diff --git a/aiolyric/__init__.py b/aiolyric/__init__.py index 1425571..7a8d6d3 100644 --- a/aiolyric/__init__.py +++ b/aiolyric/__init__.py @@ -25,7 +25,7 @@ def __init__( self._devices_dict: dict = {} self._locations: List[LyricLocation] = [] self._locations_dict: dict = {} - self._rooms_dict: dict = {} + self._rooms_dict: dict = {} @property def client_id(self) -> str: @@ -91,12 +91,12 @@ async def get_thermostat_rooms( ) json = await response.json() self.logger.debug(json) - + priority = LyricPriority(json) macId = priority.deviceId # device id in the priority payload refers to the mac address of the device self._rooms_dict[macId]: dict = {} - + # add each room to the room dictionary. Rooms contain motion, temp, and humidity averages for all accessories in a room for room in priority.currentPriority.rooms: self._rooms_dict[macId][room.id] = room diff --git a/aiolyric/client/__init__.py b/aiolyric/client/__init__.py index 39cb8e8..a1618cd 100644 --- a/aiolyric/client/__init__.py +++ b/aiolyric/client/__init__.py @@ -1,13 +1,13 @@ """Lyric: Client""" -import async_timeout -import logging - from abc import abstractmethod from asyncio import CancelledError, TimeoutError, get_event_loop -from aiohttp import ClientError, ClientSession, ClientResponse +import logging + +from aiohttp import ClientError, ClientResponse, ClientSession +import async_timeout +from ..exceptions import LyricAuthenticationException, LyricException from ..objects.base import LyricBase -from ..exceptions import LyricException, LyricAuthenticationException class LyricClient(LyricBase): diff --git a/aiolyric/objects/__init__.py b/aiolyric/objects/__init__.py index b10702a..1a548ba 100644 --- a/aiolyric/objects/__init__.py +++ b/aiolyric/objects/__init__.py @@ -1 +1 @@ -"""Lyric: Objects""" \ No newline at end of file +"""Lyric: Objects""" diff --git a/aiolyric/objects/base.py b/aiolyric/objects/base.py index dc9e7ea..dacb0da 100644 --- a/aiolyric/objects/base.py +++ b/aiolyric/objects/base.py @@ -18,4 +18,4 @@ class LyricBaseClient(LyricBase): def __init__(self, client: "AIOGitHubAPIClient", attributes: dict) -> None: """Initialise.""" super().__init__(attributes) - self.client = client \ No newline at end of file + self.client = client diff --git a/aiolyric/objects/device.py b/aiolyric/objects/device.py index 72bbfff..05a4545 100644 --- a/aiolyric/objects/device.py +++ b/aiolyric/objects/device.py @@ -1,5 +1,4 @@ -""" -Class object for LyricDevice +"""Class object for LyricDevice Documentation: https://github.com/timmo001/aiolyric Generated by generator/generator.py - 2020-08-31 14:06:02.854691 @@ -68,7 +67,7 @@ class SettingsFan(LyricBase): @property def fan(self): return self.atributes.get("fan", {}) - + class Settings(LyricBase): @property @@ -94,7 +93,7 @@ def fanModes(self): @property def fanChangeableValues(self): return SettingsFan(self.attributes.get("changeableValues", {})) - + @property def fanMode(self): return fanChangeableValues(self.attributes.get("mode", None)) @@ -172,7 +171,7 @@ def locationID(self): @property def indoorHumidity(self): return self.attributes.get("indoorHumidity", None) - + @property def displayedOutdoorHumidity(self): return self.attributes.get("displayedOutdoorHumidity", None) diff --git a/aiolyric/objects/location.py b/aiolyric/objects/location.py index 0dd0b2d..78c4afc 100644 --- a/aiolyric/objects/location.py +++ b/aiolyric/objects/location.py @@ -1,10 +1,10 @@ -""" -Class object for LyricLocation +"""Class object for LyricLocation Documentation: https://github.com/timmo001/aiolyric Generated by generator/generator.py - 2020-08-31 13:55:49.220121 """ from typing import List + from .base import LyricBase, LyricBaseClient from .device import LyricDevice diff --git a/aiolyric/objects/priority.py b/aiolyric/objects/priority.py index fb74e39..62dbc45 100644 --- a/aiolyric/objects/priority.py +++ b/aiolyric/objects/priority.py @@ -1,5 +1,4 @@ -""" -Class object for LyricPriority +"""Class object for LyricPriority Documentation: https://github.com/timmo001/aiolyric Generated by generator/generator.py - 2023-07-27 18:30:29.139453 diff --git a/generator/generator.py b/generator/generator.py index 8ff5c7d..8814a8d 100644 --- a/generator/generator.py +++ b/generator/generator.py @@ -1,7 +1,7 @@ +from datetime import datetime import json -import re import os -from datetime import datetime +import re DATE = datetime.now() @@ -63,7 +63,7 @@ def {testname}({fixture}): def get_input(): - with open("generator/input.json", "r") as inputdata: + with open("generator/input.json") as inputdata: return json.loads(inputdata.read()) @@ -276,4 +276,4 @@ def add_object(): generateclass("", data, True) -add_object() \ No newline at end of file +add_object() diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..29676ab --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1,5 @@ +"""Setup for tests.""" + +from typing import Final + +RESPONSE_JSON_BASIC: Final[dict] = {"test": "test"} diff --git a/tests/objects/test_device.py b/tests/objects/test_device.py index 7526d4b..c3e409a 100644 --- a/tests/objects/test_device.py +++ b/tests/objects/test_device.py @@ -1,8 +1,6 @@ -""" -Generated by generator/generator.py - 2020-08-31 14:06:02.854691 +"""Generated by generator/generator.py - 2020-08-31 14:06:02.854691 """ from aiolyric.objects.device import LyricDevice -from tests.responses.device_fixture import device_fixture_response def test_device(device_fixture_response): diff --git a/tests/objects/test_location.py b/tests/objects/test_location.py index 9438f0c..7f3224a 100644 --- a/tests/objects/test_location.py +++ b/tests/objects/test_location.py @@ -1,8 +1,6 @@ -""" -Generated by generator/generator.py - 2020-08-31 13:55:49.220121 +"""Generated by generator/generator.py - 2020-08-31 13:55:49.220121 """ from aiolyric.objects.location import LyricLocation -from tests.responses.location_fixture import location_fixture_response def test_location(location_fixture_response): diff --git a/tests/objects/test_priority.py b/tests/objects/test_priority.py index a896c48..0a3ef49 100644 --- a/tests/objects/test_priority.py +++ b/tests/objects/test_priority.py @@ -1,18 +1,17 @@ -""" -Generated by generator/generator.py - 2023-07-27 18:30:29.139453 +"""Generated by generator/generator.py - 2023-07-27 18:30:29.139453 """ from aiolyric.objects.priority import LyricPriority -from tests.responses.priority_fixture import priority_fixture_response + def test_priority(priority_fixture_response): obj = LyricPriority(priority_fixture_response) - assert obj.deviceId == priority_fixture_response['deviceId'] - assert obj.status == priority_fixture_response['status'] - assert obj.currentPriority.priorityType == priority_fixture_response['currentPriority']['priorityType'] - assert obj.currentPriority.selectedRooms[0] == priority_fixture_response['currentPriority']['selectedRooms'][0] - assert obj.currentPriority.rooms[0].id == priority_fixture_response['currentPriority']['rooms'][0]['id'] - assert obj.currentPriority.rooms[0].roomName == priority_fixture_response['currentPriority']['rooms'][0]['roomName'] - assert obj.currentPriority.rooms[0].roomAvgTemp == priority_fixture_response['currentPriority']['rooms'][0]['roomAvgTemp'] - assert obj.currentPriority.rooms[0].roomAvgHumidity == priority_fixture_response['currentPriority']['rooms'][0]['roomAvgHumidity'] - assert obj.currentPriority.rooms[0].overallMotion == priority_fixture_response['currentPriority']['rooms'][0]['overallMotion'] - assert obj.currentPriority.rooms[0].accessories == priority_fixture_response['currentPriority']['rooms'][0]['accessories'] + assert obj.deviceId == priority_fixture_response["deviceId"] + assert obj.status == priority_fixture_response["status"] + assert obj.currentPriority.priorityType == priority_fixture_response["currentPriority"]["priorityType"] + assert obj.currentPriority.selectedRooms[0] == priority_fixture_response["currentPriority"]["selectedRooms"][0] + assert obj.currentPriority.rooms[0].id == priority_fixture_response["currentPriority"]["rooms"][0]["id"] + assert obj.currentPriority.rooms[0].roomName == priority_fixture_response["currentPriority"]["rooms"][0]["roomName"] + assert obj.currentPriority.rooms[0].roomAvgTemp == priority_fixture_response["currentPriority"]["rooms"][0]["roomAvgTemp"] + assert obj.currentPriority.rooms[0].roomAvgHumidity == priority_fixture_response["currentPriority"]["rooms"][0]["roomAvgHumidity"] + assert obj.currentPriority.rooms[0].overallMotion == priority_fixture_response["currentPriority"]["rooms"][0]["overallMotion"] + assert obj.currentPriority.rooms[0].accessories == priority_fixture_response["currentPriority"]["rooms"][0]["accessories"] diff --git a/tests/responses/device_fixture.py b/tests/responses/device_fixture.py index 80e9ec1..02819ae 100644 --- a/tests/responses/device_fixture.py +++ b/tests/responses/device_fixture.py @@ -1,5 +1,4 @@ -""" -Generated by generator/generator.py - 2020-08-31 14:06:02.854691 +"""Generated by generator/generator.py - 2020-08-31 14:06:02.854691 """ import pytest diff --git a/tests/responses/location_fixture.py b/tests/responses/location_fixture.py index d2d4754..3ead353 100644 --- a/tests/responses/location_fixture.py +++ b/tests/responses/location_fixture.py @@ -1,5 +1,4 @@ -""" -Generated by generator/generator.py - 2020-08-31 13:55:49.220121 +"""Generated by generator/generator.py - 2020-08-31 13:55:49.220121 """ import pytest diff --git a/tests/responses/priority_fixture.py b/tests/responses/priority_fixture.py index b7180dc..fbb883f 100644 --- a/tests/responses/priority_fixture.py +++ b/tests/responses/priority_fixture.py @@ -1,5 +1,4 @@ -""" -Generated by generator/generator.py - 2023-07-27 18:30:29.139453 +"""Generated by generator/generator.py - 2023-07-27 18:30:29.139453 """ import pytest @@ -7,65 +6,65 @@ @pytest.fixture() def priority_fixture_response(): return { - 'deviceId': '00A01AB1ABCD', - 'status': 'NoHold', - 'currentPriority': { - 'priorityType': 'PickARoom', - 'selectedRooms': [ + "deviceId": "00A01AB1ABCD", + "status": "NoHold", + "currentPriority": { + "priorityType": "PickARoom", + "selectedRooms": [ 0 - ], - 'rooms': [ + ], + "rooms": [ { - 'id': 0, - 'roomName': 'Hallway', - 'roomAvgTemp': 76, - 'roomAvgHumidity': 54, - 'overallMotion': False, - 'accessories': [ + "id": 0, + "roomName": "Hallway", + "roomAvgTemp": 76, + "roomAvgHumidity": 54, + "overallMotion": False, + "accessories": [ { - 'id': 0, - 'type': 'Thermostat', - 'excludeTemp': False, - 'excludeMotion': False, - 'temperature': 75.828, - 'status': 'Ok', - 'detectMotion': False + "id": 0, + "type": "Thermostat", + "excludeTemp": False, + "excludeMotion": False, + "temperature": 75.828, + "status": "Ok", + "detectMotion": False } ] - }, + }, { - 'id': 1, - 'roomName': 'Office', - 'roomAvgTemp': 76, - 'roomAvgHumidity': 52, - 'overallMotion': True, - 'accessories': [ + "id": 1, + "roomName": "Office", + "roomAvgTemp": 76, + "roomAvgHumidity": 52, + "overallMotion": True, + "accessories": [ { - 'id': 1, - 'type': 'IndoorAirSensor', - 'excludeTemp': False, - 'excludeMotion': False, - 'temperature': 76, - 'status': 'Ok', - 'detectMotion': True + "id": 1, + "type": "IndoorAirSensor", + "excludeTemp": False, + "excludeMotion": False, + "temperature": 76, + "status": "Ok", + "detectMotion": True } ] - }, + }, { - 'id': 2, - 'roomName': 'Master Bedroom', - 'roomAvgTemp': 76, - 'roomAvgHumidity': 52, - 'overallMotion': False, - 'accessories': [ + "id": 2, + "roomName": "Master Bedroom", + "roomAvgTemp": 76, + "roomAvgHumidity": 52, + "overallMotion": False, + "accessories": [ { - 'id': 2, - 'type': 'IndoorAirSensor', - 'excludeTemp': False, - 'excludeMotion': False, - 'temperature': 76, - 'status': 'Ok', - 'detectMotion': True + "id": 2, + "type": "IndoorAirSensor", + "excludeTemp": False, + "excludeMotion": False, + "temperature": 76, + "status": "Ok", + "detectMotion": True } ] }