-
Notifications
You must be signed in to change notification settings - Fork 1
/
location_provider_test.py
31 lines (23 loc) · 1.15 KB
/
location_provider_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
31
import time
import unittest
from location_provider import LocationProvider, SizeExceededError
class LocationProviderTest(unittest.TestCase):
def test_missing_gets_next_location(self):
location_provider = LocationProvider('location_provider_test.csv', 1)
location = location_provider['0123456789']
self.assertEqual(location['latitude'], '52')
self.assertEqual(location['longitude'], '13')
self.assertEqual(location['name'], 'Niedergörsdorf')
def test_exceeding_size_raises_error(self):
location_provider = LocationProvider('location_provider_test.csv', 1)
location = location_provider['1111111111']
with self.assertRaises(SizeExceededError): location = location_provider['2222222222']
def test_locations_repeat(self):
location_provider = LocationProvider('location_provider_test.csv', 1)
location = location_provider['0123456789']
self.assertEqual(location['name'], 'Niedergörsdorf')
time.sleep(1)
location = location_provider['0123456789']
self.assertEqual(location['name'], 'Niedergörsdorf')
if __name__ == '__main__':
unittest.main()