Skip to content

Commit

Permalink
Add test for station_file
Browse files Browse the repository at this point in the history
  • Loading branch information
FL550 committed Oct 9, 2023
1 parent 88a20f1 commit f77296c
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/test_stationsfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import random
import unittest

from simple_dwd_weatherforecast import dwdforecast
import json


class StationsFileTestCase(unittest.TestCase):
FILE_NAME = "stations.json"

def setUp(self):
with open(self.FILE_NAME, encoding="utf-8", mode="r") as file:
self.stations = json.load(file)

def test_all_properties(self):
random_item = random.choice(list(self.stations.items()))[1]
self.assertTrue("icao" in random_item)
self.assertTrue("report_available" in random_item)
self.assertTrue("name" in random_item)
self.assertTrue("lat" in random_item)
self.assertTrue("lon" in random_item)
self.assertTrue("elev" in random_item)
self.assertTrue("bundesland" in random_item)

def test_contains(self):
self.assertTrue("N7651" in self.stations)
self.assertTrue("X104" in self.stations)
self.assertTrue("78458" in self.stations)
self.assertTrue("48564" in self.stations)

def test_correct_mapping(self):
self.assertTrue(self.stations["H721"]["name"] == "Bedburg-Weiler Hohen")
self.assertTrue(self.stations["78458"]["name"] == "Puerto Plata")
self.assertTrue(self.stations["H361"]["name"] == "Beckum-Unterberg")

0 comments on commit f77296c

Please sign in to comment.