-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
48 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"""Countries util.""" | ||
from __future__ import annotations | ||
|
||
_MAP_COUNTRY: dict[str, str] = {"GB": "UK"} | ||
|
||
|
||
def get_ecovacs_country(alpha_2_country: str) -> str: | ||
"""Get the country used by ecovacs from a ISO 3166 alpha2 country.""" | ||
return _MAP_COUNTRY.get(alpha_2_country, alpha_2_country) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
mypy==1.8.0 | ||
pre-commit==3.6.0 | ||
pycountry==23.12.11 | ||
pylint==3.0.3 | ||
pytest==7.4.4 | ||
pytest-asyncio==0.23.4 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,26 @@ | ||
from __future__ import annotations | ||
|
||
import pycountry | ||
import pytest | ||
|
||
from deebot_client.util.continents import get_continent | ||
from deebot_client.util.continents import COUNTRIES_TO_CONTINENTS, get_continent | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("continent", "expected"), | ||
[ | ||
("IT", "eu"), | ||
("it", "eu"), | ||
("DE", "eu"), | ||
("US", "na"), | ||
("invalid", "ww"), | ||
("", "ww"), | ||
("XX", "ww"), | ||
], | ||
) | ||
def test_get_continent(continent: str, expected: str) -> None: | ||
assert get_continent(continent) == expected | ||
|
||
|
||
def test_countries_list_match_pxycountries_one() -> None: | ||
expected_contires = {c.alpha_2 for c in pycountry.countries} | ||
|
||
assert set(COUNTRIES_TO_CONTINENTS.keys()) == expected_contires |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from __future__ import annotations | ||
|
||
import pytest | ||
|
||
from deebot_client.util.countries import get_ecovacs_country | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("continent", "expected"), | ||
[ | ||
("IT", "IT"), | ||
("GB", "UK"), | ||
], | ||
) | ||
def test_get_ecovacs_country(continent: str, expected: str) -> None: | ||
assert get_ecovacs_country(continent) == expected |