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