-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from torave/main
Hanne - test
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |