Exemplo n.º 1
0
async def test_get_device_not_adopted_enabled(protect_client: ProtectApiClient, camera):
    camera["isAdopted"] = False
    protect_client.ignore_unadopted = False
    protect_client.api_request_obj = AsyncMock(return_value=camera)  # type: ignore

    obj = create_from_unifi_dict(camera)
    assert obj == await protect_client.get_camera("test_id")
Exemplo n.º 2
0
async def test_bootstrap_fix_record_mode(bootstrap):
    expected_updates = 1
    orig_bootstrap = deepcopy(bootstrap)
    bootstrap["cameras"][0]["recordingSettings"]["mode"] = "motion"
    if len(bootstrap["cameras"]) > 1:
        expected_updates = 2
        bootstrap["cameras"][1]["recordingSettings"]["mode"] = "smartDetect"

    client = ProtectApiClient("127.0.0.1", 0, "username", "password", debug=True)
    client.api_request_obj = AsyncMock(side_effect=[bootstrap, orig_bootstrap])
    client.update_device = AsyncMock()

    await client.get_bootstrap()

    assert client.api_request_obj.call_count == 2
    assert client.update_device.call_count == expected_updates
Exemplo n.º 3
0
async def test_get_device_not_adopted(protect_client: ProtectApiClient, camera):
    camera["isAdopted"] = False
    protect_client.api_request_obj = AsyncMock(return_value=camera)  # type: ignore

    with pytest.raises(NvrError):
        await protect_client.get_camera("test_id")
Exemplo n.º 4
0
async def test_get_device_mismatch(protect_client: ProtectApiClient, camera):
    protect_client.api_request_obj = AsyncMock(return_value=camera)  # type: ignore

    with pytest.raises(NvrError):
        await protect_client.get_bridge("test_id")