Fix broken tests

This commit is contained in:
Kevin Fronczak
2019-01-26 14:35:28 -05:00
parent 1daf5d22af
commit 4297290fba
3 changed files with 23 additions and 9 deletions
+6 -2
View File
@@ -138,9 +138,13 @@ class TestBlinkSetup(unittest.TestCase):
now = self.blink.refresh_rate + 1
mock_time.return_value = now
self.assertEqual(self.blink.last_refresh, None)
result = self.blink.check_if_ok_to_update()
self.assertEqual(self.blink.check_if_ok_to_update(), True)
self.assertEqual(self.blink.last_refresh, None)
with mock.patch('blinkpy.sync_module.BlinkSyncModule.refresh',
return_value=True):
self.blink.refresh()
self.assertEqual(self.blink.last_refresh, now)
self.assertEqual(result, True)
self.assertEqual(self.blink.check_if_ok_to_update(), False)
self.assertEqual(self.blink.last_refresh, now)
+13 -5
View File
@@ -70,7 +70,12 @@ class TestBlinkCameraSetup(unittest.TestCase):
'thumbnail': '/thumb',
}
self.camera.last_record = ['1']
self.camera.sync.all_clips = {'new': {'1': '/test.mp4'}}
self.camera.sync.last_record = {
'new': {
'clip': '/test.mp4',
'time': '1970-01-01T00:00:00'
}
}
mock_sess.side_effect = [
mresp.MockResponse({'temp': 71}, 200),
'test',
@@ -102,8 +107,12 @@ class TestBlinkCameraSetup(unittest.TestCase):
'barfoo'
]
self.camera.last_record = ['1']
self.camera.sync.record_dates['new'] = ['1']
self.camera.sync.all_clips = {'new': {'1': '/test.mp4'}}
self.camera.sync.last_record = {
'new': {
'clip': '/test.mp4',
'time': '1970-01-01T00:00:00'
}
}
config = {
'name': 'new',
'camera_id': 1234,
@@ -133,8 +142,6 @@ class TestBlinkCameraSetup(unittest.TestCase):
"""Tests that thumbnail is 'None' if none found."""
mock_sess.return_value = 'foobar'
self.camera.last_record = ['1']
self.camera.sync.record_dates['new'] = ['1']
self.camera.sync.all_clips = {'new': {'1': '/test.mp4'}}
config = {
'name': 'new',
'camera_id': 1234,
@@ -153,6 +160,7 @@ class TestBlinkCameraSetup(unittest.TestCase):
with self.assertLogs() as logrecord:
self.camera.update(config)
self.assertEqual(self.camera.thumbnail, None)
self.assertEqual(self.camera.last_record, ['1'])
self.assertEqual(
logrecord.output,
["ERROR:blinkpy.camera:Could not retrieve calibrated temperature.",
+4 -2
View File
@@ -1,5 +1,6 @@
"""Tests camera and system functions."""
import unittest
import pytest
from unittest import mock
from blinkpy import blinkpy
@@ -42,6 +43,7 @@ class TestBlinkSyncModule(unittest.TestCase):
mock_resp.return_value = {'devicestatus': True}
self.assertEqual(self.blink.sync['test'].get_camera_info(), True)
@pytest.mark.skip(reason="Method removed.")
def test_get_videos_one_page(self, mock_resp):
"""Test video access."""
mock_resp.return_value = [
@@ -62,6 +64,7 @@ class TestBlinkSyncModule(unittest.TestCase):
self.assertEqual(self.blink.sync['test'].record_dates, expected_recs)
self.assertEqual(self.blink.sync['test'].all_clips, expected_clips)
@pytest.mark.skip(reason="Method removed.")
def test_get_videos_multi_page(self, mock_resp):
"""Test video access with multiple pages."""
mock_resp.return_value = [
@@ -88,9 +91,8 @@ class TestBlinkSyncModule(unittest.TestCase):
{'event': True},
{},
{},
{'devicestatus': {}},
None,
None
{'devicestatus': {}},
]
self.blink.sync['test'].start()
self.assertEqual(self.blink.sync['test'].name, 'test')