aboutsummaryrefslogtreecommitdiffstats
path: root/pyagl/tests/test_hvac.py
diff options
context:
space:
mode:
authorEdi Feschiyan <edi.feschiyan@konsulko.com>2020-10-22 12:57:43 +0300
committerScott Murray <scott.murray@konsulko.com>2020-12-03 15:54:32 +0000
commitdcc2f91e5ab3b70202e78ec7164a8e9d7501d70c (patch)
tree6a70bc59cd1c8073e6add49ab55755405068811f /pyagl/tests/test_hvac.py
parent5aed9a32ea71737709a11590d6ecc92f773f85d6 (diff)
Add HVAC bindings and testskoi_10.91.0koi/10.91.010.91.0
The current implementation of agl-service-hvac does not have test widgets implemented as reference point so these tests are new. Writing to verbs related to changing LED brightness results in I2C errors and therefore the tests are marked as hwrequired and xfail, as no hardware demo units are available to test with. The markers will stay until it is decided whether it is enough for testing or mock tests should be implemented. Bug-AGL: SPEC-3660 Signed-off-by: Edi Feschiyan <edi.feschiyan@konsulko.com> Change-Id: Ibc051c6b4a06e0d126be9f8a0e0efe5876244671
Diffstat (limited to 'pyagl/tests/test_hvac.py')
-rw-r--r--pyagl/tests/test_hvac.py74
1 files changed, 74 insertions, 0 deletions
diff --git a/pyagl/tests/test_hvac.py b/pyagl/tests/test_hvac.py
new file mode 100644
index 0000000..b265819
--- /dev/null
+++ b/pyagl/tests/test_hvac.py
@@ -0,0 +1,74 @@
+import asyncio
+import os
+import pytest
+import logging
+from pyagl.services.base import AFBResponse, AFBT
+
+from pyagl.services.hvac import HVACService as hvs
+pytestmark = [pytest.mark.asyncio, pytest.mark.hvac]
+
+
+@pytest.fixture(scope='module')
+def event_loop():
+ loop = asyncio.get_event_loop()
+ yield loop
+
+
+@pytest.fixture(scope='module')
+async def service():
+ address = os.environ.get('AGL_TGT_IP', 'localhost')
+ port = os.environ.get('AGL_TGT_PORT', None)
+ svc = await hvs(ip=address, port=port)
+ yield svc
+ await svc.websocket.close()
+
+
+async def test_get_temp_left_zone(event_loop, service: hvs):
+ msgid = await service.get_temp_left_zone()
+ resp = await service.afbresponse()
+ assert resp.status == 'success'
+ assert 'LeftTemperature' in resp.data
+
+
+async def test_get_temp_right_zone(event_loop, service: hvs):
+ msgid = await service.get_temp_right_zone()
+ resp = await service.afbresponse()
+ assert resp.status == 'success'
+ assert 'RightTemperature' in resp.data
+
+
+async def test_get_fanspeed(event_loop, service: hvs):
+ msgid = await service.get_fanspeed()
+ resp = await service.afbresponse()
+ assert resp.status == 'success'
+ assert 'FanSpeed' in resp.data
+
+
+@pytest.mark.hwrequired
+@pytest.mark.xfail(reason='This fails with I2C error due to missing /sys/class/leds/blinkm-3-9-[red,blue,green]')
+async def test_temp_left_zone_led(event_loop, service: hvs):
+ msgid = await service.temp_left_zone_led()
+ resp = await service.afbresponse()
+ assert resp.status == 'success', resp.info
+
+
+@pytest.mark.hwrequired
+@pytest.mark.xfail(reason='This fails with I2C error due to missing /sys/class/leds/blinkm-3-9-[red,blue,green]')
+async def test_temp_right_zone_led(event_loop, service: hvs):
+ msgid = await service.temp_right_zone_led()
+ resp = await service.afbresponse()
+ assert resp.status == 'success', resp.info
+
+
+async def test_get(event_loop, service: hvs):
+ msgid = await service.get()
+ resp = await service.afbresponse()
+ for property in ['FanSpeed', 'LeftTemperature', 'RightTemperature']:
+ assert property in resp.data
+
+
+async def test_set(event_loop, service: hvs):
+ msgid = await service.set({'FanSpeed': 15})
+ resp = await service.afbresponse()
+ assert resp.status == 'success'
+