craftbeerpi4-pione/tests/test_config.py

38 lines
1.1 KiB
Python
Raw Normal View History

2018-12-29 00:27:19 +01:00
import time
from aiohttp.test_utils import unittest_run_loop
from tests.cbpi_config_fixture import CraftBeerPiTestCase
2018-12-29 00:27:19 +01:00
class ConfigTestCase(CraftBeerPiTestCase):
2018-12-29 00:27:19 +01:00
@unittest_run_loop
async def test_get(self):
assert self.cbpi.config.get("steps_boil_temp", 1) == "99"
2018-12-29 00:27:19 +01:00
@unittest_run_loop
async def test_set_get(self):
value = 35
2018-12-29 00:27:19 +01:00
await self.cbpi.config.set("steps_cooldown_temp", value)
assert self.cbpi.config.get("steps_cooldown_temp", 1) == value
2018-12-29 00:27:19 +01:00
@unittest_run_loop
async def test_http_set(self):
value = "Some New Brewery Name"
key = "BREWERY_NAME"
2018-12-29 00:27:19 +01:00
resp = await self.client.request("PUT", "/config/%s/" % key, json={'value': value})
2018-12-29 00:27:19 +01:00
assert resp.status == 204
assert self.cbpi.config.get(key, -1) == value
2018-12-29 00:27:19 +01:00
@unittest_run_loop
async def test_http_get(self):
resp = await self.client.request("GET", "/config/")
assert resp.status == 200
2019-01-02 00:48:36 +01:00
2019-01-02 21:20:44 +01:00
@unittest_run_loop
async def test_get_default(self):
value = self.cbpi.config.get("HELLO_WORLD", "DefaultValue")
assert value == "DefaultValue"