Skip to content

test correct data handling #9

Merged
merged 1 commit into from
Apr 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions tests/unit/test_4_one_day.py
Original file line number Diff line number Diff line change
@@ -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