From 9499f2e6eed55db6e054dfb46236c09b999e48e8 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Wed, 25 Mar 2020 11:08:10 +0000 Subject: [PATCH] Correct linting errors and tests --- mopidy_raspberry_gpio/pinconfig.py | 11 +++++++---- tests/test_config.py | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/mopidy_raspberry_gpio/pinconfig.py b/mopidy_raspberry_gpio/pinconfig.py index 112e50b..e55a152 100644 --- a/mopidy_raspberry_gpio/pinconfig.py +++ b/mopidy_raspberry_gpio/pinconfig.py @@ -12,7 +12,9 @@ class ValidList(list): class PinConfig(config.ConfigValue): - tuple_pinconfig = namedtuple("PinConfig", ("event", "active", "bouncetime", "options")) + tuple_pinconfig = namedtuple( + "PinConfig", ("event", "active", "bouncetime", "options") + ) valid_events = ValidList( ["play_pause", "prev", "next", "volume_up", "volume_down"] @@ -31,7 +33,8 @@ class PinConfig(config.ConfigValue): value = value.split(",") - if len(value) < 3: # At least Event, Active and Bouncetime settings required + # At least Event, Active and Bouncetime settings required + if len(value) < 3: return None event, active, bouncetime = value[0:3] @@ -64,6 +67,6 @@ class PinConfig(config.ConfigValue): def serialize(self, value, display=False): if value is None: return "" - options = ",".join({f'{k}={v}' for k, v in value.options.items()}) - value = f"{value.event},{value.active},{value.bouncetime}" + options = ",".join({f"{k}={v}" for k, v in value.options.items()}) + value = f"{value.event},{value.active},{value.bouncetime},{options}" return types.encode(value) diff --git a/tests/test_config.py b/tests/test_config.py index 0eb966d..5a61ee3 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -76,4 +76,4 @@ def test_pinconfig_serialize(): schema = ext.get_config_schema() bcm1 = schema["bcm1"].deserialize("volume_up,active_low,30,steps=1") - assert bcm1.serialize() == "volume_up,active_low,30,steps=1" + assert schema["bcm1"].serialize(bcm1) == "volume_up,active_low,30,steps=1"