-
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.
modify test, import package right, add AAA description
- Loading branch information
toravest
committed
May 24, 2025
1 parent
4dafb49
commit a369d4f
Showing
9 changed files
with
112 additions
and
97 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
This file was deleted.
Oops, something went wrong.
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
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,37 @@ | ||
| 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.data import fetch_time_data | ||
|
|
||
| class TestFetchOneDay(unittest.TestCase): | ||
|
|
||
| def test_fetch_data(self): | ||
| # Testdata | ||
| #sample_data = {"temperature": 25, "humidity": 60} | ||
| city_name = "Oslo" | ||
| # start_date = "2025, 03, 25, 11, 00" | ||
| start_date = 1742896800 | ||
| # end_date = "2025, 03, 25, 12, 00" | ||
| end_date = 1742900400 | ||
|
|
||
| # Fetch data from the API, the underscore indicates the folder, which we dont use here | ||
| data, _ = fetch_time_data(start_date, end_date, city_name) | ||
|
|
||
| # Test if data is collected correctly | ||
| # We know the data is stored inside the 'list' | ||
| if data and "list" in data and data["list"]: | ||
| # Then we know both temp and humidity is stored inside the 'main' | ||
| self.assertIn("temp", data["list"][0]["main"]) | ||
| self.assertIn("humidity", data["list"][0]["main"]) | ||
| # And we check if wind is in the list | ||
| self.assertIn("wind", data["list"][0]) | ||
| else: | ||
| self.fail("No data returned from the API") | ||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() | ||
|
|
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
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
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
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
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