craftbeerpi4-pione/tests/test_kettle.py

52 lines
1.3 KiB
Python
Raw Normal View History

from aiohttp.test_utils import unittest_run_loop
from tests.cbpi_config_fixture import CraftBeerPiTestCase
2018-11-18 15:40:10 +01:00
class KettleTestCase(CraftBeerPiTestCase):
2018-11-18 15:40:10 +01:00
2019-01-01 15:35:35 +01:00
async def test_get(self):
resp = await self.client.request("GET", "/kettle")
assert resp.status == 200
kettle = await resp.json()
assert kettle != None
2019-01-02 21:20:44 +01:00
2019-01-02 00:48:36 +01:00
async def test_crud(self):
2019-01-01 15:35:35 +01:00
data = {
"name": "Test",
"sensor": None,
"heater": "1",
"automatic": None,
"logic": "CustomKettleLogic",
"config": {
"test": "WOOHO"
},
"agitator": None,
"target_temp": None
}
2019-01-02 00:48:36 +01:00
# Add new sensor
2019-01-01 15:35:35 +01:00
resp = await self.client.post(path="/kettle/", json=data)
assert resp.status == 200
2018-12-13 21:45:33 +01:00
2019-01-02 00:48:36 +01:00
m = await resp.json()
2018-12-03 22:16:03 +01:00
kettle_id = m["id"]
2019-07-27 21:08:19 +02:00
print("KETTLE", m["id"], m)
# Update Kettle
resp = await self.client.put(path="/kettle/%s" % kettle_id, json=m)
2019-01-02 00:48:36 +01:00
assert resp.status == 200
# Set Kettle target temp
resp = await self.client.post(path="/kettle/%s/target_temp" % kettle_id, json={"temp":75})
assert resp.status == 204
2018-12-03 22:16:03 +01:00
2019-01-02 00:48:36 +01:00
# # Delete Sensor
resp = await self.client.delete(path="/kettle/%s" % kettle_id)
2019-01-02 00:48:36 +01:00
assert resp.status == 204
2018-12-03 22:16:03 +01:00