Skip to content

Commit

Permalink
Added pyvcr tests to data module
Browse files Browse the repository at this point in the history
  • Loading branch information
netmanchris committed Oct 12, 2019
1 parent f70de8f commit f0e49a1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ nose
requests
sphinxcontrib-napoleon
python-coveralls
pyvcr
vcrpy
32 changes: 27 additions & 5 deletions tests/test_pyuhooair_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class TestGetAllDevices(TestCase):
Test Case for pyawair.data get_current_air_data function
"""

#@vcr.use_cassette(cassette_library_dir='./tests/fixtures/cassettes')
@vcr.use_cassette(cassette_library_dir='./tests/fixtures/cassettes',filter_post_data_parameters=['username','password'])
def test_GetAllDevices(self):
"""
"""
Expand All @@ -46,6 +46,8 @@ class TestCurrentData(TestCase):
Test Case for pyawair.data get_current_air_data function
"""

@vcr.use_cassette(cassette_library_dir='./tests/fixtures/cassettes',
filter_post_data_parameters=['username', 'password'])
def test_GetCurrentData_id_pos(self):
"""
"""
Expand All @@ -65,6 +67,8 @@ def test_GetCurrentData_id_pos(self):
self.assertIn('Temperature', keys)
self.assertIn('DateTime', keys)

@vcr.use_cassette(cassette_library_dir='./tests/fixtures/cassettes',
filter_post_data_parameters=['username', 'password'])
def test_GetCurrentData_id_neg(self):
"""
"""
Expand All @@ -73,6 +77,8 @@ def test_GetCurrentData_id_neg(self):
current_data = get_current_data(auth, serial='Doesnt Exist')
self.assertEqual(current_data, {'message': 'Incorrect serialNumber', 'status': 2})

@vcr.use_cassette(cassette_library_dir='./tests/fixtures/cassettes',
filter_post_data_parameters=['username', 'password'])
def test_GetCurrentData_name_pos(self):
"""
"""
Expand All @@ -92,6 +98,8 @@ def test_GetCurrentData_name_pos(self):
self.assertIn('Temperature', keys)
self.assertIn('DateTime', keys)

@vcr.use_cassette(cassette_library_dir='./tests/fixtures/cassettes',
filter_post_data_parameters=['username', 'password'])
def test_GetCurrentData_name_neg(self):
"""
"""
Expand All @@ -108,6 +116,8 @@ class TestHourlyData(TestCase):
Test Case for pyawair.data get_hourly_air_data function
"""

@vcr.use_cassette(cassette_library_dir='./tests/fixtures/cassettes',
filter_post_data_parameters=['username', 'password'])
def test_GetHourlyData_id_pos(self):
"""
"""
Expand All @@ -128,13 +138,16 @@ def test_GetHourlyData_id_pos(self):
self.assertIn('Temperature', keys)
self.assertIn('DateTime', keys)


@vcr.use_cassette(cassette_library_dir='./tests/fixtures/cassettes',
filter_post_data_parameters=['username', 'password'])
def test_GetHourlyData_id_neg(self):
"""
"""
hourly_data = get_hourly_data(auth, serial='Doesnt Exist')
self.assertEqual(hourly_data, {'message': 'Incorrect serialNumber', 'status': 2})

@vcr.use_cassette(cassette_library_dir='./tests/fixtures/cassettes',
filter_post_data_parameters=['username', 'password'])
def test_GetHourlyData_name_pos(self):
"""
"""
Expand All @@ -154,6 +167,8 @@ def test_GetHourlyData_name_pos(self):
self.assertIn('Temperature', keys)
self.assertIn('DateTime', keys)

@vcr.use_cassette(cassette_library_dir='./tests/fixtures/cassettes',
filter_post_data_parameters=['username', 'password'])
def test_GetHourlyData_name_neg(self):
"""
"""
Expand All @@ -168,15 +183,17 @@ class TestDailyData(TestCase):
Test Case for pyawair.data get_daily_air_data function
"""

@vcr.use_cassette(cassette_library_dir='./tests/fixtures/cassettes',
filter_post_data_parameters=['username', 'password'])
def test_GetDailyData_id_pos(self):
"""
"""
devices = get_all_devices(auth)
dev1 = devices[0]
daily_data = get_daily_data(auth, serial=dev1['serialNumber'])
print(daily_data)
self.assertEqual(type(daily_data), dict)
keys = daily_data.keys()
self.assertEqual(type(daily_data), list)
keys = daily_data[0].keys()
self.assertIn('Ozone', keys)
self.assertIn('Timestamp', keys)
self.assertIn('TVOC', keys)
Expand All @@ -188,13 +205,16 @@ def test_GetDailyData_id_pos(self):
self.assertIn('Temperature', keys)
self.assertIn('DateTime', keys)


@vcr.use_cassette(cassette_library_dir='./tests/fixtures/cassettes',
filter_post_data_parameters=['username', 'password'])
def test_GetDailyData_id_neg(self):
"""
"""
daily_data = get_daily_data(auth, serial='Doesnt Exist')
self.assertEqual(daily_data, {'message': 'Incorrect serialNumber', 'status': 2})

@vcr.use_cassette(cassette_library_dir='./tests/fixtures/cassettes',
filter_post_data_parameters=['username', 'password'])
def test_GetDailyData_name_pos(self):
"""
"""
Expand All @@ -214,6 +234,8 @@ def test_GetDailyData_name_pos(self):
self.assertIn('Temperature', keys)
self.assertIn('DateTime', keys)

@vcr.use_cassette(cassette_library_dir='./tests/fixtures/cassettes',
filter_post_data_parameters=['username', 'password'])
def test_GetDailyData_name_neg(self):
"""
"""
Expand Down

0 comments on commit f0e49a1

Please sign in to comment.