-
Notifications
You must be signed in to change notification settings - Fork 34
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
2 changed files
with
84 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
"""pytest tests for mytoyota.client.MyT""" | ||
|
||
import pytest | ||
|
||
from mytoyota.client import MyT | ||
from mytoyota.exceptions import ( | ||
ToyotaInvalidUsername, | ||
ToyotaLocaleNotValid, | ||
ToyotaRegionNotSupported, | ||
) | ||
|
||
# pylint: disable=no-self-use | ||
|
||
|
||
class TestMyT: | ||
"""pytest functions to test MyT""" | ||
|
||
def test_myt(self): | ||
"""Test an error free initialisation of MyT""" | ||
myt = MyT( | ||
username="[email protected]", | ||
password="xxxxx", | ||
locale="en-gb", | ||
region="europe", | ||
) | ||
assert myt is not None | ||
assert myt.api is not None | ||
|
||
@pytest.mark.parametrize( | ||
"username", | ||
[None, "", "_invalid_"], | ||
) | ||
def test_myt_invalid_username(self, username): | ||
"""Test an invalid username in MyT""" | ||
with pytest.raises(ToyotaInvalidUsername): | ||
_ = MyT( | ||
username=username, password="xxxxx", locale="en-gb", region="europe" | ||
) | ||
|
||
@pytest.mark.parametrize( | ||
"locale", | ||
[ | ||
None, | ||
"", | ||
"invalid-locale", | ||
"da-en-dk-us", | ||
], | ||
) | ||
def test_myt_invalid_locale(self, locale): | ||
"""Test an invalid locale in MyT""" | ||
with pytest.raises(ToyotaLocaleNotValid): | ||
_ = MyT( | ||
username="[email protected]", | ||
password="xxxxx", | ||
locale=locale, | ||
region="europe", | ||
) | ||
|
||
@pytest.mark.parametrize( | ||
"region", | ||
[ | ||
None, | ||
"", | ||
"antartica", | ||
"mars", | ||
], | ||
) | ||
def test_myt_unsupported_region(self, region): | ||
"""Test an invalid region in MyT""" | ||
with pytest.raises(ToyotaRegionNotSupported): | ||
_ = MyT( | ||
username="[email protected]", | ||
password="xxxxx", | ||
locale="en-gb", | ||
region=region, | ||
) | ||
|
||
def test_get_supported_regions(self): | ||
"""Test the supported regions""" | ||
regions = MyT.get_supported_regions() | ||
assert regions is not None | ||
assert len(regions) > 0 | ||
assert "europe" in regions |