'"Test the login tries.'

@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):

    responses = [0]
    def fake_login(*a):
        'Fake    login.'
        try:
            responses.pop(0)
            raise socket.error
        except IndexError:
            pass
    mock_store.return_value.get_camera_password.return_value = None
    mock_camera.return_value.login.side_effect = fake_login
    self.uvc._login()
    self.assertEqual(2, mock_camera.call_count)
    self.assertEqual('host-b', self.uvc._connect_addr)
    mock_camera.reset_mock()
    self.uvc._login()
    self.assertEqual(mock_camera.call_count, 1)
    self.assertEqual(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())
