Skip to content
Snippets Groups Projects
Commit a512b7f5 authored by Ellis Percival's avatar Ellis Percival
Browse files

Fix tests/flake8. Remove unused requirement.

parent a7fe9c3f
Branches
Tags
No related merge requests found
......@@ -123,8 +123,7 @@ def set_pin(output_config, value):
output_config["module"],
output_config["name"],
value)
payload = output_config["on_payload"] if value \
else output_config["off_payload"]
payload = output_config["on_payload" if value else "off_payload"]
client.publish(
"%s/%s/%s" % (topic_prefix, OUTPUT_TOPIC, output_config["name"]),
payload=payload)
......@@ -155,7 +154,6 @@ def handle_set_ms(msg, value):
output_config = output_by_name(output_name)
if output_config is None:
return
payload = output_config["on_payload" if value else "off_payload"]
gpio = GPIO_MODULES[output_config["module"]]
previous_value = gpio.get_pin(output_config["pin"])
set_pin(output_config, value)
......@@ -302,7 +300,8 @@ def init_mqtt(config, digital_outputs):
:rtype: NoneType
"""
try:
_LOG.info("Received message on topic %r: %r", msg.topic, msg.payload)
_LOG.info(
"Received message on topic %r: %r", msg.topic, msg.payload)
if msg.topic.endswith("/%s" % SET_TOPIC):
handle_set(msg)
elif msg.topic.endswith("/%s" % SET_ON_MS_TOPIC):
......
......@@ -2,5 +2,4 @@ paho-mqtt
PyYAML
enum34
cerberus
apscheduler
......@@ -57,7 +57,8 @@ def test_onfts_no_set():
Should raise a ValueError when there's no /set at the end of the topic.
"""
with pytest.raises(ValueError):
server.output_name_from_topic_set("myprefix/output/myoutputname", "myprefix")
server.output_name_from_topic(
"myprefix/output/myoutputname", "myprefix", "set")
def test_onfts_returns_output_name():
......@@ -65,8 +66,9 @@ def test_onfts_returns_output_name():
Should return the proper output name.
"""
output_name = "myoutputname"
ret = server.output_name_from_topic_set(
ret = server.output_name_from_topic(
"myprefix/output/%s/%s" % (output_name, server.SET_TOPIC),
"myprefix"
"myprefix",
"set"
)
assert ret == output_name
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment