summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordu erpei <duep.fnst@fujitsu.com>2021-08-04 11:51:56 +0800
committerJan-Simon Möller <jsmoeller@linuxfoundation.org>2021-11-03 15:11:21 +0100
commita563777f941cec6c69c221e05a6aebc3e6b2a663 (patch)
tree5bd9e62a5797b43f70b4b12dc5918860d374db6c
parent31dd870fd8706512cfb21dffab3d0557702cb877 (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}
+