Skip to content

Commit

Permalink
Review: Black formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Marvin Wichmann committed Nov 28, 2020
1 parent 5e507a0 commit 0b32417
Show file tree
Hide file tree
Showing 20 changed files with 55 additions and 84 deletions.
4 changes: 2 additions & 2 deletions home-assistant-plugin/custom_components/xknx/__init__.py
Expand Up @@ -326,7 +326,7 @@ async def telegram_received_cb(self, telegram):
"knx_event",
{
"address": str(telegram.destination_address),
"data": telegram.payload.value
"data": telegram.payload.value,
},
)

Expand All @@ -349,7 +349,7 @@ def calculate_payload(attr_payload):

telegram = Telegram(
destination_address=GroupAddress(attr_address),
payload=calculate_payload(attr_payload)
payload=calculate_payload(attr_payload),
)
await self.xknx.telegrams.put(telegram)

Expand Down
12 changes: 4 additions & 8 deletions test/devices_tests/binary_sensor_test.py
Expand Up @@ -243,8 +243,7 @@ def test_process_callback(self):
switch.register_device_updated_cb(async_after_update_callback)

telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTBinary(1)
destination_address=GroupAddress("1/2/3"), payload=DPTBinary(1)
)
self.loop.run_until_complete(switch.process(telegram))
# no _context_task started because ignore_internal_state is False
Expand Down Expand Up @@ -272,8 +271,7 @@ def test_process_callback_ignore_internal_state(self):
switch.register_device_updated_cb(async_after_update_callback)

telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTBinary(1)
destination_address=GroupAddress("1/2/3"), payload=DPTBinary(1)
)
self.assertEqual(switch.counter, 0)

Expand Down Expand Up @@ -315,8 +313,7 @@ def test_process_callback_ignore_internal_state_no_counter(self):
switch.register_device_updated_cb(async_after_update_callback)

telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTBinary(1)
destination_address=GroupAddress("1/2/3"), payload=DPTBinary(1)
)
self.loop.run_until_complete(switch.process(telegram))
# no _context_task started because context_timeout is False
Expand All @@ -343,8 +340,7 @@ def test_process_group_value_response(self):
switch.register_device_updated_cb(async_after_update_callback)

write_telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTBinary(1)
destination_address=GroupAddress("1/2/3"), payload=DPTBinary(1)
)
response_telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
Expand Down
2 changes: 1 addition & 1 deletion test/devices_tests/datetime_test.py
Expand Up @@ -112,7 +112,7 @@ def test_process_read(self):

telegram_read = Telegram(
destination_address=GroupAddress("1/2/3"),
telegramtype=TelegramType.GROUP_READ
telegramtype=TelegramType.GROUP_READ,
)
with patch("time.localtime") as mock_time:
mock_time.return_value = time.struct_time([2017, 1, 7, 9, 13, 14, 6, 0, 0])
Expand Down
5 changes: 1 addition & 4 deletions test/devices_tests/sensor_test.py
Expand Up @@ -78,10 +78,7 @@ async def async_after_update_callback(device):
# set initial payload of sensor
sensor.sensor_value.payload = payload

telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=payload
)
telegram = Telegram(destination_address=GroupAddress("1/2/3"), payload=payload)
response_telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=payload,
Expand Down
3 changes: 1 addition & 2 deletions test/devices_tests/switch_test.py
Expand Up @@ -230,8 +230,7 @@ async def async_after_update_callback(device):
switch.register_device_updated_cb(async_after_update_callback)

telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTBinary(1)
destination_address=GroupAddress("1/2/3"), payload=DPTBinary(1)
)
self.loop.run_until_complete(switch.process(telegram))

Expand Down
14 changes: 8 additions & 6 deletions test/knxip_tests/cemi_frame_test.py
Expand Up @@ -6,8 +6,8 @@
from xknx.dpt import DPTBinary, DPTComparator
from xknx.exceptions import ConversionError, CouldNotParseKNXIP, UnsupportedCEMIMessage
from xknx.knxip.cemi_frame import CEMIFrame
from xknx.knxip.knxip_enum import APCICommand, CEMIMessageCode, CEMIFlags
from xknx.telegram import PhysicalAddress, Telegram, GroupAddress
from xknx.knxip.knxip_enum import APCICommand, CEMIFlags, CEMIMessageCode
from xknx.telegram import GroupAddress, PhysicalAddress, Telegram


def get_data(code, adil, flags, src, dst, mpdu_len, tpci_apci, payload):
Expand Down Expand Up @@ -173,16 +173,18 @@ def test_telegram_group_address(frame):
"""Test telegram conversion flags with a group address"""
frame.telegram = Telegram(destination_address=GroupAddress(0))

assert (frame.flags & CEMIFlags.DESTINATION_GROUP_ADDRESS) == \
CEMIFlags.DESTINATION_GROUP_ADDRESS
assert (
frame.flags & CEMIFlags.DESTINATION_GROUP_ADDRESS
) == CEMIFlags.DESTINATION_GROUP_ADDRESS


def test_telegram_physical_address(frame):
"""Test telegram conversion flags with a physical address"""
frame.telegram = Telegram(destination_address=PhysicalAddress(0))

assert (frame.flags & CEMIFlags.DESTINATION_INDIVIDUAL_ADDRESS) == \
CEMIFlags.DESTINATION_INDIVIDUAL_ADDRESS
assert (
frame.flags & CEMIFlags.DESTINATION_INDIVIDUAL_ADDRESS
) == CEMIFlags.DESTINATION_INDIVIDUAL_ADDRESS


def test_telegram_unsupported_address(frame):
Expand Down
2 changes: 1 addition & 1 deletion test/knxip_tests/routing_indication_test.py
Expand Up @@ -241,7 +241,7 @@ def test_maximum_apci(self):
"""Test parsing and streaming CEMIFrame KNX/IP packet, testing maximum APCI."""
telegram = Telegram(
destination_address=GroupAddress(337),
payload=DPTBinary(DPTBinary.APCI_MAX_VALUE)
payload=DPTBinary(DPTBinary.APCI_MAX_VALUE),
)
xknx = XKNX()
knxipframe = KNXIPFrame(xknx)
Expand Down
6 changes: 2 additions & 4 deletions test/remote_value_tests/remote_value_1count_test.py
Expand Up @@ -59,8 +59,7 @@ def test_process(self):
xknx = XKNX()
remote_value = RemoteValue1Count(xknx, group_address=GroupAddress("1/2/3"))
telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTArray((0x64,))
destination_address=GroupAddress("1/2/3"), payload=DPTArray((0x64,))
)
self.loop.run_until_complete(remote_value.process(telegram))
self.assertEqual(remote_value.value, 100)
Expand All @@ -71,8 +70,7 @@ def test_to_process_error(self):
remote_value = RemoteValue1Count(xknx, group_address=GroupAddress("1/2/3"))
with self.assertRaises(CouldNotParseTelegram):
telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTBinary(1)
destination_address=GroupAddress("1/2/3"), payload=DPTBinary(1)
)
self.loop.run_until_complete(remote_value.process(telegram))
with self.assertRaises(CouldNotParseTelegram):
Expand Down
12 changes: 4 additions & 8 deletions test/remote_value_tests/remote_value_climate_mode_test.py
Expand Up @@ -219,8 +219,7 @@ def test_process_operation_mode(self):
climate_mode_type=RemoteValueClimateMode.ClimateModeType.HVAC_MODE,
)
telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTArray((0x00,))
destination_address=GroupAddress("1/2/3"), payload=DPTArray((0x00,))
)
self.loop.run_until_complete(remote_value.process(telegram))
self.assertEqual(remote_value.value, HVACOperationMode.AUTO)
Expand All @@ -234,8 +233,7 @@ def test_process_binary(self):
operation_mode=HVACOperationMode.FROST_PROTECTION,
)
telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTBinary(True)
destination_address=GroupAddress("1/2/3"), payload=DPTBinary(True)
)
self.loop.run_until_complete(remote_value.process(telegram))
self.assertEqual(remote_value.value, HVACOperationMode.FROST_PROTECTION)
Expand All @@ -250,8 +248,7 @@ def test_to_process_error_operation_mode(self):
)
with self.assertRaises(CouldNotParseTelegram):
telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTBinary(1)
destination_address=GroupAddress("1/2/3"), payload=DPTBinary(1)
)
self.loop.run_until_complete(remote_value.process(telegram))
with self.assertRaises(CouldNotParseTelegram):
Expand All @@ -276,8 +273,7 @@ def test_to_process_error_heat_cool(self):
)
with self.assertRaises(CouldNotParseTelegram):
telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTArray((0x01,))
destination_address=GroupAddress("1/2/3"), payload=DPTArray((0x01,))
)
self.loop.run_until_complete(remote_value.process(telegram))
with self.assertRaises(CouldNotParseTelegram):
Expand Down
5 changes: 2 additions & 3 deletions test/remote_value_tests/remote_value_color_rgb_test.py
Expand Up @@ -80,7 +80,7 @@ def test_process(self):
remote_value = RemoteValueColorRGB(xknx, group_address=GroupAddress("1/2/3"))
telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTArray((0x64, 0x65, 0x66))
payload=DPTArray((0x64, 0x65, 0x66)),
)
self.loop.run_until_complete(remote_value.process(telegram))
self.assertEqual(remote_value.value, (100, 101, 102))
Expand All @@ -91,8 +91,7 @@ def test_to_process_error(self):
remote_value = RemoteValueColorRGB(xknx, group_address=GroupAddress("1/2/3"))
with self.assertRaises(CouldNotParseTelegram):
telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTBinary(1)
destination_address=GroupAddress("1/2/3"), payload=DPTBinary(1)
)
self.loop.run_until_complete(remote_value.process(telegram))
with self.assertRaises(CouldNotParseTelegram):
Expand Down
3 changes: 1 addition & 2 deletions test/remote_value_tests/remote_value_color_rgbw_test.py
Expand Up @@ -125,8 +125,7 @@ def test_to_process_error(self):
remote_value = RemoteValueColorRGBW(xknx, group_address=GroupAddress("1/2/3"))
with self.assertRaises(CouldNotParseTelegram):
telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTBinary(1)
destination_address=GroupAddress("1/2/3"), payload=DPTBinary(1)
)
self.loop.run_until_complete(remote_value.process(telegram))
with self.assertRaises(CouldNotParseTelegram):
Expand Down
Expand Up @@ -77,8 +77,7 @@ def test_process(self):
xknx, group_address=GroupAddress("1/2/3")
)
telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTArray((0x0A, 0x0B))
destination_address=GroupAddress("1/2/3"), payload=DPTArray((0x0A, 0x0B))
)
self.loop.run_until_complete(remote_value.process(telegram))
self.assertEqual(remote_value.value, 2571)
Expand All @@ -91,14 +90,12 @@ def test_to_process_error(self):
)
with self.assertRaises(CouldNotParseTelegram):
telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTBinary(1)
destination_address=GroupAddress("1/2/3"), payload=DPTBinary(1)
)
self.loop.run_until_complete(remote_value.process(telegram))
with self.assertRaises(CouldNotParseTelegram):
telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTArray((0x64,))
destination_address=GroupAddress("1/2/3"), payload=DPTArray((0x64,))
)
self.loop.run_until_complete(remote_value.process(telegram))
with self.assertRaises(CouldNotParseTelegram):
Expand Down
Expand Up @@ -68,8 +68,7 @@ def test_process(self):
xknx, group_address=GroupAddress("1/2/3")
)
telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTArray((0x0A,))
destination_address=GroupAddress("1/2/3"), payload=DPTArray((0x0A,))
)
self.loop.run_until_complete(remote_value.process(telegram))
self.assertEqual(remote_value.value, 10)
Expand All @@ -82,8 +81,7 @@ def test_to_process_error(self):
)
with self.assertRaises(CouldNotParseTelegram):
telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTBinary(1)
destination_address=GroupAddress("1/2/3"), payload=DPTBinary(1)
)
self.loop.run_until_complete(remote_value.process(telegram))
with self.assertRaises(CouldNotParseTelegram):
Expand Down
6 changes: 2 additions & 4 deletions test/remote_value_tests/remote_value_scene_number_test.py
Expand Up @@ -64,8 +64,7 @@ def test_process(self):
xknx = XKNX()
remote_value = RemoteValueSceneNumber(xknx, group_address=GroupAddress("1/2/3"))
telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTArray((0x0A,))
destination_address=GroupAddress("1/2/3"), payload=DPTArray((0x0A,))
)
self.loop.run_until_complete(remote_value.process(telegram))
self.assertEqual(remote_value.value, 11)
Expand All @@ -76,8 +75,7 @@ def test_to_process_error(self):
remote_value = RemoteValueSceneNumber(xknx, group_address=GroupAddress("1/2/3"))
with self.assertRaises(CouldNotParseTelegram):
telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTBinary(1)
destination_address=GroupAddress("1/2/3"), payload=DPTBinary(1)
)
self.loop.run_until_complete(remote_value.process(telegram))
with self.assertRaises(CouldNotParseTelegram):
Expand Down
10 changes: 4 additions & 6 deletions test/remote_value_tests/remote_value_step_test.py
Expand Up @@ -94,8 +94,8 @@ def test_process(self):
xknx = XKNX()
remote_value = RemoteValueStep(xknx, group_address=GroupAddress("1/2/3"))
telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTBinary(0))
destination_address=GroupAddress("1/2/3"), payload=DPTBinary(0)
)
self.assertEqual(remote_value.value, None)
self.loop.run_until_complete(remote_value.process(telegram))
self.assertEqual(remote_value.value, RemoteValueStep.Direction.DECREASE)
Expand All @@ -106,14 +106,12 @@ def test_to_process_error(self):
remote_value = RemoteValueStep(xknx, group_address=GroupAddress("1/2/3"))
with self.assertRaises(CouldNotParseTelegram):
telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTArray(0x01)
destination_address=GroupAddress("1/2/3"), payload=DPTArray(0x01)
)
self.loop.run_until_complete(remote_value.process(telegram))
with self.assertRaises(CouldNotParseTelegram):
telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTBinary(3)
destination_address=GroupAddress("1/2/3"), payload=DPTBinary(3)
)
self.loop.run_until_complete(remote_value.process(telegram))
# pylint: disable=pointless-statement
Expand Down
3 changes: 1 addition & 2 deletions test/remote_value_tests/remote_value_string_test.py
Expand Up @@ -141,8 +141,7 @@ def test_to_process_error(self):
remote_value = RemoteValueString(xknx, group_address=GroupAddress("1/2/3"))
with self.assertRaises(CouldNotParseTelegram):
telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTBinary(1)
destination_address=GroupAddress("1/2/3"), payload=DPTBinary(1)
)
self.loop.run_until_complete(remote_value.process(telegram))
with self.assertRaises(CouldNotParseTelegram):
Expand Down
12 changes: 4 additions & 8 deletions test/remote_value_tests/remote_value_switch_test.py
Expand Up @@ -78,8 +78,7 @@ def test_process(self):
xknx = XKNX()
remote_value = RemoteValueSwitch(xknx, group_address=GroupAddress("1/2/3"))
telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTBinary(1)
destination_address=GroupAddress("1/2/3"), payload=DPTBinary(1)
)
self.assertEqual(remote_value.value, None)
self.loop.run_until_complete(remote_value.process(telegram))
Expand All @@ -91,8 +90,7 @@ def test_process_off(self):
xknx = XKNX()
remote_value = RemoteValueSwitch(xknx, group_address=GroupAddress("1/2/3"))
telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTBinary(0)
destination_address=GroupAddress("1/2/3"), payload=DPTBinary(0)
)
self.assertEqual(remote_value.value, None)
self.loop.run_until_complete(remote_value.process(telegram))
Expand All @@ -105,14 +103,12 @@ def test_to_process_error(self):
remote_value = RemoteValueSwitch(xknx, group_address=GroupAddress("1/2/3"))
with self.assertRaises(CouldNotParseTelegram):
telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTArray(0x01)
destination_address=GroupAddress("1/2/3"), payload=DPTArray(0x01)
)
self.loop.run_until_complete(remote_value.process(telegram))
with self.assertRaises(CouldNotParseTelegram):
telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTBinary(3)
destination_address=GroupAddress("1/2/3"), payload=DPTBinary(3)
)
self.loop.run_until_complete(remote_value.process(telegram))
# pylint: disable=pointless-statement
Expand Down
9 changes: 3 additions & 6 deletions test/remote_value_tests/remote_value_updown_test.py
Expand Up @@ -94,8 +94,7 @@ def test_process(self):
xknx = XKNX()
remote_value = RemoteValueUpDown(xknx, group_address=GroupAddress("1/2/3"))
telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTBinary(1)
destination_address=GroupAddress("1/2/3"), payload=DPTBinary(1)
)
self.assertEqual(remote_value.value, None)
self.loop.run_until_complete(remote_value.process(telegram))
Expand All @@ -107,14 +106,12 @@ def test_to_process_error(self):
remote_value = RemoteValueUpDown(xknx, group_address=GroupAddress("1/2/3"))
with self.assertRaises(CouldNotParseTelegram):
telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTArray(0x01)
destination_address=GroupAddress("1/2/3"), payload=DPTArray(0x01)
)
self.loop.run_until_complete(remote_value.process(telegram))
with self.assertRaises(CouldNotParseTelegram):
telegram = Telegram(
destination_address=GroupAddress("1/2/3"),
payload=DPTBinary(3)
destination_address=GroupAddress("1/2/3"), payload=DPTBinary(3)
)
self.loop.run_until_complete(remote_value.process(telegram))
# pylint: disable=pointless-statement
Expand Down

0 comments on commit 0b32417

Please sign in to comment.