pytouchlinesl 0.6.0__tar.gz → 0.6.2__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 (22) hide show
  1. {pytouchlinesl-0.6.0/pytouchlinesl.egg-info → pytouchlinesl-0.6.2}/PKG-INFO +3 -1
  2. {pytouchlinesl-0.6.0 → pytouchlinesl-0.6.2}/README.md +2 -0
  3. {pytouchlinesl-0.6.0 → pytouchlinesl-0.6.2}/pyproject.toml +1 -1
  4. {pytouchlinesl-0.6.0 → pytouchlinesl-0.6.2}/pytouchlinesl/client/models/models.py +9 -1
  5. {pytouchlinesl-0.6.0 → pytouchlinesl-0.6.2/pytouchlinesl.egg-info}/PKG-INFO +3 -1
  6. {pytouchlinesl-0.6.0 → pytouchlinesl-0.6.2}/tests/test_module.py +22 -1
  7. {pytouchlinesl-0.6.0 → pytouchlinesl-0.6.2}/LICENSE +0 -0
  8. {pytouchlinesl-0.6.0 → pytouchlinesl-0.6.2}/pytouchlinesl/__init__.py +0 -0
  9. {pytouchlinesl-0.6.0 → pytouchlinesl-0.6.2}/pytouchlinesl/client/__init__.py +0 -0
  10. {pytouchlinesl-0.6.0 → pytouchlinesl-0.6.2}/pytouchlinesl/client/base.py +0 -0
  11. {pytouchlinesl-0.6.0 → pytouchlinesl-0.6.2}/pytouchlinesl/client/client.py +0 -0
  12. {pytouchlinesl-0.6.0 → pytouchlinesl-0.6.2}/pytouchlinesl/client/models/__init__.py +0 -0
  13. {pytouchlinesl-0.6.0 → pytouchlinesl-0.6.2}/pytouchlinesl/module.py +0 -0
  14. {pytouchlinesl-0.6.0 → pytouchlinesl-0.6.2}/pytouchlinesl/touchlinesl.py +0 -0
  15. {pytouchlinesl-0.6.0 → pytouchlinesl-0.6.2}/pytouchlinesl/zone.py +0 -0
  16. {pytouchlinesl-0.6.0 → pytouchlinesl-0.6.2}/pytouchlinesl.egg-info/SOURCES.txt +0 -0
  17. {pytouchlinesl-0.6.0 → pytouchlinesl-0.6.2}/pytouchlinesl.egg-info/dependency_links.txt +0 -0
  18. {pytouchlinesl-0.6.0 → pytouchlinesl-0.6.2}/pytouchlinesl.egg-info/requires.txt +0 -0
  19. {pytouchlinesl-0.6.0 → pytouchlinesl-0.6.2}/pytouchlinesl.egg-info/top_level.txt +0 -0
  20. {pytouchlinesl-0.6.0 → pytouchlinesl-0.6.2}/setup.cfg +0 -0
  21. {pytouchlinesl-0.6.0 → pytouchlinesl-0.6.2}/tests/test_touchlinesl.py +0 -0
  22. {pytouchlinesl-0.6.0 → pytouchlinesl-0.6.2}/tests/test_zone.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytouchlinesl
3
- Version: 0.6.0
3
+ Version: 0.6.2
4
4
  Summary: An API client for Roth's TouchlineSL control system.
5
5
  Author-email: Jon Seager <jon@sgrs.uk>
6
6
  Project-URL: Homepage, https://github.com/jnsgruk/pytouchlinesl
@@ -69,6 +69,7 @@ import os
69
69
 
70
70
  from pytouchlinesl import TouchlineSL
71
71
 
72
+
72
73
  async def touchlinesl_example():
73
74
  tsl = TouchlineSL(
74
75
  username=os.getenv("TOUCHLINESL_LOGIN"),
@@ -88,6 +89,7 @@ async def touchlinesl_example():
88
89
  living_spaces = await module.schedule_by_name("Living Spaces")
89
90
  await kitchen.set_schedule(living_spaces.id)
90
91
 
92
+
91
93
  if __name__ == "__main__":
92
94
  asyncio.set_event_loop(asyncio.new_event_loop())
93
95
  asyncio.run(touchlinesl_example())
@@ -48,6 +48,7 @@ import os
48
48
 
49
49
  from pytouchlinesl import TouchlineSL
50
50
 
51
+
51
52
  async def touchlinesl_example():
52
53
  tsl = TouchlineSL(
53
54
  username=os.getenv("TOUCHLINESL_LOGIN"),
@@ -67,6 +68,7 @@ async def touchlinesl_example():
67
68
  living_spaces = await module.schedule_by_name("Living Spaces")
68
69
  await kitchen.set_schedule(living_spaces.id)
69
70
 
71
+
70
72
  if __name__ == "__main__":
71
73
  asyncio.set_event_loop(asyncio.new_event_loop())
72
74
  asyncio.run(touchlinesl_example())
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pytouchlinesl"
3
- version = "0.6.0"
3
+ version = "0.6.2"
4
4
  authors = [{ name = "Jon Seager", email = "jon@sgrs.uk" }]
5
5
  description = "An API client for Roth's TouchlineSL control system."
6
6
  readme = "README.md"
@@ -6,7 +6,7 @@ tweaks to types and names.
6
6
 
7
7
  from typing import Any, Dict, List, Literal, Optional, Union
8
8
 
9
- from pydantic import BaseModel, Field
9
+ from pydantic import BaseModel, Field, field_validator
10
10
 
11
11
 
12
12
  class ZoneFlagsModel(BaseModel):
@@ -124,6 +124,14 @@ class ZonesModel(BaseModel):
124
124
  global_schedules: GlobalSchedulesModel = Field(..., alias="globalSchedules")
125
125
  controller_parameters: ControllerParametersModel = Field(..., alias="controllerParameters")
126
126
 
127
+ @field_validator("elements", mode="before")
128
+ @classmethod
129
+ def remove_null_elements(cls, value: Any) -> Any:
130
+ """Drop null placeholders from the Roth API's zone list."""
131
+ if isinstance(value, list):
132
+ return [zone for zone in value if zone is not None]
133
+ return value
134
+
127
135
 
128
136
  class ParamsModel(BaseModel):
129
137
  description: Optional[str] = None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytouchlinesl
3
- Version: 0.6.0
3
+ Version: 0.6.2
4
4
  Summary: An API client for Roth's TouchlineSL control system.
5
5
  Author-email: Jon Seager <jon@sgrs.uk>
6
6
  Project-URL: Homepage, https://github.com/jnsgruk/pytouchlinesl
@@ -69,6 +69,7 @@ import os
69
69
 
70
70
  from pytouchlinesl import TouchlineSL
71
71
 
72
+
72
73
  async def touchlinesl_example():
73
74
  tsl = TouchlineSL(
74
75
  username=os.getenv("TOUCHLINESL_LOGIN"),
@@ -88,6 +89,7 @@ async def touchlinesl_example():
88
89
  living_spaces = await module.schedule_by_name("Living Spaces")
89
90
  await kitchen.set_schedule(living_spaces.id)
90
91
 
92
+
91
93
  if __name__ == "__main__":
92
94
  asyncio.set_event_loop(asyncio.new_event_loop())
93
95
  asyncio.run(touchlinesl_example())
@@ -1,10 +1,31 @@
1
1
  import asyncio
2
+ import json
2
3
 
3
4
  import pytest
5
+ from pydantic import ValidationError
4
6
 
5
- from pytouchlinesl.client.models import GlobalScheduleModel
7
+ from pytouchlinesl.client.models import GlobalScheduleModel, ModuleModel
6
8
  from pytouchlinesl.zone import Zone
7
9
 
10
+ from .fake_client import data_dir
11
+
12
+
13
+ def test_module_response_with_null_zone():
14
+ payload = json.loads((data_dir / "module.json").read_text())
15
+ expected_zones = ModuleModel.model_validate(payload).zones.elements
16
+ payload["zones"]["elements"].insert(1, None)
17
+
18
+ assert ModuleModel.model_validate(payload).zones.elements == expected_zones
19
+
20
+
21
+ @pytest.mark.parametrize("elements", [None, {}, [False]])
22
+ def test_module_response_with_invalid_zones(elements):
23
+ payload = json.loads((data_dir / "module.json").read_text())
24
+ payload["zones"]["elements"] = elements
25
+
26
+ with pytest.raises(ValidationError, match=r"zones\.elements"):
27
+ ModuleModel.model_validate(payload)
28
+
8
29
 
9
30
  @pytest.mark.asyncio
10
31
  async def test_zones(test_module):
File without changes
File without changes