Add sensor platform to Bring integration (#126642)
* Add sensor platform to Bring integration * Add more tests * unignore typedef check * Update language sensor * update snapshot * changes * add entities Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * add units * lowercase * snapshot --------- Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
This commit is contained in:
parent
c66e2dc076
commit
20030ab604
17 changed files with 910 additions and 9 deletions
56
tests/components/bring/test_util.py
Normal file
56
tests/components/bring/test_util.py
Normal file
|
@ -0,0 +1,56 @@
|
|||
"""Test for utility functions of the Bring! integration."""
|
||||
|
||||
from typing import cast
|
||||
|
||||
from bring_api import BringUserSettingsResponse
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.bring import DOMAIN
|
||||
from homeassistant.components.bring.coordinator import BringData
|
||||
from homeassistant.components.bring.util import list_language, sum_attributes
|
||||
|
||||
from tests.common import load_json_object_fixture
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("list_uuid", "expected"),
|
||||
[
|
||||
("e542eef6-dba7-4c31-a52c-29e6ab9d83a5", "de-DE"),
|
||||
("b4776778-7f6c-496e-951b-92a35d3db0dd", "en-US"),
|
||||
("00000000-0000-0000-0000-00000000", None),
|
||||
],
|
||||
)
|
||||
def test_list_language(list_uuid: str, expected: str | None) -> None:
|
||||
"""Test function list_language."""
|
||||
|
||||
result = list_language(
|
||||
list_uuid,
|
||||
cast(
|
||||
BringUserSettingsResponse,
|
||||
load_json_object_fixture("usersettings.json", DOMAIN),
|
||||
),
|
||||
)
|
||||
|
||||
assert result == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("attribute", "expected"),
|
||||
[
|
||||
("urgent", 2),
|
||||
("convenient", 2),
|
||||
("discounted", 2),
|
||||
],
|
||||
)
|
||||
def test_sum_attributes(attribute: str, expected: int) -> None:
|
||||
"""Test function sum_attributes."""
|
||||
|
||||
result = sum_attributes(
|
||||
cast(
|
||||
BringData,
|
||||
load_json_object_fixture("items.json", DOMAIN),
|
||||
),
|
||||
attribute,
|
||||
)
|
||||
|
||||
assert result == expected
|
Loading…
Add table
Add a link
Reference in a new issue