@mock.patch('uvcclient.store.get_info_store')
    @mock.patch('uvcclient.camera.UVCCameraClient')
    def test_login_tries_both_addrs_and_caches(self, mock_camera, mock_store):
        """"Test the login tries."""
        responses = [0]

        def fake_login(*a):
            try:
                responses.pop(0)
                raise socket.error
            except __HOLE__:
                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()
        mock_camera.assert_called_once_with('host-b', 'admin', 'ubnt')
        mock_camera.return_value.login.assert_called_once_with()
dataset/ETHPy150Open home-assistant/home-assistant/tests/components/camera/test_uvc.py/TestUVC.test_login_tries_both_addrs_and_caches