コード例 #1
0
def test_hvac_start_later(mocked_responses: aioresponses,
                          cli_runner: CliRunner) -> None:
    """It exits with a status code of zero."""
    initialise_credential_store(include_account_id=True, include_vin=True)
    url = fixtures.inject_set_hvac_start(mocked_responses, "start")

    result = cli_runner.invoke(
        __main__.main,
        "hvac start --temperature 24 --at '2020-12-25T11:50:00+02:00'")
    assert result.exit_code == 0, result.exception

    expected_json = {
        "data": {
            "attributes": {
                "action": "start",
                "startDateTime": "2020-12-25T09:50:00Z",
                "targetTemperature": 24,
            },
            "type": "HvacStart",
        }
    }
    expected_output = "{'action': 'start', 'targetTemperature': 21.0}\n"
    request: RequestCall = mocked_responses.requests[("POST", URL(url))][0]
    assert expected_json == request.kwargs["json"]
    assert expected_output == result.output
コード例 #2
0
async def test_set_vehicle_action(websession: aiohttp.ClientSession,
                                  mocked_responses: aioresponses) -> None:
    """Test set_vehicle_action."""
    url = fixtures.inject_set_hvac_start(mocked_responses, "cancel")
    assert await kamereon.set_vehicle_action(
        websession=websession,
        root_url=TEST_KAMEREON_URL,
        api_key=TEST_KAMEREON_APIKEY,
        gigya_jwt=fixtures.get_jwt(),
        country=TEST_COUNTRY,
        account_id=TEST_ACCOUNT_ID,
        vin=TEST_VIN,
        endpoint="hvac-start",
        attributes={"action": "cancel"},
    )

    expected_json = {
        "data": {
            "type": "HvacStart",
            "attributes": {
                "action": "cancel"
            }
        }
    }

    request: RequestCall = mocked_responses.requests[("POST", URL(url))][0]
    assert expected_json == request.kwargs["json"]
コード例 #3
0
async def test_set_ac_stop(vehicle: RenaultVehicle,
                           mocked_responses: aioresponses) -> None:
    """Test set_ac_stop."""
    url = fixtures.inject_set_hvac_start(mocked_responses, "cancel")
    assert await vehicle.set_ac_stop()

    expected_json = {
        "data": {
            "type": "HvacStart",
            "attributes": {
                "action": "cancel"
            }
        }
    }

    request: RequestCall = mocked_responses.requests[("POST", URL(url))][0]
    assert expected_json == request.kwargs["json"]
コード例 #4
0
async def test_set_ac_start(vehicle: RenaultVehicle,
                            mocked_responses: aioresponses) -> None:
    """Test set_ac_start."""
    url = fixtures.inject_set_hvac_start(mocked_responses, "start")
    assert await vehicle.set_ac_start(
        21, datetime(2020, 11, 24, 6, 30, tzinfo=timezone.utc))

    expected_json = {
        "data": {
            "type": "HvacStart",
            "attributes": {
                "action": "start",
                "targetTemperature": 21,
                "startDateTime": "2020-11-24T06:30:00Z",
            },
        }
    }

    request: RequestCall = mocked_responses.requests[("POST", URL(url))][0]
    assert expected_json == request.kwargs["json"]
コード例 #5
0
ファイル: test_vehicle_hvac.py プロジェクト: PysX/renault-api
def test_hvac_cancel(mocked_responses: aioresponses,
                     cli_runner: CliRunner) -> None:
    """It exits with a status code of zero."""
    initialise_credential_store(include_account_id=True, include_vin=True)
    url = fixtures.inject_set_hvac_start(mocked_responses, result="cancel")

    result = cli_runner.invoke(__main__.main, "hvac cancel")
    assert result.exit_code == 0, result.exception

    expected_json = {
        "data": {
            "attributes": {
                "action": "cancel"
            },
            "type": "HvacStart"
        }
    }
    expected_output = "{'action': 'cancel'}\n"

    request: RequestCall = mocked_responses.requests[("POST", URL(url))][0]
    assert expected_json == request.kwargs["json"]
    assert expected_output == result.output