Skip to content

Commit

Permalink
test correct data handling
Browse files Browse the repository at this point in the history
  • Loading branch information
hannhegg committed Apr 8, 2025
1 parent ad9ec94 commit 188836e
Showing 1 changed file with 34 additions and 0 deletions.
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

0 comments on commit 188836e

Please sign in to comment.