mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-09 17:07:43 +01:00
some fixes in tests and parameter for influxdb measurement name
This commit is contained in:
parent
10e603e81c
commit
2429ea63d1
10 changed files with 13 additions and 21 deletions
|
@ -1,3 +1,3 @@
|
|||
__version__ = "4.1.0.rc1"
|
||||
__version__ = "4.1.0.rc2"
|
||||
__codename__ = "Groundhog Day"
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@ class LogController:
|
|||
self.influxdbname = self.cbpi.config.get("INFLUXDBNAME", None)
|
||||
self.influxdbuser = self.cbpi.config.get("INFLUXDBUSER", None)
|
||||
self.influxdbpwd = self.cbpi.config.get("INFLUXDBPWD", None)
|
||||
self.influxdbmeasurement = self.cbpi.config.get("INFLUXDBMEASUREMENT", "measurement")
|
||||
|
||||
id = name
|
||||
try:
|
||||
|
@ -62,7 +63,7 @@ class LogController:
|
|||
itemname=sensor.name.replace(" ", "_")
|
||||
for char in chars:
|
||||
itemname = itemname.replace(char,chars[char])
|
||||
out="measurement,source=" + itemname + ",itemID=" + str(id) + " value="+str(value)
|
||||
out=str(self.influxdbmeasurement)+",source=" + itemname + ",itemID=" + str(id) + " value="+str(value)
|
||||
except Exception as e:
|
||||
logging.error("InfluxDB ID Error: {}".format(e))
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ class ConfigUpdate(CBPiExtension):
|
|||
influxdbuser = self.cbpi.config.get("INFLUXDBUSER", None)
|
||||
influxdbpwd = self.cbpi.config.get("INFLUXDBPWD", None)
|
||||
influxdbcloud = self.cbpi.config.get("INFLUXDBCLOUD", None)
|
||||
influxdbmeasurement = self.cbpi.config.get("INFLUXDBMEASUREMENT", None)
|
||||
mqttupdate = self.cbpi.config.get("MQTTUpdate", None)
|
||||
PRESSURE_UNIT = self.cbpi.config.get("PRESSURE_UNIT", None)
|
||||
SENSOR_LOG_BACKUP_COUNT = self.cbpi.config.get("SENSOR_LOG_BACKUP_COUNT", None)
|
||||
|
@ -267,6 +268,14 @@ class ConfigUpdate(CBPiExtension):
|
|||
except:
|
||||
logger.warning('Unable to update config')
|
||||
|
||||
## Check if influxdbname is in config
|
||||
if influxdbmeasurement is None:
|
||||
logger.info("INIT Influxdb measurementname")
|
||||
try:
|
||||
await self.cbpi.config.add("INFLUXDBMEASUREMENT", "measurement", ConfigType.STRING, "Name of the measurement in your INFLUXDB database (default: measurement)")
|
||||
except:
|
||||
logger.warning('Unable to update config')
|
||||
|
||||
if mqttupdate is None:
|
||||
logger.info("INIT MQTT update frequency for Kettles and Fermenters")
|
||||
try:
|
||||
|
|
|
@ -8,7 +8,6 @@ logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(
|
|||
|
||||
class ActorTestCase(CraftBeerPiTestCase):
|
||||
|
||||
@unittest_run_loop
|
||||
async def test_actor_switch(self):
|
||||
|
||||
resp = await self.client.post(path="/login", data={"username": "cbpi", "password": "123"})
|
||||
|
@ -25,7 +24,6 @@ class ActorTestCase(CraftBeerPiTestCase):
|
|||
i = self.cbpi.actor.find_by_id("3CUJte4bkxDMFCtLX8eqsX")
|
||||
assert i.instance.state is False
|
||||
|
||||
@unittest_run_loop
|
||||
async def test_crud(self):
|
||||
data = {
|
||||
"name": "SomeActor",
|
||||
|
@ -63,7 +61,6 @@ class ActorTestCase(CraftBeerPiTestCase):
|
|||
resp = await self.client.delete(path="/actor/%s" % sensor_id)
|
||||
assert resp.status == 204
|
||||
|
||||
@unittest_run_loop
|
||||
async def test_crud_negative(self):
|
||||
data = {
|
||||
"name": "CustomActor",
|
||||
|
@ -81,7 +78,6 @@ class ActorTestCase(CraftBeerPiTestCase):
|
|||
resp = await self.client.put(path="/actor/%s" % 9999, json=data)
|
||||
assert resp.status == 500
|
||||
|
||||
@unittest_run_loop
|
||||
async def test_actor_action(self):
|
||||
resp = await self.client.post(path="/actor/1/action", json=dict(name="myAction", parameter=dict(name="Manuel")))
|
||||
assert resp.status == 204
|
||||
|
|
|
@ -5,19 +5,16 @@ from tests.cbpi_config_fixture import CraftBeerPiTestCase
|
|||
|
||||
class ConfigTestCase(CraftBeerPiTestCase):
|
||||
|
||||
@unittest_run_loop
|
||||
async def test_get(self):
|
||||
|
||||
assert self.cbpi.config.get("steps_boil_temp", 1) == "99"
|
||||
|
||||
@unittest_run_loop
|
||||
async def test_set_get(self):
|
||||
value = 35
|
||||
|
||||
await self.cbpi.config.set("steps_cooldown_temp", value)
|
||||
assert self.cbpi.config.get("steps_cooldown_temp", 1) == value
|
||||
|
||||
@unittest_run_loop
|
||||
async def test_http_set(self):
|
||||
value = "Some New Brewery Name"
|
||||
key = "BREWERY_NAME"
|
||||
|
@ -27,12 +24,10 @@ class ConfigTestCase(CraftBeerPiTestCase):
|
|||
|
||||
assert self.cbpi.config.get(key, -1) == value
|
||||
|
||||
@unittest_run_loop
|
||||
async def test_http_get(self):
|
||||
resp = await self.client.request("GET", "/config/")
|
||||
assert resp.status == 200
|
||||
|
||||
@unittest_run_loop
|
||||
async def test_get_default(self):
|
||||
value = self.cbpi.config.get("HELLO_WORLD", "DefaultValue")
|
||||
assert value == "DefaultValue"
|
|
@ -6,7 +6,6 @@ from cbpi.craftbeerpi import CraftBeerPi
|
|||
|
||||
class DashboardTestCase(CraftBeerPiTestCase):
|
||||
|
||||
@unittest_run_loop
|
||||
async def test_crud(self):
|
||||
data = {
|
||||
"name": "MyDashboard",
|
||||
|
|
|
@ -4,7 +4,6 @@ from tests.cbpi_config_fixture import CraftBeerPiTestCase
|
|||
|
||||
class IndexTestCase(CraftBeerPiTestCase):
|
||||
|
||||
@unittest_run_loop
|
||||
async def test_index(self):
|
||||
|
||||
|
||||
|
@ -12,19 +11,16 @@ class IndexTestCase(CraftBeerPiTestCase):
|
|||
resp = await self.client.get(path="/")
|
||||
assert resp.status == 200
|
||||
|
||||
@unittest_run_loop
|
||||
async def test_404(self):
|
||||
# Test Index Page
|
||||
resp = await self.client.get(path="/abc")
|
||||
assert resp.status == 500
|
||||
|
||||
@unittest_run_loop
|
||||
async def test_wrong_login(self):
|
||||
resp = await self.client.post(path="/login", data={"username": "beer", "password": "123"})
|
||||
print("REPONSE STATUS", resp.status)
|
||||
assert resp.status == 403
|
||||
|
||||
@unittest_run_loop
|
||||
async def test_login(self):
|
||||
|
||||
resp = await self.client.post(path="/login", data={"username": "cbpi", "password": "123"})
|
||||
|
|
|
@ -4,15 +4,13 @@ from tests.cbpi_config_fixture import CraftBeerPiTestCase
|
|||
|
||||
class KettleTestCase(CraftBeerPiTestCase):
|
||||
|
||||
@unittest_run_loop
|
||||
async def test_get(self):
|
||||
|
||||
resp = await self.client.request("GET", "/kettle")
|
||||
assert resp.status == 200
|
||||
kettle = resp.json()
|
||||
kettle = await resp.json()
|
||||
assert kettle != None
|
||||
|
||||
@unittest_run_loop
|
||||
async def test_crud(self):
|
||||
data = {
|
||||
"name": "Test",
|
||||
|
|
|
@ -7,7 +7,6 @@ import os
|
|||
|
||||
class LoggerTestCase(CraftBeerPiTestCase):
|
||||
|
||||
@unittest_run_loop
|
||||
async def test_log_data(self):
|
||||
|
||||
os.makedirs(os.path.join(".", "tests", "logs"), exist_ok=True)
|
||||
|
|
|
@ -4,6 +4,5 @@ from tests.cbpi_config_fixture import CraftBeerPiTestCase
|
|||
|
||||
class NotificationTestCase(CraftBeerPiTestCase):
|
||||
|
||||
@unittest_run_loop
|
||||
async def test_actor_switch(self):
|
||||
self.cbpi.notify("test", "test")
|
Loading…
Reference in a new issue