myPyllant 0.4.2__tar.gz → 0.4.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. {mypyllant-0.4.2 → mypyllant-0.4.3}/PKG-INFO +1 -1
  2. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/api.py +9 -7
  3. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/tests/test_api.py +23 -2
  4. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/tests/utils.py +7 -1
  5. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/utils.py +3 -1
  6. {mypyllant-0.4.2 → mypyllant-0.4.3}/.dockerignore +0 -0
  7. {mypyllant-0.4.2 → mypyllant-0.4.3}/.github/workflows/build-test.yaml +0 -0
  8. {mypyllant-0.4.2 → mypyllant-0.4.3}/.github/workflows/docker.yaml +0 -0
  9. {mypyllant-0.4.2 → mypyllant-0.4.3}/.gitignore +0 -0
  10. {mypyllant-0.4.2 → mypyllant-0.4.3}/.pre-commit-config.yaml +0 -0
  11. {mypyllant-0.4.2 → mypyllant-0.4.3}/Dockerfile +0 -0
  12. {mypyllant-0.4.2 → mypyllant-0.4.3}/LICENSE +0 -0
  13. {mypyllant-0.4.2 → mypyllant-0.4.3}/README.md +0 -0
  14. {mypyllant-0.4.2 → mypyllant-0.4.3}/logo.png +0 -0
  15. {mypyllant-0.4.2 → mypyllant-0.4.3}/pyproject.toml +0 -0
  16. {mypyllant-0.4.2 → mypyllant-0.4.3}/requirements-dev.txt +0 -0
  17. {mypyllant-0.4.2 → mypyllant-0.4.3}/run_pytest.sh +0 -0
  18. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/__init__.py +0 -0
  19. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/const.py +0 -0
  20. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/export.py +0 -0
  21. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/models.py +0 -0
  22. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/py.typed +0 -0
  23. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/sample.py +0 -0
  24. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/tests/__init__.py +0 -0
  25. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/tests/conftest.py +0 -0
  26. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/tests/find_countries.py +0 -0
  27. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/tests/generate_test_data.py +0 -0
  28. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/tests/json/56f4c513b87875849a089b83cafbe6fdd6020b55/claims.json +0 -0
  29. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/tests/json/56f4c513b87875849a089b83cafbe6fdd6020b55/connection_status.json +0 -0
  30. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/tests/json/56f4c513b87875849a089b83cafbe6fdd6020b55/control_identifier.json +0 -0
  31. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/tests/json/56f4c513b87875849a089b83cafbe6fdd6020b55/current_system.json +0 -0
  32. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/tests/json/56f4c513b87875849a089b83cafbe6fdd6020b55/device_buckets.json +0 -0
  33. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/tests/json/56f4c513b87875849a089b83cafbe6fdd6020b55/firmware_update_required.json +0 -0
  34. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/tests/json/56f4c513b87875849a089b83cafbe6fdd6020b55/system.json +0 -0
  35. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/tests/json/56f4c513b87875849a089b83cafbe6fdd6020b55/time_zone.json +0 -0
  36. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/tests/json/cf6a60bfab7c00bc4bd13cc80618315d9cec2129/claims.json +0 -0
  37. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/tests/json/cf6a60bfab7c00bc4bd13cc80618315d9cec2129/connection_status.json +0 -0
  38. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/tests/json/cf6a60bfab7c00bc4bd13cc80618315d9cec2129/control_identifier.json +0 -0
  39. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/tests/json/cf6a60bfab7c00bc4bd13cc80618315d9cec2129/current_system.json +0 -0
  40. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/tests/json/cf6a60bfab7c00bc4bd13cc80618315d9cec2129/device_buckets.json +0 -0
  41. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/tests/json/cf6a60bfab7c00bc4bd13cc80618315d9cec2129/firmware_update_required.json +0 -0
  42. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/tests/json/cf6a60bfab7c00bc4bd13cc80618315d9cec2129/system.json +0 -0
  43. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/tests/json/cf6a60bfab7c00bc4bd13cc80618315d9cec2129/time_zone.json +0 -0
  44. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/tests/test_countries.py +0 -0
  45. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/tests/test_export.py +0 -0
  46. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/tests/test_generate_test_data.py +0 -0
  47. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/tests/test_sample.py +0 -0
  48. {mypyllant-0.4.2 → mypyllant-0.4.3}/src/myPyllant/tests/update_sample.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: myPyllant
3
- Version: 0.4.2
3
+ Version: 0.4.3
4
4
  Summary: A Python library to interact with the API behind the myVAILLANT app
5
5
  Project-URL: Homepage, https://github.com/signalkraft/myPyllant
6
6
  Project-URL: Bug Tracker, https://github.com/signalkraft/myPyllant/issues
@@ -84,13 +84,15 @@ class MyPyllantAPI:
84
84
  raise ValueError(
85
85
  f"Invalid brand, must be one of {', '.join(BRANDS.keys())}"
86
86
  )
87
- if country and country not in COUNTRIES[brand].keys():
88
- raise RealmInvalid(
89
- f"Invalid country, {BRANDS[brand]} only supports {', '.join(COUNTRIES[brand].keys())}"
90
- )
91
- if not country and brand in COUNTRIES and COUNTRIES[brand]:
92
- # If a brand has countries defined, a country needs to be provided
93
- raise RealmInvalid(f"{BRANDS[brand]} requires country to be passed")
87
+ if brand in COUNTRIES:
88
+ # Only need to valid country, if the brand exists as a key in COUNTRIES
89
+ if not country:
90
+ raise RealmInvalid(f"{BRANDS[brand]} requires country to be passed")
91
+ elif country not in COUNTRIES[brand].keys():
92
+ raise RealmInvalid(
93
+ f"Invalid country, {BRANDS[brand]} only supports {', '.join(COUNTRIES[brand].keys())}"
94
+ )
95
+
94
96
  self.username = username
95
97
  self.password = password
96
98
  self.country = country
@@ -4,7 +4,7 @@ from datetime import datetime, timedelta, tzinfo
4
4
  import pytest
5
5
  from freezegun import freeze_time
6
6
 
7
- from myPyllant.api import MyPyllantAPI
7
+ from myPyllant.api import MyPyllantAPI, RealmInvalid
8
8
  from myPyllant.models import (
9
9
  Device,
10
10
  DeviceData,
@@ -29,7 +29,7 @@ def get_test_data():
29
29
  return test_data
30
30
 
31
31
 
32
- async def test_login(mypyllant_aioresponses) -> None:
32
+ async def test_login_vaillant(mypyllant_aioresponses) -> None:
33
33
  with mypyllant_aioresponses() as _:
34
34
  async with MyPyllantAPI(
35
35
  "test@example.com", "test", "vaillant", "germany"
@@ -40,6 +40,27 @@ async def test_login(mypyllant_aioresponses) -> None:
40
40
  assert "Authorization" in mocked_api.get_authorized_headers()
41
41
 
42
42
 
43
+ async def test_login_bulex(mypyllant_aioresponses) -> None:
44
+ with mypyllant_aioresponses() as _:
45
+ async with MyPyllantAPI(
46
+ "test@example.com", "test", "bulex", None
47
+ ) as mocked_api:
48
+ assert isinstance(mocked_api.oauth_session_expires, datetime)
49
+ assert mocked_api.oauth_session_expires > datetime.now()
50
+ assert mocked_api.access_token == "access_token"
51
+ assert "Authorization" in mocked_api.get_authorized_headers()
52
+
53
+
54
+ async def test_login_invalid_country(mypyllant_aioresponses) -> None:
55
+ with pytest.raises(RealmInvalid):
56
+ MyPyllantAPI("test@example.com", "test", "sdbg", "germany")
57
+
58
+
59
+ async def test_login_country_missing(mypyllant_aioresponses) -> None:
60
+ with pytest.raises(RealmInvalid):
61
+ MyPyllantAPI("test@example.com", "test", "sdbg")
62
+
63
+
43
64
  async def test_refresh_token(mypyllant_aioresponses, mocked_api) -> None:
44
65
  with mypyllant_aioresponses() as _:
45
66
  with freeze_time(datetime.now() + timedelta(hours=1)):
@@ -18,11 +18,17 @@ def _mypyllant_aioresponses():
18
18
 
19
19
  # auth endpoints
20
20
  self.get(
21
- re.compile(r".*openid-connect/auth\?"),
21
+ re.compile(r".*vaillant-germany-b2c/protocol/openid-connect/auth\?"),
22
22
  body=f"{LOGIN_URL.format(realm=get_realm('vaillant', 'germany'))}?test=test",
23
23
  status=200,
24
24
  repeat=True,
25
25
  )
26
+ self.get(
27
+ re.compile(r".*bulex-b2c/protocol/openid-connect/auth\?"),
28
+ body=f"{LOGIN_URL.format(realm=get_realm('bulex'))}?test=test",
29
+ status=200,
30
+ repeat=True,
31
+ )
26
32
  self.post(
27
33
  re.compile(r".*login-actions/authenticate\?"),
28
34
  status=200,
@@ -60,12 +60,14 @@ def datetime_parse(date_string: str) -> datetime:
60
60
  return datetime.strptime(date_string, "%Y-%m-%dT%H:%M:%SZ")
61
61
 
62
62
 
63
- def get_realm(brand: str, country: str) -> str:
63
+ def get_realm(brand: str, country: str | None = None) -> str:
64
64
  """
65
65
  Vaillant and SDBG use `brand-country-b2c` as the realm, Bulex doesn't use a country
66
66
  """
67
67
  if brand == "bulex":
68
68
  return f"{brand}-b2c"
69
+ elif not country:
70
+ return f"{brand}-b2c"
69
71
  else:
70
72
  return f"{brand}-{country}-b2c"
71
73
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes