diff --git a/tests/unit/test_4_one_day.py b/tests/unit/test_4_one_day.py new file mode 100644 index 0000000..0efacf6 --- /dev/null +++ b/tests/unit/test_4_one_day.py @@ -0,0 +1,34 @@ +import unittest +import sys +import os + +# Add the src folder to the Python path +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../src'))) + +from my_package.fetch_data import fetch_data + +class TestPart4(unittest.TestCase): + + def test_fetch_data(self): + # Testdata + #sample_data = {"temperature": 25, "humidity": 60} + city_name = "Oslo" + start_date = "2025, 03, 25, 11, 00" + end_date = "2025, 03, 25, 12, 00" + + # Hent data fra API + data = fetch_data(start_date, end_date, city_name) + + # Sjekk om dataene som ble hentet er riktige + if data: + self.assertIn("temperature", data) + self.assertIn("humidity", data) + #else: + #self.fail("No data returned from the API") + +if __name__ == "__main__": + unittest.main() + + +#this test is to test if the function write_data and fetch_data is working as we expect it to, tests if the data can writes to a file and read data back from the file and, and that the data read back is identical to the one written +#this test makes sure that data can be handled in a correct way \ No newline at end of file