* add bring integration * fix typings and remove from strictly typed - wait for python-bring-api to be ready for strictly typed * make entity unique to user and list - before it was only list, therefore the same list imported by two users would have failed * simplify bring attribute Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * cleanup and code simplification * remove empty fields in manifest * __init__.py aktualisieren Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * __init__.py aktualisieren Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * strings.json aktualisieren Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * streamline async calls * use coordinator refresh * fix order in update call and simplify bring list * simplify the config_flow * Update homeassistant/components/bring/manifest.json Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> * add unit testing for __init__.py * cleanup comments * use dict instead of list * Update homeassistant/components/bring/todo.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * clean up * update attribute name * update more attribute name * improve unit tests - remove patch and use mock in conftest * clean up tests even more * more unit test inprovements * remove optional type * minor unit test cleanup * Update .coveragerc Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> --------- Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com>
49 lines
1.4 KiB
Python
49 lines
1.4 KiB
Python
"""Common fixtures for the Bring! tests."""
|
|
from collections.abc import Generator
|
|
from unittest.mock import Mock, patch
|
|
|
|
import pytest
|
|
|
|
from homeassistant.components.bring import DOMAIN
|
|
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
|
|
|
|
from tests.common import MockConfigEntry
|
|
|
|
EMAIL = "test-email"
|
|
PASSWORD = "test-password"
|
|
|
|
UUID = "00000000-00000000-00000000-00000000"
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_setup_entry() -> Generator[Mock, None, None]:
|
|
"""Override async_setup_entry."""
|
|
with patch(
|
|
"homeassistant.components.bring.async_setup_entry", return_value=True
|
|
) as mock_setup_entry:
|
|
yield mock_setup_entry
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_bring_client() -> Generator[Mock, None, None]:
|
|
"""Mock a Bring client."""
|
|
with patch(
|
|
"homeassistant.components.bring.Bring",
|
|
autospec=True,
|
|
) as mock_client, patch(
|
|
"homeassistant.components.bring.config_flow.Bring",
|
|
new=mock_client,
|
|
):
|
|
client = mock_client.return_value
|
|
client.uuid = UUID
|
|
client.login.return_value = True
|
|
client.loadLists.return_value = {"lists": []}
|
|
yield client
|
|
|
|
|
|
@pytest.fixture(name="bring_config_entry")
|
|
def mock_bring_config_entry() -> MockConfigEntry:
|
|
"""Mock bring configuration entry."""
|
|
return MockConfigEntry(
|
|
domain=DOMAIN, data={CONF_EMAIL: EMAIL, CONF_PASSWORD: PASSWORD}, unique_id=UUID
|
|
)
|