craftbeerpi4-pione/tests/test_step.py
Philipp Grathwohl 652fbd74be Fix tests so they run again
Tests that can not work because of missing endpoints in the controllers
were removed. Also tests that have no clear intent and were failing were
deleted.
2022-03-31 08:06:46 +02:00

52 lines
No EOL
1.3 KiB
Python

import asyncio
from aiohttp.test_utils import unittest_run_loop
from tests.cbpi_config_fixture import CraftBeerPiTestCase
class StepTestCase(CraftBeerPiTestCase):
@unittest_run_loop
async def test_get(self):
resp = await self.client.request("GET", "/step2")
print(resp)
assert resp.status == 200
@unittest_run_loop
async def test_crud(self):
data = {
"name": "Test",
"type": "CustomStepCBPi",
"config": {}
}
# Add new step
resp = await self.client.post(path="/step2/", json=data)
assert resp.status == 200
m = await resp.json()
print("Step", m)
sensor_id = m["id"]
# Update step
resp = await self.client.put(path="/step2/%s" % sensor_id, json=m)
assert resp.status == 200
# # Delete step
resp = await self.client.delete(path="/step2/%s" % sensor_id)
assert resp.status == 204
def create_wait_callback(self, topic):
future = self.cbpi.app.loop.create_future()
async def test(**kwargs):
print("GOON")
future.set_result("OK")
self.cbpi.bus.register(topic, test, once=True)
return future
async def wait(self, future):
done, pending = await asyncio.wait({future})
if future in done:
pass