def camera_home_data(auth, requests_mock):
    with open("fixtures/camera_home_data.json") as json_file:
        json_fixture = json.load(json_file)
    requests_mock.post(
        pyatmo.camera._GETHOMEDATA_REQ,
        json=json_fixture,
        headers={"content-type": "application/json"},
    )
    for index in ["w", "z", "g"]:
        vpn_url = (
            f"https://prodvpn-eu-2.netatmo.net/restricted/10.255.248.91/"
            f"6d278460699e56180d47ab47169efb31/"
            f"MpEylTU2MDYzNjRVD-LJxUnIndumKzLboeAwMDqTT{index},,"
        )
        with open("fixtures/camera_ping.json") as json_file:
            json_fixture = json.load(json_file)
        requests_mock.post(
            vpn_url + "/command/ping",
            json=json_fixture,
            headers={"content-type": "application/json"},
        )
    local_url = "http://192.168.0.123/678460a0d47e5618699fb31169e2b47d"
    with open("fixtures/camera_ping.json") as json_file:
        json_fixture = json.load(json_file)
    requests_mock.post(
        local_url + "/command/ping",
        json=json_fixture,
        headers={"content-type": "application/json"},
    )
    return pyatmo.CameraData(auth)
Exemple #2
0
def cameraHomeData(auth, requests_mock):
    with open("fixtures/camera_home_data.json") as f:
        json_fixture = json.load(f)
    requests_mock.post(
        pyatmo.camera._GETHOMEDATA_REQ,
        json=json_fixture,
        headers={"content-type": "application/json"},
    )
    return pyatmo.CameraData(auth)
def test_home_data_no_homes(auth, requests_mock):
    with open("fixtures/camera_home_data_no_homes.json") as fixture_file:
        json_fixture = json.load(fixture_file)
    requests_mock.post(
        pyatmo.camera._GETHOMEDATA_REQ,
        json=json_fixture,
        headers={"content-type": "application/json"},
    )
    with pytest.raises(pyatmo.NoDevice):
        assert pyatmo.CameraData(auth)
def test_CameraData_cameraUrls_disconnected(auth, requests_mock):
    with open("fixtures/camera_home_data_disconnected.json") as f:
        json_fixture = json.load(f)
    requests_mock.post(
        pyatmo.camera._GETHOMEDATA_REQ,
        json=json_fixture,
        headers={"content-type": "application/json"},
    )
    camera_data = pyatmo.CameraData(auth)
    assert camera_data.cameraUrls() == (None, None)
def test_camera_data_camera_urls_disconnected(auth, requests_mock):
    with open("fixtures/camera_home_data_disconnected.json") as fixture_file:
        json_fixture = json.load(fixture_file)
    requests_mock.post(
        pyatmo.camera._GETHOMEDATA_REQ,
        json=json_fixture,
        headers={"content-type": "application/json"},
    )
    camera_data = pyatmo.CameraData(auth)
    cid = "12:34:56:00:f1:62"

    camera_data.update_camera_urls(cid)

    assert camera_data.camera_urls(cid) == (None, None)
    def update(self):
        """Call the Netatmo API to update the data."""
        import pyatmo

        self.camera_data = pyatmo.CameraData(self.auth, size=100)
Exemple #7
0
 def update(self):
     """Call the Netatmo API to update the data."""
     self.camera_data = pyatmo.CameraData(self.auth, size=100)
     self.update_persons()