Add password parameter to uvc component (#7499)

This commit is contained in:
Nuno Sousa
2017-05-09 21:54:38 -07:00
committed by Paulus Schoutsen
parent b30c352e37
commit 89d950c73a
2 changed files with 20 additions and 34 deletions
+11 -23
View File
@@ -31,6 +31,7 @@ class TestUVCSetup(unittest.TestCase):
config = {
'platform': 'uvc',
'nvr': 'foo',
'password': 'bar',
'port': 123,
'key': 'secret',
}
@@ -58,8 +59,8 @@ class TestUVCSetup(unittest.TestCase):
mock_remote.call_args, mock.call('foo', 123, 'secret')
)
mock_uvc.assert_has_calls([
mock.call(mock_remote.return_value, 'id1', 'Front'),
mock.call(mock_remote.return_value, 'id2', 'Back'),
mock.call(mock_remote.return_value, 'id1', 'Front', 'bar'),
mock.call(mock_remote.return_value, 'id2', 'Back', 'bar'),
])
@mock.patch('uvcclient.nvr.UVCRemote')
@@ -86,8 +87,8 @@ class TestUVCSetup(unittest.TestCase):
mock_remote.call_args, mock.call('foo', 7080, 'secret')
)
mock_uvc.assert_has_calls([
mock.call(mock_remote.return_value, 'id1', 'Front'),
mock.call(mock_remote.return_value, 'id2', 'Back'),
mock.call(mock_remote.return_value, 'id1', 'Front', 'ubnt'),
mock.call(mock_remote.return_value, 'id2', 'Back', 'ubnt'),
])
@mock.patch('uvcclient.nvr.UVCRemote')
@@ -114,8 +115,8 @@ class TestUVCSetup(unittest.TestCase):
mock_remote.call_args, mock.call('foo', 7080, 'secret')
)
mock_uvc.assert_has_calls([
mock.call(mock_remote.return_value, 'one', 'Front'),
mock.call(mock_remote.return_value, 'two', 'Back'),
mock.call(mock_remote.return_value, 'one', 'Front', 'ubnt'),
mock.call(mock_remote.return_value, 'two', 'Back', 'ubnt'),
])
@mock.patch.object(uvc, 'UnifiVideoCamera')
@@ -156,7 +157,9 @@ class TestUVC(unittest.TestCase):
self.nvr = mock.MagicMock()
self.uuid = 'uuid'
self.name = 'name'
self.uvc = uvc.UnifiVideoCamera(self.nvr, self.uuid, self.name)
self.password = 'seekret'
self.uvc = uvc.UnifiVideoCamera(self.nvr, self.uuid, self.name,
self.password)
self.nvr.get_camera.return_value = {
'model': 'UVC Fake',
'recordingSettings': {
@@ -179,7 +182,6 @@ class TestUVC(unittest.TestCase):
@mock.patch('uvcclient.camera.UVCCameraClientV320')
def test_login(self, mock_camera, mock_store):
""""Test the login."""
mock_store.return_value.get_camera_password.return_value = 'seekret'
self.uvc._login()
self.assertEqual(mock_camera.call_count, 1)
self.assertEqual(
@@ -192,7 +194,6 @@ class TestUVC(unittest.TestCase):
@mock.patch('uvcclient.camera.UVCCameraClient')
def test_login_v31x(self, mock_camera, mock_store):
"""Test login with v3.1.x server."""
mock_store.return_value.get_camera_password.return_value = 'seekret'
self.nvr.server_version = (3, 1, 3)
self.uvc._login()
self.assertEqual(mock_camera.call_count, 1)
@@ -202,19 +203,6 @@ class TestUVC(unittest.TestCase):
self.assertEqual(mock_camera.return_value.login.call_count, 1)
self.assertEqual(mock_camera.return_value.login.call_args, mock.call())
@mock.patch('uvcclient.store.get_info_store')
@mock.patch('uvcclient.camera.UVCCameraClientV320')
def test_login_no_password(self, mock_camera, mock_store):
""""Test the login with no password."""
mock_store.return_value.get_camera_password.return_value = None
self.uvc._login()
self.assertEqual(mock_camera.call_count, 1)
self.assertEqual(
mock_camera.call_args, mock.call('host-a', 'admin', 'ubnt')
)
self.assertEqual(mock_camera.return_value.login.call_count, 1)
self.assertEqual(mock_camera.return_value.login.call_args, mock.call())
@mock.patch('uvcclient.store.get_info_store')
@mock.patch('uvcclient.camera.UVCCameraClientV320')
def test_login_tries_both_addrs_and_caches(self, mock_camera, mock_store):
@@ -239,7 +227,7 @@ class TestUVC(unittest.TestCase):
self.uvc._login()
self.assertEqual(mock_camera.call_count, 1)
self.assertEqual(
mock_camera.call_args, mock.call('host-b', 'admin', 'ubnt')
mock_camera.call_args, mock.call('host-b', 'admin', 'seekret')
)
self.assertEqual(mock_camera.return_value.login.call_count, 1)
self.assertEqual(mock_camera.return_value.login.call_args, mock.call())