-
Notifications
You must be signed in to change notification settings - Fork 0
/
database_test.py
30 lines (22 loc) · 965 Bytes
/
database_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from database import DB
from sqlalchemy.orm import sessionmaker
import unittest
import json
from database_definitions import Forecast, Status, Extraction, Office
class TestDatabase(unittest.TestCase):
def setUp(self):
self.db = DB()
Session = sessionmaker(bind=self.db.engine)
self.session = Session()
office_info = 'data/NWS_OFFICE_LOCATION.json'
with open(office_info, 'r') as j:
self.office_locations = json.load(j)
def test_validate_office_information(self):
for office_id, location in self.office_locations.items():
office = self.session.query(Office).filter_by(name=office_id).one()
self.assertEqual(office.name, office_id)
self.assertEqual(office.city, location['City'])
self.assertEqual(office.address, location['Address'])
self.assertEqual(office.state, location['State'])
if __name__ == "__main__":
unittest.main()