aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordu erpei <duep.fnst@fujitsu.com>2021-08-04 11:51:56 +0800
committerEdi Feschiyan <edi.feschiyan@konsulko.com>2021-08-20 11:38:29 +0000
commitec4011fb7514d6ca9abe03f937a729089dc24fe2 (patch)
tree689ff7aa7b58a05b0bae31234be68dc4f0044db6
parent1fbb7518d5e295bf10e78b11e4dcea77ffad6267 (diff)
Add testcase of get api to hvac service module.
Bug-AGL: SPEC-4043 Signed-off-by: du erpei <duep.fnst@fujitsu.com> Change-Id: I1fd89f020d6f9456a70b676428f40ef4764478d7
-rw-r--r--pyagl/tests/test_hvac.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/pyagl/tests/test_hvac.py b/pyagl/tests/test_hvac.py
index b265819..0c4d1c6 100644
--- a/pyagl/tests/test_hvac.py
+++ b/pyagl/tests/test_hvac.py
@@ -72,3 +72,35 @@ async def test_set(event_loop, service: hvs):
resp = await service.afbresponse()
assert resp.status == 'success'
+async def test_set_bad_request(event_loop, service: hvs):
+ msgid = await service.set({'FanSpeed': -1})
+ resp = await service.afbresponse()
+ assert resp.status == 'bad-request'
+
+ msgid = await service.set({'FanSpeed': 256})
+ resp = await service.afbresponse()
+ assert resp.status == 'bad-request'
+
+ msgid = await service.set({'FanSpeed': 'aa'})
+ resp = await service.afbresponse()
+ assert resp.status == 'bad-request'
+
+async def test_set_success(event_loop, service: hvs):
+ msgid = await service.set({'FanSpeed': 255})
+ resp = await service.afbresponse()
+ assert resp.status == 'success'
+
+ msgid = await service.get_fanspeed()
+ resp = await service.afbresponse()
+ assert resp.status == 'success'
+ assert resp.data == {'FanSpeed': 255}
+
+ msgid = await service.set({'FanSpeed': 0})
+ resp = await service.afbresponse()
+ assert resp.status == 'success'
+
+ msgid = await service.get_fanspeed()
+ resp = await service.afbresponse()
+ assert resp.status == 'success'
+ assert resp.data == {'FanSpeed': 0}
+