1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
"""Test cases for the Renault client API keys."""
import aiohttp
import pytest
from aioresponses import aioresponses
from tests import fixtures
from tests.const import TEST_ACCOUNT_ID
from tests.const import TEST_COUNTRY
from tests.const import TEST_LOCALE_DETAILS
from tests.const import TEST_VIN
from tests.test_credential_store import get_logged_in_credential_store
from tests.test_renault_session import get_logged_in_session
from renault_api.renault_account import RenaultAccount
@pytest.fixture
def account(websession: aiohttp.ClientSession) -> RenaultAccount:
"""Fixture for testing RenaultAccount."""
return RenaultAccount(
account_id=TEST_ACCOUNT_ID,
session=get_logged_in_session(websession),
)
def tests_init(websession: aiohttp.ClientSession) -> None:
"""Test RenaultAccount initialisation."""
assert RenaultAccount(
account_id=TEST_ACCOUNT_ID,
session=get_logged_in_session(websession),
)
assert RenaultAccount(
account_id=TEST_ACCOUNT_ID,
websession=websession,
country=TEST_COUNTRY,
locale_details=TEST_LOCALE_DETAILS,
credential_store=get_logged_in_credential_store(),
)
@pytest.mark.asyncio
async def test_get_vehicles(
account: RenaultAccount, mocked_responses: aioresponses
) -> None:
"""Test get_vehicles."""
fixtures.inject_get_vehicles(mocked_responses, "zoe_40.1.json")
await account.get_vehicles()
@pytest.mark.asyncio
async def test_get_api_vehicles(
account: RenaultAccount, mocked_responses: aioresponses
) -> None:
"""Test get_api_vehicles."""
fixtures.inject_get_vehicles(mocked_responses, "zoe_40.1.json")
await account.get_api_vehicles()
@pytest.mark.asyncio
async def test_get_api_vehicle(account: RenaultAccount) -> None:
"""Test get_api_vehicle."""
vehicle = await account.get_api_vehicle(TEST_VIN)
assert vehicle._vin == TEST_VIN
|