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 66 67 68 69 70 71 72 73 74 75 76 77
|
"""Define shared fixtures."""
from contextlib import contextmanager
from unittest.mock import AsyncMock, patch
import pytest
import pyatmo
from .common import fake_post_request, fake_post_request_multi
@contextmanager
def does_not_raise():
yield
@pytest.fixture
async def async_auth():
"""AsyncAuth fixture."""
with patch("pyatmo.auth.AbstractAsyncAuth", AsyncMock()) as auth:
yield auth
@pytest.fixture
async def async_account(async_auth):
"""AsyncAccount fixture."""
account: pyatmo.AsyncAccount = pyatmo.AsyncAccount(async_auth)
with (
patch(
"pyatmo.auth.AbstractAsyncAuth.async_post_api_request",
fake_post_request,
),
patch(
"pyatmo.auth.AbstractAsyncAuth.async_post_request",
fake_post_request,
),
):
await account.async_update_topology()
yield account
@pytest.fixture
async def async_home(async_account):
"""AsyncClimate fixture for home_id 91763b24c43d3e344f424e8b."""
home_id = "91763b24c43d3e344f424e8b"
await async_account.async_update_status(home_id)
return async_account.homes[home_id]
@pytest.fixture
async def async_account_multi(async_auth):
"""AsyncAccount fixture."""
account: pyatmo.AsyncAccount = pyatmo.AsyncAccount(async_auth)
with (
patch(
"pyatmo.auth.AbstractAsyncAuth.async_post_api_request",
fake_post_request_multi,
),
patch(
"pyatmo.auth.AbstractAsyncAuth.async_post_request",
fake_post_request_multi,
),
):
await account.async_update_topology(
disabled_homes_ids=["eeeeeeeeeffffffffffaaaaa"],
)
yield account
@pytest.fixture
async def async_home_multi(async_account_multi):
"""AsyncClimate fixture for home_id 91763b24c43d3e344f424e8b."""
home_id = "aaaaaaaaaaabbbbbbbbbbccc"
return async_account_multi.homes[home_id]
|