From 3c2d3e07714199b0b087456ae20c89100cbfdfa0 Mon Sep 17 00:00:00 2001 From: Matthias Alphart Date: Sun, 27 Sep 2020 02:43:49 +0200 Subject: [PATCH] Remove loop argument (#433) * remove loop argument from XKNX() use asyncio.get_running_loop() and asyncio.create_task() (or non-async method in knxip_interface) * test without loop argument * Review: Fix date time tests. By the time you add the tasks to asyncio the loop is not yet running thus the error occurs. Simply add the tasks to the created (but not yet started) loop and wait for it to run. Co-authored-by: Marvin Wichmann --- .../custom_components/xknx/__init__.py | 1 - test/core_tests/config_test.py | 6 +- test/core_tests/state_updater_test.py | 8 +- test/core_tests/telegram_queue_test.py | 24 +- test/core_tests/value_reader_test.py | 8 +- test/devices_tests/action_test.py | 16 +- test/devices_tests/binary_sensor_test.py | 18 +- test/devices_tests/climate_test.py | 104 +++---- test/devices_tests/cover_test.py | 72 ++--- test/devices_tests/datetime_test.py | 10 +- test/devices_tests/device_test.py | 18 +- test/devices_tests/devices_test.py | 18 +- test/devices_tests/expose_sensor_test.py | 22 +- test/devices_tests/fan_test.py | 18 +- test/devices_tests/light_test.py | 80 +++--- test/devices_tests/notification_test.py | 18 +- test/devices_tests/scene_test.py | 10 +- test/devices_tests/sensor_expose_loop_test.py | 4 +- test/devices_tests/sensor_test.py | 272 +++++++++--------- test/devices_tests/switch_test.py | 18 +- test/devices_tests/weather_test.py | 36 +-- test/io_tests/connect_test.py | 2 +- test/io_tests/connectionstate_test.py | 2 +- test/io_tests/disconnect_test.py | 2 +- test/io_tests/gateway_scanner_test.py | 6 +- test/io_tests/request_response_test.py | 2 +- test/io_tests/tunnelling_test.py | 2 +- test/knxip_tests/body_test.py | 6 +- test/knxip_tests/connect_request_test.py | 6 +- test/knxip_tests/connect_response_test.py | 8 +- .../connectionstate_request_test.py | 4 +- .../connectionstate_response_test.py | 4 +- test/knxip_tests/disconnect_request_test.py | 4 +- test/knxip_tests/disconnect_response_test.py | 4 +- test/knxip_tests/header_test.py | 12 +- test/knxip_tests/knxip_test.py | 4 +- test/knxip_tests/routing_indication_test.py | 24 +- test/knxip_tests/search_request_test.py | 2 +- test/knxip_tests/search_response_test.py | 4 +- test/knxip_tests/tunnelling_ack_test.py | 6 +- test/knxip_tests/tunnelling_request_test.py | 6 +- .../remote_value_1count_test.py | 10 +- .../remote_value_climate_mode_test.py | 40 +-- .../remote_value_color_rgb_test.py | 12 +- .../remote_value_color_rgbw_test.py | 12 +- .../remote_value_datetime_test.py | 10 +- .../remote_value_dpt_2_byte_unsigned_test.py | 12 +- .../remote_value_dpt_value_1_ucount_test.py | 12 +- .../remote_value_scaling_test.py | 2 +- .../remote_value_scene_number_test.py | 12 +- .../remote_value_sensor_test.py | 2 +- .../remote_value_step_test.py | 16 +- .../remote_value_string_test.py | 12 +- .../remote_value_switch_test.py | 18 +- test/remote_value_tests/remote_value_test.py | 20 +- .../remote_value_updown_test.py | 16 +- test/str_test.py | 66 ++--- test/xknx_test.py | 14 +- xknx/core/state_updater.py | 4 +- xknx/core/value_reader.py | 5 +- xknx/devices/binary_sensor.py | 4 +- xknx/devices/datetime.py | 3 +- xknx/io/gateway_scanner.py | 5 +- xknx/io/knxip_interface.py | 2 +- xknx/io/request_response.py | 5 +- xknx/io/tunnel.py | 11 +- xknx/io/udp_client.py | 6 +- xknx/xknx.py | 9 +- 68 files changed, 613 insertions(+), 618 deletions(-) diff --git a/home-assistant-plugin/custom_components/xknx/__init__.py b/home-assistant-plugin/custom_components/xknx/__init__.py index 2ec42b061..321ba7f66 100644 --- a/home-assistant-plugin/custom_components/xknx/__init__.py +++ b/home-assistant-plugin/custom_components/xknx/__init__.py @@ -191,7 +191,6 @@ def init_xknx(self): """Initialize of KNX object.""" self.xknx = XKNX( config=self.config_file(), - loop=self.hass.loop, own_address=self.config[DOMAIN][CONF_XKNX_INDIVIDUAL_ADDRESS], rate_limit=self.config[DOMAIN][CONF_XKNX_RATE_LIMIT], multicast_group=self.config[DOMAIN][CONF_XKNX_MCAST_GRP], diff --git a/test/core_tests/config_test.py b/test/core_tests/config_test.py index 5d6b57405..d7c178549 100644 --- a/test/core_tests/config_test.py +++ b/test/core_tests/config_test.py @@ -42,7 +42,7 @@ def setUpClass(cls): ) cls.datetime_patcher.start() - cls.xknx = XKNX(config="xknx.yaml", loop=cls.loop) + cls.xknx = XKNX(config="xknx.yaml") @classmethod def tearDownClass(cls): @@ -553,7 +553,7 @@ def test_config_weather_expose_sensor(self): def test_config_file_not_found(self): """Test error message when reading a non exisiting config file.""" with patch("logging.Logger.error") as mock_err: - XKNX(config="xknx_does_not_exist.yaml", loop=self.loop) + XKNX(config="xknx_does_not_exist.yaml") self.assertEqual(mock_err.call_count, 1) def test_config_file_error(self): @@ -562,5 +562,5 @@ def test_config_file_error(self): "xknx.core.Config.parse_group_light" ) as mock_parse: mock_parse.side_effect = XKNXException() - XKNX(config="xknx.yaml", loop=self.loop) + XKNX(config="xknx.yaml") self.assertEqual(mock_err.call_count, 1) diff --git a/test/core_tests/state_updater_test.py b/test/core_tests/state_updater_test.py index 45ccf1a95..3b05210de 100644 --- a/test/core_tests/state_updater_test.py +++ b/test/core_tests/state_updater_test.py @@ -26,7 +26,7 @@ def tearDown(self): def test_register_unregister(self): """Test register and unregister.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() self.assertEqual(len(xknx.state_updater._workers), 0) # register when state address and sync_state is set remote_value_1 = RemoteValue( @@ -54,7 +54,7 @@ def test_register_unregister(self): def test_tracker_parser(self): """Test parsing tracker options.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() def _get_only_tracker() -> _StateTracker: # _workers is unordered so it just works with 1 item @@ -104,7 +104,7 @@ def _get_only_tracker() -> _StateTracker: @patch("logging.Logger.warning") def test_tracker_parser_invalid_options(self, logging_warning_mock): """Test parsing invalid tracker options.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() def _get_only_tracker() -> _StateTracker: # _workers is unordered so it just works with 1 item @@ -152,7 +152,7 @@ def _get_only_tracker() -> _StateTracker: def test_state_updater_start_update_stop(self): """Test start, update_received and stop of StateUpdater.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value_1 = RemoteValue( xknx, sync_state=True, group_address_state=GroupAddress("1/1/1") ) diff --git a/test/core_tests/telegram_queue_test.py b/test/core_tests/telegram_queue_test.py index b0263f657..e8826de12 100644 --- a/test/core_tests/telegram_queue_test.py +++ b/test/core_tests/telegram_queue_test.py @@ -27,7 +27,7 @@ def tearDown(self): def test_start(self): """Test start, run and stop.""" # pylint: disable=no-self-use - xknx = XKNX(loop=self.loop) + xknx = XKNX() telegram_in = Telegram( direction=TelegramDirection.INCOMING, @@ -61,7 +61,7 @@ async def async_none(): async_sleep_mock.return_value = asyncio.ensure_future(async_none()) - xknx = XKNX(loop=self.loop) + xknx = XKNX() xknx.rate_limit = 20 # 50 ms per outgoing telegram sleep_time = 0.05 # 1 / 20 @@ -99,7 +99,7 @@ async def async_none(): def test_register(self): """Test telegram_received_callback after state of switch was changed.""" # pylint: disable=no-self-use - xknx = XKNX(loop=self.loop) + xknx = XKNX() telegram_received_callback = Mock() @@ -125,7 +125,7 @@ async def async_telegram_received_cb(device): def test_unregister(self): """Test telegram_received_callback after state of switch was changed.""" # pylint: disable=no-self-use - xknx = XKNX(loop=self.loop) + xknx = XKNX() telegram_received_callback = Mock() @@ -155,7 +155,7 @@ async def async_telegram_received_cb(device): def test_process_to_device(self, devices_by_ga_mock): """Test process_telegram_incoming for forwarding telegram to a device.""" # pylint: disable=no-self-use - xknx = XKNX(loop=self.loop) + xknx = XKNX() test_device = Mock() async_device_process = asyncio.Future() @@ -180,7 +180,7 @@ def test_process_to_device(self, devices_by_ga_mock): def test_process_to_callback(self, devices_by_ga_mock): """Test process_telegram_incoming for returning after processing callback.""" # pylint: disable=no-self-use - xknx = XKNX(loop=self.loop) + xknx = XKNX() telegram_received_callback = Mock() @@ -207,7 +207,7 @@ async def async_telegram_received_cb(device): def test_outgoing(self, logger_warning_mock, if_mock): """Test outgoing telegrams in telegram queue.""" # pylint: disable=no-self-use - xknx = XKNX(loop=self.loop) + xknx = XKNX() async_if_send_telegram = asyncio.Future() async_if_send_telegram.set_result(None) @@ -238,7 +238,7 @@ def test_outgoing(self, logger_warning_mock, if_mock): def test_process_exception(self, process_tg_in_mock, logging_error_mock): """Test process_telegram exception handling.""" # pylint: disable=no-self-use - xknx = XKNX(loop=self.loop) + xknx = XKNX() async def process_exception(): raise CouldNotParseTelegram( @@ -270,7 +270,7 @@ def test_process_all_telegrams( ): """Test _process_all_telegrams for clearing the queue.""" # pylint: disable=no-self-use - xknx = XKNX(loop=self.loop) + xknx = XKNX() async_process_mock = asyncio.Future() async_process_mock.set_result(None) @@ -302,7 +302,7 @@ def test_process_all_telegrams( def test_no_filters(self): """Test telegram_received_callback after state of switch was changed.""" # pylint: disable=no-self-use - xknx = XKNX(loop=self.loop) + xknx = XKNX() telegram_received_callback = Mock() @@ -328,7 +328,7 @@ async def async_telegram_received_cb(device): def test_positive_filters(self): """Test telegram_received_callback after state of switch was changed.""" # pylint: disable=no-self-use - xknx = XKNX(loop=self.loop) + xknx = XKNX() telegram_received_callback = Mock() @@ -357,7 +357,7 @@ async def async_telegram_received_cb(device): def test_negative_filters(self): """Test telegram_received_callback after state of switch was changed.""" # pylint: disable=no-self-use - xknx = XKNX(loop=self.loop) + xknx = XKNX() telegram_received_callback = Mock() diff --git a/test/core_tests/value_reader_test.py b/test/core_tests/value_reader_test.py index 436bdd980..afbe35d5e 100644 --- a/test/core_tests/value_reader_test.py +++ b/test/core_tests/value_reader_test.py @@ -24,7 +24,7 @@ def tearDown(self): @patch("xknx.core.ValueReader.timeout") def test_value_reader_read_success(self, timeout_mock): """Test value reader: successfull read.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() test_group_address = GroupAddress("0/0/0") response_telegram = Telegram( group_address=test_group_address, @@ -59,7 +59,7 @@ def test_value_reader_read_success(self, timeout_mock): @patch("logging.Logger.warning") def test_value_reader_read_timeout(self, logger_warning_mock): """Test value reader: read timeout.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() value_reader = ValueReader(xknx, GroupAddress("0/0/0"), timeout_in_seconds=0) timed_out_read = self.loop.run_until_complete(value_reader.read()) @@ -85,7 +85,7 @@ def test_value_reader_read_timeout(self, logger_warning_mock): def test_value_reader_send_group_read(self): """Test value reader: send_group_read.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() value_reader = ValueReader(xknx, GroupAddress("0/0/0")) self.loop.run_until_complete(value_reader.send_group_read()) @@ -101,7 +101,7 @@ def test_value_reader_send_group_read(self): def test_value_reader_telegram_received(self): """Test value reader: telegram_received.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() test_group_address = GroupAddress("0/0/0") expected_telegram_1 = Telegram( group_address=test_group_address, diff --git a/test/devices_tests/action_test.py b/test/devices_tests/action_test.py index 350b9634e..c4af3df2d 100644 --- a/test/devices_tests/action_test.py +++ b/test/devices_tests/action_test.py @@ -24,7 +24,7 @@ def tearDown(self): # def test_counter(self): """Test counter method.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() action = ActionBase(xknx, counter=2) self.assertTrue(action.test_counter(None)) self.assertFalse(action.test_counter(1)) @@ -33,7 +33,7 @@ def test_counter(self): def test_no_counter(self): """Test counter method with no counter set.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() action = ActionBase(xknx, counter=None) self.assertTrue(action.test_counter(None)) self.assertTrue(action.test_counter(1)) @@ -45,7 +45,7 @@ def test_no_counter(self): # def test_if_applicable_hook_on(self): """Test test_if_applicable method with hook set to 'on'.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() action = ActionBase(xknx, counter=2, hook="on") self.assertTrue(action.test_if_applicable(True, 2)) self.assertFalse(action.test_if_applicable(True, 3)) @@ -53,7 +53,7 @@ def test_if_applicable_hook_on(self): def test_if_applicable_hook_off(self): """Test test_if_applicable method with hook set to 'off'.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() action = ActionBase(xknx, counter=2, hook="off") self.assertTrue(action.test_if_applicable(False, 2)) self.assertFalse(action.test_if_applicable(False, 3)) @@ -64,7 +64,7 @@ def test_if_applicable_hook_off(self): # def test_execute_base_action(self): """Test if execute method of BaseAction shows correct info message.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() action = ActionBase(xknx) with patch("logging.Logger.info") as mock_info: self.loop.run_until_complete(action.execute()) @@ -72,7 +72,7 @@ def test_execute_base_action(self): def test_execute_action(self): """Test if execute method of Action calls correct do method of device.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light(xknx, "Light1", group_address_switch="1/6/4") action = Action(xknx, target=light.name, method="on") with patch("xknx.devices.Light.do") as mock_do: @@ -84,7 +84,7 @@ def test_execute_action(self): def test_execute_action_callback(self): """Test if execute method of ActionCallback calls correct callback method.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() callback = Mock() async def async_callback(): @@ -97,7 +97,7 @@ async def async_callback(): def test_execute_unknown_device(self): """Test if execute method of Action calls correct do method of device.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() action = Action(xknx, target="Light1", method="on") with patch("logging.Logger.warning") as logger_warning_mock: diff --git a/test/devices_tests/binary_sensor_test.py b/test/devices_tests/binary_sensor_test.py index 6cd035d5c..c4f5a7d59 100644 --- a/test/devices_tests/binary_sensor_test.py +++ b/test/devices_tests/binary_sensor_test.py @@ -32,7 +32,7 @@ def tearDown(self): # def test_process(self): """Test process / reading telegrams from telegram queue.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() binaryinput = BinarySensor(xknx, "TestInput", "1/2/3") self.assertEqual(binaryinput.state, None) @@ -61,7 +61,7 @@ def test_process(self): def test_process_reset_after(self): """Test process / reading telegrams from telegram queue.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() reset_after_ms = 0.01 binaryinput = BinarySensor( xknx, "TestInput", "1/2/3", reset_after=reset_after_ms @@ -76,7 +76,7 @@ def test_process_reset_after(self): def test_process_action(self): """Test process / reading telegrams from telegram queue. Test if action is executed.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() switch = Switch(xknx, "TestOutlet", group_address="1/2/3") binary_sensor = BinarySensor(xknx, "TestInput", group_address_state="1/2/3") @@ -109,7 +109,7 @@ def test_process_action(self): def test_process_action_ignore_internal_state(self): """Test process / reading telegrams from telegram queue. Test if action is executed.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() switch = Switch(xknx, "TestOutlet", group_address="5/5/5") binary_sensor = BinarySensor( @@ -158,7 +158,7 @@ def test_process_action_ignore_internal_state(self): def test_process_wrong_payload(self): """Test process wrong telegram (wrong payload type).""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() binary_sensor = BinarySensor(xknx, "Warning", group_address_state="1/2/3") telegram = Telegram(GroupAddress("1/2/3"), payload=DPTArray((0x1, 0x2, 0x3))) with self.assertRaises(CouldNotParseTelegram): @@ -169,7 +169,7 @@ def test_process_wrong_payload(self): # def test_is_on(self): """Test is_on() and is_off() of a BinarySensor with state 'on'.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() binaryinput = BinarySensor(xknx, "TestInput", "1/2/3") self.assertFalse(binaryinput.is_on()) self.assertTrue(binaryinput.is_off()) @@ -184,7 +184,7 @@ def test_is_on(self): # def test_is_off(self): """Test is_on() and is_off() of a BinarySensor with state 'off'.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() binaryinput = BinarySensor(xknx, "TestInput", "1/2/3") # pylint: disable=protected-access self.loop.run_until_complete(binaryinput._set_internal_state(False)) @@ -198,7 +198,7 @@ def test_is_off(self): def test_process_callback(self): """Test after_update_callback after state of switch was changed.""" # pylint: disable=no-self-use - xknx = XKNX(loop=self.loop) + xknx = XKNX() switch = BinarySensor(xknx, "TestInput", group_address_state="1/2/3") after_update_callback = Mock() @@ -219,7 +219,7 @@ async def async_after_update_callback(device): # def test_counter(self): """Test counter functionality.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() switch = BinarySensor(xknx, "TestInput", group_address_state="1/2/3") with patch("time.time") as mock_time: mock_time.return_value = 1517000000.0 diff --git a/test/devices_tests/climate_test.py b/test/devices_tests/climate_test.py index 281219ad8..5435cb156 100644 --- a/test/devices_tests/climate_test.py +++ b/test/devices_tests/climate_test.py @@ -47,7 +47,7 @@ def tearDown(self): # def test_support_temperature(self): """Test supports_temperature flag.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate = Climate(xknx, "TestClimate", group_address_temperature="1/2/3") self.assertTrue(climate.temperature.initialized) @@ -55,7 +55,7 @@ def test_support_temperature(self): def test_support_target_temperature(self): """Test supports_target__temperature flag.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate = Climate(xknx, "TestClimate", group_address_target_temperature="1/2/3") self.assertFalse(climate.temperature.initialized) @@ -63,7 +63,7 @@ def test_support_target_temperature(self): def test_support_operation_mode(self): """Test supports_supports_operation_mode flag. One group address for all modes.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode( xknx, "TestClimate", group_address_operation_mode="1/2/4" ) @@ -71,7 +71,7 @@ def test_support_operation_mode(self): def test_support_operation_mode2(self): """Test supports_supports_operation_mode flag. Splitted group addresses for each mode.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode( xknx, "TestClimate", group_address_operation_mode_protection="1/2/4" ) @@ -82,7 +82,7 @@ def test_support_operation_mode2(self): # def test_has_group_address(self): """Test if has_group_address function works.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate = Climate( xknx, "TestClimate", @@ -106,7 +106,7 @@ def test_has_group_address(self): # def test_has_group_address_mode(self): """Test if has_group_address function works.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode( xknx, name=None, @@ -146,7 +146,7 @@ def test_has_group_address_mode(self): def test_process_callback(self): """Test if after_update_callback is called after update of Climate object was changed.""" # pylint: disable=no-self-use - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate = Climate( xknx, "TestClimate", @@ -176,7 +176,7 @@ async def async_after_update_callback(device): def test_process_callback_mode(self): """Test if after_update_callback is called after update of Climate object was changed.""" # pylint: disable=no-self-use - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode( xknx, "TestClimate", group_address_operation_mode="1/2/5" ) @@ -213,7 +213,7 @@ async def async_after_update_callback(device): def test_process_callback_updated_via_telegram(self): """Test if after_update_callback is called after update of Climate object.""" # pylint: disable=no-self-use - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate = Climate( xknx, "TestClimate", @@ -254,7 +254,7 @@ async def async_after_update_callback(device): def test_climate_mode_process_callback_updated_via_telegram(self): """Test if after_update_callback is called after update of ClimateMode object.""" # pylint: disable=no-self-use - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode( xknx, "TestClimateMode", group_address_operation_mode="1/2/4" ) @@ -281,7 +281,7 @@ async def async_after_update_callback(device): # def test_set_operation_mode(self): """Test set_operation_mode.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode( xknx, "TestClimate", group_address_operation_mode="1/2/4" ) @@ -303,7 +303,7 @@ def test_set_operation_mode(self): def test_set_controller_operation_mode(self): """Test set_operation_mode with DPT20.105 controller.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode( xknx, "TestClimate", group_address_controller_mode="1/2/4" ) @@ -325,7 +325,7 @@ def test_set_controller_operation_mode(self): def test_set_operation_mode_not_supported(self): """Test set_operation_mode but not supported.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode(xknx, "TestClimate") with self.assertRaises(DeviceIllegalValue): self.loop.run_until_complete( @@ -334,7 +334,7 @@ def test_set_operation_mode_not_supported(self): def test_set_operation_mode_with_controller_status(self): """Test set_operation_mode with controller status adddressedefined.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode( xknx, "TestClimate", group_address_controller_status="1/2/4" ) @@ -358,7 +358,7 @@ def test_set_operation_mode_with_controller_status(self): def test_set_operation_mode_with_separate_addresses(self): """Test set_operation_mode with combined and separated group adddresses defined.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode( xknx, "TestClimate", @@ -388,7 +388,7 @@ def test_set_operation_mode_with_separate_addresses(self): def test_set_heat_cool_binary(self): """Test set_operation_mode with binary heat/cool group adddresses defined.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode( xknx, "TestClimate", @@ -418,7 +418,7 @@ def test_set_heat_cool_binary(self): # def test_initialized_for_setpoint_shift_calculations(self): """Test initialized_for_setpoint_shift_calculations method.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate1 = Climate(xknx, "TestClimate") self.assertFalse(climate1.initialized_for_setpoint_shift_calculations) @@ -447,7 +447,7 @@ def test_initialized_for_setpoint_shift_calculations(self): # def test_uninitalized_for_target_temperature_min_max(self): """Test if target_temperature_min/target_temperature_max return non if not initialized.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate = Climate(xknx, "TestClimate") self.assertEqual(climate.target_temperature_min, None) self.assertEqual(climate.target_temperature_max, None) @@ -457,7 +457,7 @@ def test_uninitalized_for_target_temperature_min_max(self): # def test_uninitalized_for_target_temperature_min_max_can_be_overridden(self): """Test if target_temperature_min/target_temperature_max return overridden value if specified.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate = Climate(xknx, "TestClimate", min_temp="7", max_temp="35") self.assertEqual(climate.target_temperature_min, "7") self.assertEqual(climate.target_temperature_max, "35") @@ -467,7 +467,7 @@ def test_uninitalized_for_target_temperature_min_max_can_be_overridden(self): # def test_overridden_max_min_temperature_has_priority(self): """Test that the overridden min and max temp always have precedence over setpoint shift calculations.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate = Climate( xknx, "TestClimate", @@ -492,7 +492,7 @@ def test_overridden_max_min_temperature_has_priority(self): def test_target_temperature_up(self): """Test increase target temperature.""" # pylint: disable=no-self-use - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate = Climate( xknx, "TestClimate", @@ -575,7 +575,7 @@ def test_target_temperature_up(self): def test_target_temperature_down(self): """Test decrease target temperature.""" # pylint: disable=no-self-use - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate = Climate( xknx, "TestClimate", @@ -658,7 +658,7 @@ def test_target_temperature_down(self): def test_target_temperature_modified_step(self): """Test increase target temperature with modified step size.""" # pylint: disable=no-self-use - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate = Climate( xknx, "TestClimate", @@ -719,7 +719,7 @@ def test_target_temperature_modified_step(self): def test_base_temperature(self): """Test base temperature.""" # pylint: disable=no-self-use - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate = Climate( xknx, "TestClimate", @@ -774,7 +774,7 @@ def test_base_temperature(self): def test_target_temperature_step_mode_9002(self): """Test increase target temperature with modified step size.""" # pylint: disable=no-self-use - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate = Climate( xknx, "TestClimate", @@ -839,7 +839,7 @@ def test_target_temperature_step_mode_9002(self): def test_temperature_step(self): """Test base temperature step.""" # pylint: disable=no-self-use - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate = Climate( xknx, "TestClimate", @@ -876,7 +876,7 @@ def test_temperature_step(self): # def test_sync(self): """Test sync function / sending group reads to KNX bus.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate = Climate(xknx, "TestClimate", group_address_temperature="1/2/3") self.loop.run_until_complete(climate.sync()) self.assertEqual(xknx.telegrams.qsize(), 1) @@ -887,7 +887,7 @@ def test_sync(self): def test_sync_operation_mode(self): """Test sync function / sending group reads to KNX bus for operation mode.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode( xknx, "TestClimate", @@ -903,7 +903,7 @@ def test_sync_operation_mode(self): def test_sync_controller_status(self): """Test sync function / sending group reads to KNX bus for controller status.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode( xknx, "TestClimate", @@ -919,7 +919,7 @@ def test_sync_controller_status(self): def test_sync_controller_mode(self): """Test sync function / sending group reads to KNX bus for controller mode.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode( xknx, "TestClimate", @@ -935,7 +935,7 @@ def test_sync_controller_mode(self): def test_sync_operation_mode_state(self): """Test sync function / sending group reads to KNX bus for multiple mode addresses.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode( xknx, "TestClimate", @@ -963,7 +963,7 @@ def test_sync_operation_mode_state(self): def test_sync_heat_cool(self): """Test sync function / sending group reads to KNX bus for heat/cool.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode( xknx, "TestClimate", @@ -982,7 +982,7 @@ def test_sync_heat_cool(self): # def test_process_temperature(self): """Test process / reading telegrams from telegram queue. Test if temperature is processed correctly.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate = Climate(xknx, "TestClimate", group_address_temperature="1/2/3") telegram = Telegram(GroupAddress("1/2/3")) @@ -992,7 +992,7 @@ def test_process_temperature(self): def test_process_operation_mode(self): """Test process / reading telegrams from telegram queue. Test if operation mode is processed correctly.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode( xknx, "TestClimate", @@ -1014,7 +1014,7 @@ def test_process_operation_mode(self): def test_process_binary_operation_mode(self): """Test process / reading telegrams from telegram queue. Test binary operation mode is processed correctly.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode( xknx, "TestClimate", @@ -1067,7 +1067,7 @@ def test_process_binary_operation_mode(self): def test_process_controller_mode(self): """Test process / reading telegrams from telegram queue. Test if DPT20.105 controller mode is set correctly.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode( xknx, "TestClimate", group_address_controller_mode="1/2/5" ) @@ -1079,7 +1079,7 @@ def test_process_controller_mode(self): def test_process_controller_status_wrong_payload(self): """Test process wrong telegram for controller status (wrong payload type).""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode( xknx, "TestClimate", @@ -1092,7 +1092,7 @@ def test_process_controller_status_wrong_payload(self): def test_process_controller_status_payload_invalid_length(self): """Test process wrong telegram for controller status (wrong payload length).""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode( xknx, "TestClimate", @@ -1105,7 +1105,7 @@ def test_process_controller_status_payload_invalid_length(self): def test_process_operation_mode_wrong_payload(self): """Test process wrong telegram for operation mode (wrong payload type).""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode( xknx, "TestClimate", @@ -1118,7 +1118,7 @@ def test_process_operation_mode_wrong_payload(self): def test_process_operation_mode_payload_invalid_length(self): """Test process wrong telegram for operation mode (wrong payload length).""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode( xknx, "TestClimate", @@ -1132,7 +1132,7 @@ def test_process_operation_mode_payload_invalid_length(self): def test_process_callback_temp(self): """Test process / reading telegrams from telegram queue. Test if callback is executed when receiving temperature.""" # pylint: disable=no-self-use - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate = Climate(xknx, "TestClimate", group_address_temperature="1/2/3") after_update_callback = Mock() @@ -1150,7 +1150,7 @@ async def async_after_update_callback(device): def test_process_heat_cool(self): """Test process / reading telegrams from telegram queue. Test if heat/cool is set correctly.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode( xknx, "TestClimate", @@ -1173,7 +1173,7 @@ def test_process_heat_cool(self): # def test_supported_operation_modes(self): """Test get_supported_operation_modes with combined group address.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode( xknx, "TestClimate", group_address_operation_mode="1/2/5" ) @@ -1190,7 +1190,7 @@ def test_supported_operation_modes(self): def test_supported_operation_modes_controller_status(self): """Test get_supported_operation_modes with combined group address.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode( xknx, "TestClimate", group_address_controller_status="1/2/5" ) @@ -1206,13 +1206,13 @@ def test_supported_operation_modes_controller_status(self): def test_supported_operation_modes_no_mode(self): """Test get_supported_operation_modes no operation_modes supported.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode(xknx, "TestClimate") self.assertEqual(climate_mode.operation_modes, []) def test_supported_operation_modes_with_separate_addresses(self): """Test get_supported_operation_modes with separated group addresses.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode( xknx, "TestClimate", @@ -1233,7 +1233,7 @@ def test_supported_operation_modes_with_separate_addresses(self): def test_supported_operation_modes_only_night(self): """Test get_supported_operation_modes with only night mode supported.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode( xknx, "TestClimate", group_address_operation_mode_night="1/2/7" ) @@ -1250,7 +1250,7 @@ def test_supported_operation_modes_only_night(self): def test_supported_operation_modes_heat_cool(self): """Test get_supported_operation_modes with heat_cool group address.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode( xknx, "TestClimate", @@ -1265,7 +1265,7 @@ def test_supported_operation_modes_heat_cool(self): def test_custom_supported_operation_modes(self): """Test get_supported_operation_modes with custom mode.""" modes = [HVACOperationMode.STANDBY, HVACOperationMode.NIGHT] - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode( xknx, "TestClimate", @@ -1278,7 +1278,7 @@ def test_custom_supported_operation_modes_as_str(self): """Test get_supported_operation_modes with custom mode as str list.""" str_modes = ["Standby", "Frost Protection"] modes = [HVACOperationMode.STANDBY, HVACOperationMode.FROST_PROTECTION] - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode( xknx, "TestClimate", @@ -1289,7 +1289,7 @@ def test_custom_supported_operation_modes_as_str(self): def test_process_power_status(self): """Test process / reading telegrams from telegram queue. Test if DPT20.105 controller mode is set correctly.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate = Climate(xknx, "TestClimate", group_address_on_off="1/2/2") telegram = Telegram(GroupAddress("1/2/2")) telegram.payload = DPTBinary(1) @@ -1306,7 +1306,7 @@ def test_process_power_status(self): def test_power_on_off(self): """Test turn_on and turn_off functions.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate = Climate(xknx, "TestClimate", group_address_on_off="1/2/2") self.loop.run_until_complete(climate.turn_on()) _telegram = xknx.telegrams.get_nowait() diff --git a/test/devices_tests/cover_test.py b/test/devices_tests/cover_test.py index f5712be72..ac00f7044 100644 --- a/test/devices_tests/cover_test.py +++ b/test/devices_tests/cover_test.py @@ -29,7 +29,7 @@ def tearDown(self): # def test_supports_stop_true(self): """Test support_position_true.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover_short_stop = Cover( xknx, "Children.Venetian", @@ -48,7 +48,7 @@ def test_supports_stop_true(self): def test_supports_stop_false(self): """Test support_position_true.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "Children.Venetian", @@ -66,7 +66,7 @@ def test_supports_stop_false(self): def test_supports_position_true(self): """Test support_position_true.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "Children.Venetian", @@ -78,7 +78,7 @@ def test_supports_position_true(self): def test_supports_position_false(self): """Test support_position_true.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "Children.Venetian", @@ -89,7 +89,7 @@ def test_supports_position_false(self): def test_supports_angle_true(self): """Test support_position_true.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "Children.Venetian", @@ -101,7 +101,7 @@ def test_supports_angle_true(self): def test_support_angle_false(self): """Test support_position_true.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "Children.Venetian", @@ -115,7 +115,7 @@ def test_support_angle_false(self): # def test_sync(self): """Test sync function / sending group reads to KNX bus.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "TestCover", @@ -132,7 +132,7 @@ def test_sync(self): def test_sync_state(self): """Test sync function with explicit state address.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "TestCover", @@ -150,7 +150,7 @@ def test_sync_state(self): def test_sync_angle(self): """Test sync function for cover with angle.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "TestCover", @@ -172,7 +172,7 @@ def test_sync_angle(self): def test_sync_angle_state(self): """Test sync function with angle/explicit state.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "TestCover", @@ -193,7 +193,7 @@ def test_sync_angle_state(self): # def test_set_up(self): """Test moving cover to 'up' position.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "TestCover", @@ -215,7 +215,7 @@ def test_set_up(self): # def test_set_short_down(self): """Test moving cover to 'down' position.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "TestCover", @@ -236,7 +236,7 @@ def test_set_short_down(self): # def test_set_down_inverted(self): """Test moving cover to 'down' position.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "TestCover", @@ -258,7 +258,7 @@ def test_set_down_inverted(self): # def test_set_short_up(self): """Test moving cover 'short up'.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "TestCover", @@ -280,7 +280,7 @@ def test_set_short_up(self): # def test_set_up_inverted(self): """Test moving cover 'short up'.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "TestCover", @@ -303,7 +303,7 @@ def test_set_up_inverted(self): # def test_set_down(self): """Test moving cover 'short down'.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "TestCover", @@ -325,7 +325,7 @@ def test_set_down(self): # def test_stop(self): """Test stopping cover.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover_short_stop = Cover( xknx, "TestCover", @@ -362,7 +362,7 @@ def test_stop(self): # def test_position(self): """Test moving cover to absolute position.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "TestCover", @@ -380,7 +380,7 @@ def test_position(self): def test_position_without_position_address_up(self): """Test moving cover to absolute position - with no absolute positioning supported.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "TestCover", @@ -400,7 +400,7 @@ def test_position_without_position_address_up(self): def test_position_without_position_address_down(self): """Test moving cover down - with no absolute positioning supported.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "TestCover", @@ -419,7 +419,7 @@ def test_position_without_position_address_down(self): def test_position_without_position_address_uninitialized_up(self): """Test moving uninitialized cover to absolute position - with no absolute positioning supported.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "TestCover", @@ -444,7 +444,7 @@ def test_position_without_position_address_uninitialized_up(self): def test_position_without_position_address_uninitialized_down(self): """Test moving uninitialized cover to absolute position - with no absolute positioning supported.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "TestCover", @@ -470,7 +470,7 @@ def test_position_without_position_address_uninitialized_down(self): def test_angle(self): """Test changing angle.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "Children.Venetian", @@ -490,7 +490,7 @@ def test_angle(self): def test_angle_not_supported(self): """Test changing angle on cover wich does not support angle.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "Children.Venetian", @@ -509,7 +509,7 @@ def test_angle_not_supported(self): # def test_process_position(self): """Test process / reading telegrams from telegram queue. Test if position is processed correctly.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "TestCover", @@ -544,7 +544,7 @@ def test_process_position(self): def test_process_angle(self): """Test process / reading telegrams from telegram queue. Test if position is processed correctly.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "TestCover", @@ -559,7 +559,7 @@ def test_process_angle(self): def test_process_up(self): """Test process / reading telegrams from telegram queue. Test if up/down is processed correctly.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "TestCover", group_address_long="1/2/1", group_address_short="1/2/2" ) @@ -571,7 +571,7 @@ def test_process_up(self): def test_process_down(self): """Test process / reading telegrams from telegram queue. Test if up/down is processed correctly.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "TestCover", group_address_long="1/2/1", group_address_short="1/2/2" ) @@ -583,7 +583,7 @@ def test_process_down(self): def test_process_stop(self): """Test process / reading telegrams from telegram queue. Test if stop is processed correctly.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "TestCover", @@ -599,7 +599,7 @@ def test_process_stop(self): def test_process_short_stop(self): """Test process / reading telegrams from telegram queue. Test if stop is processed correctly.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "TestCover", @@ -616,7 +616,7 @@ def test_process_short_stop(self): def test_process_callback(self): """Test process / reading telegrams from telegram queue. Test if callback is executed.""" # pylint: disable=no-self-use - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "TestCover", @@ -662,7 +662,7 @@ async def async_after_update_callback(device): # def test_is_traveling(self): """Test moving cover to absolute position.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "TestCover", @@ -734,7 +734,7 @@ def test_is_traveling(self): # def test_auto_stop(self): """Test auto stop functionality.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "TestCover", @@ -774,7 +774,7 @@ def test_do(self): async def async_none(): return None - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover(xknx, "TestCover") with patch("xknx.devices.Cover.set_up") as mock: mock.return_value = asyncio.ensure_future(async_none()) @@ -799,7 +799,7 @@ async def async_none(): def test_wrong_do(self): """Test wrong do command.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover(xknx, "TestCover") with patch("logging.Logger.warning") as mock_warn: self.loop.run_until_complete(cover.do("execute")) @@ -813,7 +813,7 @@ def test_wrong_do(self): # def test_has_group_address(self): """Test sensor has group address.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, "TestCover", diff --git a/test/devices_tests/datetime_test.py b/test/devices_tests/datetime_test.py index a442a0041..fecea6990 100644 --- a/test/devices_tests/datetime_test.py +++ b/test/devices_tests/datetime_test.py @@ -27,7 +27,7 @@ def tearDown(self): # def test_sync_datetime(self): """Test sync function / sending group reads to KNX bus.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() datetime = DateTime( xknx, "TestDateTime", group_address="1/2/3", broadcast_type="DATETIME" ) @@ -54,7 +54,7 @@ def test_sync_datetime(self): # def test_sync_date(self): """Test sync function / sending group reads to KNX bus.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() datetime = DateTime( xknx, "TestDateTime", group_address="1/2/3", broadcast_type="DATE" ) @@ -78,7 +78,7 @@ def test_sync_date(self): # def test_sync_time(self): """Test sync function / sending group reads to KNX bus.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() datetime = DateTime( xknx, "TestDateTime", group_address="1/2/3", broadcast_type="TIME" ) @@ -105,7 +105,7 @@ def test_sync_time(self): # def test_process_read(self): """Test test process a read telegram from KNX bus.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() datetime = DateTime( xknx, "TestDateTime", group_address="1/2/3", broadcast_type="TIME" ) @@ -136,7 +136,7 @@ def test_process_read(self): # def test_has_group_address(self): """Test if has_group_address function works.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() datetime = DateTime( xknx, "TestDateTime", group_address="1/2/3", localtime=False ) diff --git a/test/devices_tests/device_test.py b/test/devices_tests/device_test.py index 36d069984..276030488 100644 --- a/test/devices_tests/device_test.py +++ b/test/devices_tests/device_test.py @@ -23,7 +23,7 @@ def tearDown(self): def test_device_updated_cb(self): """Test device updated cb is added to the device.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() after_update_callback = Mock() @@ -40,14 +40,14 @@ async def async_after_update_callback(device1): def test_iter_remote_value_raises_exception(self): """Test _iter_remote_value raises NotImplementedError.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() device = Device(xknx, "TestDevice") self.assertRaises(NotImplementedError, device._iter_remote_values) def test_process_callback(self): """Test process / reading telegrams from telegram queue. Test if callback was called.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() device = Device(xknx, "TestDevice") after_update_callback1 = Mock() @@ -94,7 +94,7 @@ async def async_after_update_callback2(device): def test_process(self): """Test if telegram is handled by the correct process_* method.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() device = Device(xknx, "TestDevice") with patch("xknx.devices.Device.process_group_read") as mock_group_read: @@ -135,7 +135,7 @@ def test_process(self): def test_sync_with_wait(self): """Test sync with wait_for_result=True.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "Sensor", group_address_state="1/2/3", value_type="wind_speed_ms" ) @@ -152,13 +152,13 @@ def test_sync_with_wait(self): def test_process_group_write(self): """Test if process_group_write. Nothing really to test here.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() device = Device(xknx, "TestDevice") self.loop.run_until_complete(device.process_group_write(Telegram())) def test_process_group_response(self): """Test if process_group_read. Testing if mapped to group_write.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() device = Device(xknx, "TestDevice") with patch("xknx.devices.Device.process_group_write") as mock_group_write: fut = asyncio.Future() @@ -170,13 +170,13 @@ def test_process_group_response(self): def test_process_group_read(self): """Test if process_group_read. Nothing really to test here.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() device = Device(xknx, "TestDevice") self.loop.run_until_complete(device.process_group_read(Telegram())) def test_do(self): """Testing empty do.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() device = Device(xknx, "TestDevice") with patch("logging.Logger.info") as mock_info: self.loop.run_until_complete(device.do("xx")) diff --git a/test/devices_tests/devices_test.py b/test/devices_tests/devices_test.py index 057ad852b..0b84a8bb7 100644 --- a/test/devices_tests/devices_test.py +++ b/test/devices_tests/devices_test.py @@ -26,7 +26,7 @@ def tearDown(self): # def test_get_item(self): """Test get item by name or by index.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light1 = Light(xknx, "Living-Room.Light_1", group_address_switch="1/6/7") @@ -54,7 +54,7 @@ def test_get_item(self): def test_device_by_group_address(self): """Test get devices by group address.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() devices = Devices() light1 = Light(xknx, "Living-Room.Light_1", group_address_switch="1/6/7") @@ -86,7 +86,7 @@ def test_device_by_group_address(self): def test_iter(self): """Test __iter__() function.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() devices = Devices() light1 = Light(xknx, "Living-Room.Light_1", group_address_switch="1/6/7") @@ -110,7 +110,7 @@ def test_iter(self): def test_len(self): """Test len() function.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() self.assertEqual(len(xknx.devices), 0) Light(xknx, "Living-Room.Light_1", group_address_switch="1/6/7") @@ -127,7 +127,7 @@ def test_len(self): def test_contains(self): """Test __contains__() function.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() Light(xknx, "Living-Room.Light_1", group_address_switch="1/6/7") @@ -139,7 +139,7 @@ def test_contains(self): def test_modification_of_device(self): """Test if devices object does store references and not copies of objects.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light1 = Light(xknx, "Living-Room.Light_1", group_address_switch="1/6/7") for device in xknx.devices: self.loop.run_until_complete(device.set_on()) @@ -160,7 +160,7 @@ def test_modification_of_device(self): def test_add_wrong_type(self): """Test if exception is raised when wrong type of devices is added.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() with self.assertRaises(TypeError): xknx.devices.add("fnord") @@ -169,7 +169,7 @@ def test_add_wrong_type(self): # def test_sync(self): """Test sync function.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() Device(xknx, "TestDevice1") Device(xknx, "TestDevice2") with patch("xknx.devices.Device.sync") as mock_sync: @@ -184,7 +184,7 @@ def test_sync(self): # def test_device_updated_callback(self): """Test if device updated callback is called correctly if device was updated.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() device1 = Device(xknx, "TestDevice1") device2 = Device(xknx, "TestDevice2") diff --git a/test/devices_tests/expose_sensor_test.py b/test/devices_tests/expose_sensor_test.py index ed9f761a3..2ebe79c6f 100644 --- a/test/devices_tests/expose_sensor_test.py +++ b/test/devices_tests/expose_sensor_test.py @@ -26,7 +26,7 @@ def tearDown(self): # def test_str_binary(self): """Test resolve state with binary sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() expose_sensor = ExposeSensor( xknx, "TestSensor", group_address="1/2/3", value_type="binary" ) @@ -37,7 +37,7 @@ def test_str_binary(self): def test_str_percent(self): """Test resolve state with percent sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() expose_sensor = ExposeSensor( xknx, "TestSensor", group_address="1/2/3", value_type="percent" ) @@ -48,7 +48,7 @@ def test_str_percent(self): def test_str_temperature(self): """Test resolve state with temperature sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() expose_sensor = ExposeSensor( xknx, "TestSensor", group_address="1/2/3", value_type="temperature" ) @@ -62,7 +62,7 @@ def test_str_temperature(self): # def test_set_binary(self): """Test set with binary sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() expose_sensor = ExposeSensor( xknx, "TestSensor", group_address="1/2/3", value_type="binary" ) @@ -78,7 +78,7 @@ def test_set_binary(self): def test_set_percent(self): """Test set with percent sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() expose_sensor = ExposeSensor( xknx, "TestSensor", group_address="1/2/3", value_type="percent" ) @@ -97,7 +97,7 @@ def test_set_percent(self): def test_set_temperature(self): """Test set with temperature sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() expose_sensor = ExposeSensor( xknx, "TestSensor", group_address="1/2/3", value_type="temperature" ) @@ -118,7 +118,7 @@ def test_set_temperature(self): # def test_process_binary(self): """Test reading binary expose sensor from bus.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() expose_sensor = ExposeSensor( xknx, "TestSensor", value_type="binary", group_address="1/2/3" ) @@ -140,7 +140,7 @@ def test_process_binary(self): def test_process_percent(self): """Test reading percent expose sensor from bus.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() expose_sensor = ExposeSensor( xknx, "TestSensor", value_type="percent", group_address="1/2/3" ) @@ -162,7 +162,7 @@ def test_process_percent(self): def test_process_temperature(self): """Test reading temperature expose sensor from bus.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() expose_sensor = ExposeSensor( xknx, "TestSensor", value_type="temperature", group_address="1/2/3" ) @@ -187,7 +187,7 @@ def test_process_temperature(self): # def test_has_group_address(self): """Test expose sensor has group address.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() expose_sensor = ExposeSensor( xknx, "TestSensor", value_type="temperature", group_address="1/2/3" ) @@ -200,7 +200,7 @@ def test_has_group_address(self): def test_process_callback(self): """Test setting value. Test if callback is called.""" # pylint: disable=no-self-use - xknx = XKNX(loop=self.loop) + xknx = XKNX() expose_sensor = ExposeSensor( xknx, "TestSensor", group_address="1/2/3", value_type="temperature" ) diff --git a/test/devices_tests/fan_test.py b/test/devices_tests/fan_test.py index 6661265b1..10440d743 100644 --- a/test/devices_tests/fan_test.py +++ b/test/devices_tests/fan_test.py @@ -29,7 +29,7 @@ def tearDown(self): # def test_sync(self): """Test sync function / sending group reads to KNX bus.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() fan = Fan(xknx, name="TestFan", group_address_speed_state="1/2/3") self.loop.run_until_complete(fan.sync()) @@ -45,7 +45,7 @@ def test_sync(self): # def test_sync_state_address(self): """Test sync function / sending group reads to KNX bus.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() fan = Fan( xknx, name="TestFan", @@ -67,7 +67,7 @@ def test_sync_state_address(self): # def test_set_speed(self): """Test setting the speed of a Fan.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() fan = Fan(xknx, name="TestFan", group_address_speed="1/2/3") self.loop.run_until_complete(fan.set_speed(55)) self.assertEqual(xknx.telegrams.qsize(), 1) @@ -82,7 +82,7 @@ def test_set_speed(self): # def test_process_speed(self): """Test process / reading telegrams from telegram queue. Test if speed is processed.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() fan = Fan(xknx, name="TestFan", group_address_speed="1/2/3") self.assertEqual(fan.current_speed, None) @@ -93,7 +93,7 @@ def test_process_speed(self): def test_process_speed_wrong_payload(self): # pylint: disable=invalid-name """Test process wrong telegrams. (wrong payload type).""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() fan = Fan(xknx, name="TestFan", group_address_speed="1/2/3") telegram = Telegram(GroupAddress("1/2/3"), payload=DPTBinary(1)) with self.assertRaises(CouldNotParseTelegram): @@ -102,7 +102,7 @@ def test_process_speed_wrong_payload(self): # pylint: disable=invalid-name def test_process_fan_payload_invalid_length(self): """Test process wrong telegrams. (wrong payload length).""" # pylint: disable=invalid-name - xknx = XKNX(loop=self.loop) + xknx = XKNX() fan = Fan(xknx, name="TestFan", group_address_speed="1/2/3") telegram = Telegram(GroupAddress("1/2/3"), payload=DPTArray((23, 24))) with self.assertRaises(CouldNotParseTelegram): @@ -113,7 +113,7 @@ def test_process_fan_payload_invalid_length(self): # def test_do(self): """Test 'do' functionality.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() fan = Fan(xknx, name="TestFan", group_address_speed="1/2/3") self.loop.run_until_complete(fan.do("speed:50")) self.loop.run_until_complete(xknx.devices.process(xknx.telegrams.get_nowait())) @@ -124,7 +124,7 @@ def test_do(self): def test_wrong_do(self): """Test wrong do command.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() fan = Fan(xknx, name="TestFan", group_address_speed="1/2/3") with patch("logging.Logger.warning") as mock_warn: self.loop.run_until_complete(fan.do("execute")) @@ -135,7 +135,7 @@ def test_wrong_do(self): def test_has_group_address(self): """Test has_group_address.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() fan = Fan( xknx, "TestFan", diff --git a/test/devices_tests/light_test.py b/test/devices_tests/light_test.py index a80c11c1c..239414ed1 100644 --- a/test/devices_tests/light_test.py +++ b/test/devices_tests/light_test.py @@ -29,7 +29,7 @@ def tearDown(self): # def test_supports_dimm_yes(self): """Test supports_dimm attribute with a light with dimmer.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, "Diningroom.Light_1", @@ -40,7 +40,7 @@ def test_supports_dimm_yes(self): def test_supports_dimm_no(self): """Test supports_dimm attribute with a Light without dimmer.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light(xknx, "Diningroom.Light_1", group_address_switch="1/6/4") self.assertFalse(light.supports_brightness) @@ -49,7 +49,7 @@ def test_supports_dimm_no(self): # def test_supports_color_true(self): """Test supports_color true.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, "Diningroom.Light_1", @@ -60,7 +60,7 @@ def test_supports_color_true(self): def test_supports_color_false(self): """Test supports_color false.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light(xknx, "Diningroom.Light_1", group_address_switch="1/6/4") self.assertFalse(light.supports_color) @@ -69,7 +69,7 @@ def test_supports_color_false(self): # def test_supports_rgbw_true(self): """Test supports_rgbw true.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, "Diningroom.Light_1", @@ -81,7 +81,7 @@ def test_supports_rgbw_true(self): def test_supports_rgbw_false(self): """Test supports_color false.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, "Diningroom.Light_1", @@ -95,7 +95,7 @@ def test_supports_rgbw_false(self): # def test_supports_tw_yes(self): """Test supports_tw attribute with a light with tunable white function.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, "Diningroom.Light_1", @@ -106,7 +106,7 @@ def test_supports_tw_yes(self): def test_supports_tw_no(self): """Test supports_tw attribute with a Light without tunable white function.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light(xknx, "Diningroom.Light_1", group_address_switch="1/6/4") self.assertFalse(light.supports_tunable_white) @@ -115,7 +115,7 @@ def test_supports_tw_no(self): # def test_supports_color_temp_true(self): """Test supports_color_temp attribute with a light with color temperature function.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, "Diningroom.Light_1", @@ -126,7 +126,7 @@ def test_supports_color_temp_true(self): def test_supports_color_temp_false(self): """Test supports_color_temp attribute with a Light without color temperature function.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light(xknx, "Diningroom.Light_1", group_address_switch="1/6/4") self.assertFalse(light.supports_color_temperature) @@ -135,7 +135,7 @@ def test_supports_color_temp_false(self): # def test_sync(self): """Test sync function / sending group reads to KNX bus. Testing with a Light without dimm functionality.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, name="TestLight", @@ -171,7 +171,7 @@ def test_sync(self): # def test_sync_state_address(self): """Test sync function / sending group reads to KNX bus. Testing with a Light with dimm functionality.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, name="TestLight", @@ -213,7 +213,7 @@ def test_sync_state_address(self): # def test_set_on(self): """Test switching on a Light.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, name="TestLight", @@ -232,7 +232,7 @@ def test_set_on(self): # def test_set_off(self): """Test switching off a Light.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, name="TestLight", @@ -251,7 +251,7 @@ def test_set_off(self): # def test_set_brightness(self): """Test setting the brightness of a Light.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, name="TestLight", @@ -268,7 +268,7 @@ def test_set_brightness(self): def test_set_brightness_not_dimmable(self): """Test setting the brightness of a non dimmable Light.""" # pylint: disable=invalid-name - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light(xknx, name="TestLight", group_address_switch="1/2/3") with patch("logging.Logger.warning") as mock_warn: self.loop.run_until_complete(light.set_brightness(23)) @@ -282,7 +282,7 @@ def test_set_brightness_not_dimmable(self): # def test_set_color(self): """Test setting the color of a Light.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, name="TestLight", @@ -301,7 +301,7 @@ def test_set_color(self): def test_set_color_not_possible(self): """Test setting the color of a non light without color.""" # pylint: disable=invalid-name - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light(xknx, name="TestLight", group_address_switch="1/2/3") with patch("logging.Logger.warning") as mock_warn: self.loop.run_until_complete(light.set_color((23, 24, 25))) @@ -315,7 +315,7 @@ def test_set_color_not_possible(self): # def test_set_color_rgbw(self): """Test setting RGBW value of a Light.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, name="TestLight", @@ -336,7 +336,7 @@ def test_set_color_rgbw(self): def test_set_color_rgbw_not_possible(self): """Test setting RGBW value of a non light without color.""" # pylint: disable=invalid-name - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, name="TestLight", @@ -356,7 +356,7 @@ def test_set_color_rgbw_not_possible(self): # def test_set_tw(self): """Test setting the tunable white value of a Light.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, name="TestLight", @@ -373,7 +373,7 @@ def test_set_tw(self): def test_set_tw_unsupported(self): """Test setting the tunable white value of a non tw Light.""" # pylint: disable=invalid-name - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light(xknx, name="TestLight", group_address_switch="1/2/3") with patch("logging.Logger.warning") as mock_warn: self.loop.run_until_complete(light.set_tunable_white(23)) @@ -387,7 +387,7 @@ def test_set_tw_unsupported(self): # def test_set_color_temp(self): """Test setting the color temperature value of a Light.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, name="TestLight", @@ -413,7 +413,7 @@ def test_set_color_temp(self): def test_set_color_temp_unsupported(self): """Test setting the color temperature value of an unsupported Light.""" # pylint: disable=invalid-name - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light(xknx, name="TestLight", group_address_switch="1/2/3") with patch("logging.Logger.warning") as mock_warn: self.loop.run_until_complete(light.set_color_temperature(4000)) @@ -427,7 +427,7 @@ def test_set_color_temp_unsupported(self): # def test_process_switch(self): """Test process / reading telegrams from telegram queue. Test if switch position is processed correctly.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, name="TestLight", @@ -447,7 +447,7 @@ def test_process_switch(self): def test_process_switch_callback(self): """Test process / reading telegrams from telegram queue. Test if callback is called.""" # pylint: disable=no-self-use - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, name="TestLight", @@ -470,7 +470,7 @@ async def async_after_update_callback(device): def test_process_dimm(self): """Test process / reading telegrams from telegram queue. Test if brightness is processed.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, name="TestLight", @@ -485,7 +485,7 @@ def test_process_dimm(self): def test_process_dimm_wrong_payload(self): """Test process wrong telegrams. (wrong payload type).""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, name="TestLight", @@ -499,7 +499,7 @@ def test_process_dimm_wrong_payload(self): def test_process_dimm_payload_invalid_length(self): """Test process wrong telegrams. (wrong payload length).""" # pylint: disable=invalid-name - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, name="TestLight", @@ -512,7 +512,7 @@ def test_process_dimm_payload_invalid_length(self): def test_process_color(self): """Test process / reading telegrams from telegram queue. Test if color is processed.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, name="TestLight", @@ -526,7 +526,7 @@ def test_process_color(self): def test_process_color_rgbw(self): """Test process / reading telegrams from telegram queue. Test if RGBW is processed.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, name="TestLight", @@ -543,7 +543,7 @@ def test_process_color_rgbw(self): def test_process_tunable_white(self): """Test process / reading telegrams from telegram queue. Test if tunable white is processed.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, name="TestLight", @@ -558,7 +558,7 @@ def test_process_tunable_white(self): def test_process_tunable_white_wrong_payload(self): """Test process wrong telegrams. (wrong payload type).""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, name="TestLight", @@ -572,7 +572,7 @@ def test_process_tunable_white_wrong_payload(self): def test_process_tunable_white_payload_invalid_length(self): """Test process wrong telegrams. (wrong payload length).""" # pylint: disable=invalid-name - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, name="TestLight", @@ -585,7 +585,7 @@ def test_process_tunable_white_payload_invalid_length(self): def test_process_color_temperature(self): """Test process / reading telegrams from telegram queue. Test if color temperature is processed.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, name="TestLight", @@ -608,7 +608,7 @@ def test_process_color_temperature(self): def test_process_color_temperature_wrong_payload(self): """Test process wrong telegrams. (wrong payload type).""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, name="TestLight", @@ -622,7 +622,7 @@ def test_process_color_temperature_wrong_payload(self): def test_process_color_temperature_payload_invalid_length(self): """Test process wrong telegrams. (wrong payload length).""" # pylint: disable=invalid-name - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, name="TestLight", @@ -638,7 +638,7 @@ def test_process_color_temperature_payload_invalid_length(self): # def test_do(self): """Test 'do' functionality.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, name="TestLight", @@ -665,7 +665,7 @@ def test_do(self): def test_wrong_do(self): """Test wrong do command.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, name="TestLight", @@ -681,7 +681,7 @@ def test_wrong_do(self): def test_has_group_address(self): """Test has_group_address.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, "Office.Light_1", diff --git a/test/devices_tests/notification_test.py b/test/devices_tests/notification_test.py index eb471ce9e..174f12b28 100644 --- a/test/devices_tests/notification_test.py +++ b/test/devices_tests/notification_test.py @@ -27,7 +27,7 @@ def tearDown(self): # def test_sync_state(self): """Test sync function / sending group reads to KNX bus.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() notification = Notification( xknx, "Warning", group_address="1/2/3", group_address_state="1/2/4" ) @@ -43,7 +43,7 @@ def test_sync_state(self): # def test_process(self): """Test process telegram with notification. Test if device was updated.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() notification = Notification(xknx, "Warning", group_address="1/2/3") telegram_set = Telegram( GroupAddress("1/2/3"), payload=DPTArray(DPTString().to_knx("Ein Prosit!")) @@ -60,7 +60,7 @@ def test_process(self): def test_process_callback(self): """Test process / reading telegrams from telegram queue. Test if callback was called.""" # pylint: disable=no-self-use - xknx = XKNX(loop=self.loop) + xknx = XKNX() notification = Notification(xknx, "Warning", group_address="1/2/3") after_update_callback = Mock() @@ -78,7 +78,7 @@ async def async_after_update_callback(device): def test_process_payload_invalid_length(self): """Test process wrong telegram (wrong payload length).""" # pylint: disable=invalid-name - xknx = XKNX(loop=self.loop) + xknx = XKNX() notification = Notification(xknx, "Warning", group_address="1/2/3") telegram = Telegram(GroupAddress("1/2/3"), payload=DPTArray((23, 24))) with self.assertRaises(CouldNotParseTelegram): @@ -86,7 +86,7 @@ def test_process_payload_invalid_length(self): def test_process_wrong_payload(self): """Test process wrong telegram (wrong payload type).""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() notification = Notification(xknx, "Warning", group_address="1/2/3") telegram = Telegram(GroupAddress("1/2/3"), payload=DPTBinary(1)) with self.assertRaises(CouldNotParseTelegram): @@ -97,7 +97,7 @@ def test_process_wrong_payload(self): # def test_set(self): """Test notificationing off notification.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() notification = Notification(xknx, "Warning", group_address="1/2/3") self.loop.run_until_complete(notification.set("Ein Prosit!")) self.assertEqual(xknx.telegrams.qsize(), 1) @@ -127,7 +127,7 @@ def test_set(self): # def test_do(self): """Test 'do' functionality.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() notification = Notification(xknx, "Warning", group_address="1/2/3") self.loop.run_until_complete(notification.do("message:Ein Prosit!")) self.loop.run_until_complete(xknx.devices.process(xknx.telegrams.get_nowait())) @@ -135,7 +135,7 @@ def test_do(self): def test_wrong_do(self): """Test wrong do command.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() notification = Notification(xknx, "Warning", group_address="1/2/3") with patch("logging.Logger.warning") as mock_warn: self.loop.run_until_complete(notification.do("execute")) @@ -149,7 +149,7 @@ def test_wrong_do(self): # def test_has_group_address(self): """Test has_group_address.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() notification = Notification( xknx, "Warning", group_address="1/2/3", group_address_state="1/2/4" ) diff --git a/test/devices_tests/scene_test.py b/test/devices_tests/scene_test.py index 2cce2cbe9..2daf43ce3 100644 --- a/test/devices_tests/scene_test.py +++ b/test/devices_tests/scene_test.py @@ -29,7 +29,7 @@ def tearDown(self): # def test_sync(self): """Test sync function / sending group reads to KNX bus.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() scene = Scene(xknx, "TestScene", group_address="1/2/1", scene_number=23) self.loop.run_until_complete(scene.sync()) self.assertEqual(xknx.telegrams.qsize(), 0) @@ -39,7 +39,7 @@ def test_sync(self): # def test_run(self): """Test running scene.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() scene = Scene(xknx, "TestScene", group_address="1/2/1", scene_number=23) self.loop.run_until_complete(scene.run()) self.assertEqual(xknx.telegrams.qsize(), 1) @@ -50,7 +50,7 @@ def test_run(self): def test_do(self): """Test running scene with do command.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() scene = Scene(xknx, "TestScene", group_address="1/2/1", scene_number=23) self.loop.run_until_complete(scene.do("run")) self.assertEqual(xknx.telegrams.qsize(), 1) @@ -61,7 +61,7 @@ def test_do(self): def test_wrong_do(self): """Test wrong do command.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() scene = Scene(xknx, "TestScene", group_address="1/2/1", scene_number=23) with patch("logging.Logger.warning") as mockWarn: self.loop.run_until_complete(scene.do("execute")) @@ -75,7 +75,7 @@ def test_wrong_do(self): # def test_has_group_address(self): """Test has_group_address.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() scene = Scene(xknx, "TestScene", group_address="1/2/1", scene_number=23) self.assertTrue(scene.has_group_address(GroupAddress("1/2/1"))) self.assertFalse(scene.has_group_address(GroupAddress("2/2/2"))) diff --git a/test/devices_tests/sensor_expose_loop_test.py b/test/devices_tests/sensor_expose_loop_test.py index 9f722e78a..0716b081b 100644 --- a/test/devices_tests/sensor_expose_loop_test.py +++ b/test/devices_tests/sensor_expose_loop_test.py @@ -1444,7 +1444,7 @@ def test_array_sensor_loop(self): for value_type, test_payload, test_value in test_cases: with self.subTest(value_type=value_type): - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor_%s" % value_type, @@ -1497,7 +1497,7 @@ def test_binary_sensor_loop(self): for value_type, test_payload, test_value in test_cases: with self.subTest(value_type=value_type): - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = BinarySensor( xknx, "TestSensor_%s" % value_type, group_address_state="1/1/1" ) diff --git a/test/devices_tests/sensor_test.py b/test/devices_tests/sensor_test.py index ca645f2f9..2043eb3c9 100644 --- a/test/devices_tests/sensor_test.py +++ b/test/devices_tests/sensor_test.py @@ -27,7 +27,7 @@ def tearDown(self): def test_str_absolute_temperature(self): """Test resolve state with absolute_temperature sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -49,7 +49,7 @@ def test_str_absolute_temperature(self): def test_str_acceleration(self): """Test resolve state with acceleration sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="acceleration" ) @@ -68,7 +68,7 @@ def test_str_acceleration(self): def test_str_volume_liquid_litre(self): """Test resolve state with volume liquid sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -90,7 +90,7 @@ def test_str_volume_liquid_litre(self): def test_str_volume_m3(self): """Test resolve state with volume m3 sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="volume_m3" ) @@ -109,7 +109,7 @@ def test_str_volume_m3(self): def test_str_acceleration_angular(self): """Test resolve state with acceleration_angular sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -131,7 +131,7 @@ def test_str_acceleration_angular(self): def test_str_activation_energy(self): """Test resolve state with activation_energy sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -153,7 +153,7 @@ def test_str_activation_energy(self): def test_str_active_energy(self): """Test resolve state with active_energy sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="active_energy" ) @@ -172,7 +172,7 @@ def test_str_active_energy(self): def test_str_active_energy_kwh(self): """Test resolve state with active_energy_kwh sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -194,7 +194,7 @@ def test_str_active_energy_kwh(self): def test_str_activity(self): """Test resolve state with activity sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="activity" ) @@ -213,7 +213,7 @@ def test_str_activity(self): def test_str_amplitude(self): """Test resolve state with amplitude sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="amplitude" ) @@ -232,7 +232,7 @@ def test_str_amplitude(self): def test_str_angle(self): """Test resolve state with angle sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="angle" ) @@ -244,7 +244,7 @@ def test_str_angle(self): def test_str_angle_deg(self): """Test resolve state with angle_deg sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="angle_deg" ) @@ -263,7 +263,7 @@ def test_str_angle_deg(self): def test_str_angle_rad(self): """Test resolve state with angle_rad sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="angle_rad" ) @@ -282,7 +282,7 @@ def test_str_angle_rad(self): def test_str_angular_frequency(self): """Test resolve state with angular_frequency sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -304,7 +304,7 @@ def test_str_angular_frequency(self): def test_str_angular_momentum(self): """Test resolve state with angular_momentum sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -326,7 +326,7 @@ def test_str_angular_momentum(self): def test_str_angular_velocity(self): """Test resolve state with angular_velocity sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -348,7 +348,7 @@ def test_str_angular_velocity(self): def test_str_apparant_energy(self): """Test resolve state with apparant_energy sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -370,7 +370,7 @@ def test_str_apparant_energy(self): def test_str_apparant_energy_kvah(self): """Test resolve state with apparant_energy_kvah sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -392,7 +392,7 @@ def test_str_apparant_energy_kvah(self): def test_str_area(self): """Test resolve state with area sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="area" ) @@ -411,7 +411,7 @@ def test_str_area(self): def test_str_brightness(self): """Test resolve state with brightness sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="brightness" ) @@ -428,7 +428,7 @@ def test_str_brightness(self): def test_str_capacitance(self): """Test resolve state with capacitance sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="capacitance" ) @@ -447,7 +447,7 @@ def test_str_capacitance(self): def test_str_charge_density_surface(self): """Test resolve state with charge_density_surface sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -469,7 +469,7 @@ def test_str_charge_density_surface(self): def test_str_charge_density_volume(self): """Test resolve state with charge_density_volume sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -491,7 +491,7 @@ def test_str_charge_density_volume(self): def test_str_color_temperature(self): """Test resolve state with color_temperature sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -511,7 +511,7 @@ def test_str_color_temperature(self): def test_str_common_temperature(self): """Test resolve state with common_temperature sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -533,7 +533,7 @@ def test_str_common_temperature(self): def test_str_compressibility(self): """Test resolve state with compressibility sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -555,7 +555,7 @@ def test_str_compressibility(self): def test_str_conductance(self): """Test resolve state with conductance sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="conductance" ) @@ -574,7 +574,7 @@ def test_str_conductance(self): def test_str_counter_pulses(self): """Test resolve state with counter_pulses sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="counter_pulses" ) @@ -586,7 +586,7 @@ def test_str_counter_pulses(self): def test_str_current(self): """Test resolve state with current sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="current" ) @@ -603,7 +603,7 @@ def test_str_current(self): def test_str_delta_time_hrs(self): """Test resolve state with delta_time_hrs sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="delta_time_hrs" ) @@ -620,7 +620,7 @@ def test_str_delta_time_hrs(self): def test_str_delta_time_min(self): """Test resolve state with delta_time_min sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="delta_time_min" ) @@ -637,7 +637,7 @@ def test_str_delta_time_min(self): def test_str_delta_time_ms(self): """Test resolve state with delta_time_ms sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="delta_time_ms" ) @@ -654,7 +654,7 @@ def test_str_delta_time_ms(self): def test_str_delta_time_sec(self): """Test resolve state with delta_time_sec sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="delta_time_sec" ) @@ -671,7 +671,7 @@ def test_str_delta_time_sec(self): def test_str_density(self): """Test resolve state with density sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="density" ) @@ -690,7 +690,7 @@ def test_str_density(self): def test_str_electrical_conductivity(self): """Test resolve state with electrical_conductivity sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -712,7 +712,7 @@ def test_str_electrical_conductivity(self): def test_str_electric_charge(self): """Test resolve state with electric_charge sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -734,7 +734,7 @@ def test_str_electric_charge(self): def test_str_electric_current(self): """Test resolve state with electric_current sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -756,7 +756,7 @@ def test_str_electric_current(self): def test_str_electric_current_density(self): """Test resolve state with electric_current_density sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -778,7 +778,7 @@ def test_str_electric_current_density(self): def test_str_electric_dipole_moment(self): """Test resolve state with electric_dipole_moment sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -800,7 +800,7 @@ def test_str_electric_dipole_moment(self): def test_str_electric_displacement(self): """Test resolve state with electric_displacement sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -822,7 +822,7 @@ def test_str_electric_displacement(self): def test_str_electric_field_strength(self): """Test resolve state with electric_field_strength sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -844,7 +844,7 @@ def test_str_electric_field_strength(self): def test_str_electric_flux(self): """Test resolve state with electric_flux sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="electric_flux" ) @@ -863,7 +863,7 @@ def test_str_electric_flux(self): def test_str_electric_flux_density(self): """Test resolve state with electric_flux_density sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -885,7 +885,7 @@ def test_str_electric_flux_density(self): def test_str_electric_polarization(self): """Test resolve state with electric_polarization sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -907,7 +907,7 @@ def test_str_electric_polarization(self): def test_str_electric_potential(self): """Test resolve state with electric_potential sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -929,7 +929,7 @@ def test_str_electric_potential(self): def test_str_electric_potential_difference(self): """Test resolve state with electric_potential_difference sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -951,7 +951,7 @@ def test_str_electric_potential_difference(self): def test_str_electromagnetic_moment(self): """Test resolve state with electromagnetic_moment sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -973,7 +973,7 @@ def test_str_electromagnetic_moment(self): def test_str_electromotive_force(self): """Test resolve state with electromotive_force sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -995,7 +995,7 @@ def test_str_electromotive_force(self): def test_str_energy(self): """Test resolve state with energy sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="energy" ) @@ -1014,7 +1014,7 @@ def test_str_energy(self): def test_str_enthalpy(self): """Test resolve state with enthalpy sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="enthalpy" ) @@ -1031,7 +1031,7 @@ def test_str_enthalpy(self): def test_str_flow_rate_m3h(self): """Test resolve state with flow_rate_m3h sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="flow_rate_m3h" ) @@ -1050,7 +1050,7 @@ def test_str_flow_rate_m3h(self): def test_str_force(self): """Test resolve state with force sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="force" ) @@ -1069,7 +1069,7 @@ def test_str_force(self): def test_str_frequency(self): """Test resolve state with frequency sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="frequency" ) @@ -1088,7 +1088,7 @@ def test_str_frequency(self): def test_str_heatcapacity(self): """Test resolve state with heatcapacity sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="heatcapacity" ) @@ -1107,7 +1107,7 @@ def test_str_heatcapacity(self): def test_str_heatflowrate(self): """Test resolve state with heatflowrate sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="heatflowrate" ) @@ -1126,7 +1126,7 @@ def test_str_heatflowrate(self): def test_str_heat_quantity(self): """Test resolve state with heat_quantity sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="heat_quantity" ) @@ -1145,7 +1145,7 @@ def test_str_heat_quantity(self): def test_str_humidity(self): """Test resolve state with humidity sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="humidity" ) @@ -1162,7 +1162,7 @@ def test_str_humidity(self): def test_str_impedance(self): """Test resolve state with impedance sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="impedance" ) @@ -1181,7 +1181,7 @@ def test_str_impedance(self): def test_str_illuminance(self): """Test resolve state with illuminance sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="illuminance" ) @@ -1198,7 +1198,7 @@ def test_str_illuminance(self): def test_str_kelvin_per_percent(self): """Test resolve state with kelvin_per_percent sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -1218,7 +1218,7 @@ def test_str_kelvin_per_percent(self): def test_str_length(self): """Test resolve state with length sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="length" ) @@ -1237,7 +1237,7 @@ def test_str_length(self): def test_str_length_mm(self): """Test resolve state with length_mm sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="length_mm" ) @@ -1254,7 +1254,7 @@ def test_str_length_mm(self): def test_str_light_quantity(self): """Test resolve state with light_quantity sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="light_quantity" ) @@ -1273,7 +1273,7 @@ def test_str_light_quantity(self): def test_str_long_delta_timesec(self): """Test resolve state with long_delta_timesec sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -1295,7 +1295,7 @@ def test_str_long_delta_timesec(self): def test_str_luminance(self): """Test resolve state with luminance sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="luminance" ) @@ -1314,7 +1314,7 @@ def test_str_luminance(self): def test_str_luminous_flux(self): """Test resolve state with luminous_flux sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="luminous_flux" ) @@ -1333,7 +1333,7 @@ def test_str_luminous_flux(self): def test_str_luminous_intensity(self): """Test resolve state with luminous_intensity sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -1355,7 +1355,7 @@ def test_str_luminous_intensity(self): def test_str_magnetic_field_strength(self): """Test resolve state with magnetic_field_strength sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -1377,7 +1377,7 @@ def test_str_magnetic_field_strength(self): def test_str_magnetic_flux(self): """Test resolve state with magnetic_flux sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="magnetic_flux" ) @@ -1396,7 +1396,7 @@ def test_str_magnetic_flux(self): def test_str_magnetic_flux_density(self): """Test resolve state with magnetic_flux_density sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -1418,7 +1418,7 @@ def test_str_magnetic_flux_density(self): def test_str_magnetic_moment(self): """Test resolve state with magnetic_moment sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -1440,7 +1440,7 @@ def test_str_magnetic_moment(self): def test_str_magnetic_polarization(self): """Test resolve state with magnetic_polarization sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -1462,7 +1462,7 @@ def test_str_magnetic_polarization(self): def test_str_magnetization(self): """Test resolve state with magnetization sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="magnetization" ) @@ -1481,7 +1481,7 @@ def test_str_magnetization(self): def test_str_magnetomotive_force(self): """Test resolve state with magnetomotive_force sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -1503,7 +1503,7 @@ def test_str_magnetomotive_force(self): def test_str_mass(self): """Test resolve state with mass sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="mass" ) @@ -1522,7 +1522,7 @@ def test_str_mass(self): def test_str_mass_flux(self): """Test resolve state with mass_flux sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="mass_flux" ) @@ -1541,7 +1541,7 @@ def test_str_mass_flux(self): def test_str_mol(self): """Test resolve state with mol sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="mol" ) @@ -1560,7 +1560,7 @@ def test_str_mol(self): def test_str_momentum(self): """Test resolve state with momentum sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="momentum" ) @@ -1579,7 +1579,7 @@ def test_str_momentum(self): def test_str_percent(self): """Test resolve state with percent sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="percent" ) @@ -1591,7 +1591,7 @@ def test_str_percent(self): def test_str_percent_u8(self): """Test resolve state with percentU8 sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="percentU8" ) @@ -1603,7 +1603,7 @@ def test_str_percent_u8(self): def test_str_percent_v8(self): """Test resolve state with percentV8 sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="percentV8" ) @@ -1615,7 +1615,7 @@ def test_str_percent_v8(self): def test_str_percent_v16(self): """Test resolve state with percentV16 sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="percentV16" ) @@ -1632,7 +1632,7 @@ def test_str_percent_v16(self): def test_str_phaseanglerad(self): """Test resolve state with phaseanglerad sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="phaseanglerad" ) @@ -1651,7 +1651,7 @@ def test_str_phaseanglerad(self): def test_str_phaseangledeg(self): """Test resolve state with phaseangledeg sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="phaseangledeg" ) @@ -1670,7 +1670,7 @@ def test_str_phaseangledeg(self): def test_str_power(self): """Test resolve state with power sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="power" ) @@ -1689,7 +1689,7 @@ def test_str_power(self): def test_str_power_2byte(self): """Test resolve state with power_2byte sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="power_2byte" ) @@ -1706,7 +1706,7 @@ def test_str_power_2byte(self): def test_str_power_density(self): """Test resolve state with power_density sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="power_density" ) @@ -1723,7 +1723,7 @@ def test_str_power_density(self): def test_str_powerfactor(self): """Test resolve state with powerfactor sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="powerfactor" ) @@ -1742,7 +1742,7 @@ def test_str_powerfactor(self): def test_str_ppm(self): """Test resolve state with ppm sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="ppm" ) @@ -1759,7 +1759,7 @@ def test_str_ppm(self): def test_str_pressure(self): """Test resolve state with pressure sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="pressure" ) @@ -1778,7 +1778,7 @@ def test_str_pressure(self): def test_str_pressure_2byte(self): """Test resolve state with pressure_2byte sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="pressure_2byte" ) @@ -1795,7 +1795,7 @@ def test_str_pressure_2byte(self): def test_str_pulse(self): """Test resolve state with pulse sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="pulse" ) @@ -1807,7 +1807,7 @@ def test_str_pulse(self): def test_str_rain_amount(self): """Test resolve state with rain_amount sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="rain_amount" ) @@ -1824,7 +1824,7 @@ def test_str_rain_amount(self): def test_str_reactance(self): """Test resolve state with reactance sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="reactance" ) @@ -1843,7 +1843,7 @@ def test_str_reactance(self): def test_str_reactive_energy(self): """Test resolve state with reactive_energy sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -1865,7 +1865,7 @@ def test_str_reactive_energy(self): def test_str_reactive_energy_kvarh(self): """Test resolve state with reactive_energy_kvarh sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -1887,7 +1887,7 @@ def test_str_reactive_energy_kvarh(self): def test_str_resistance(self): """Test resolve state with resistance sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="resistance" ) @@ -1906,7 +1906,7 @@ def test_str_resistance(self): def test_str_resistivity(self): """Test resolve state with resistivity sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="resistivity" ) @@ -1925,7 +1925,7 @@ def test_str_resistivity(self): def test_str_rotation_angle(self): """Test resolve state with rotation_angle sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="rotation_angle" ) @@ -1942,7 +1942,7 @@ def test_str_rotation_angle(self): def test_str_scene_number(self): """Test resolve state with scene_number sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="scene_number" ) @@ -1954,7 +1954,7 @@ def test_str_scene_number(self): def test_str_self_inductance(self): """Test resolve state with self_inductance sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -1976,7 +1976,7 @@ def test_str_self_inductance(self): def test_str_solid_angle(self): """Test resolve state with solid_angle sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="solid_angle" ) @@ -1995,7 +1995,7 @@ def test_str_solid_angle(self): def test_str_sound_intensity(self): """Test resolve state with sound_intensity sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -2017,7 +2017,7 @@ def test_str_sound_intensity(self): def test_str_speed(self): """Test resolve state with speed sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="speed" ) @@ -2036,7 +2036,7 @@ def test_str_speed(self): def test_str_stress(self): """Test resolve state with stress sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="stress" ) @@ -2055,7 +2055,7 @@ def test_str_stress(self): def test_str_surface_tension(self): """Test resolve state with surface_tension sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -2077,7 +2077,7 @@ def test_str_surface_tension(self): def test_str_temperature(self): """Test resolve state with temperature sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="temperature" ) @@ -2094,7 +2094,7 @@ def test_str_temperature(self): def test_str_temperature_a(self): """Test resolve state with temperature_a sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="temperature_a" ) @@ -2111,7 +2111,7 @@ def test_str_temperature_a(self): def test_str_temperature_difference(self): """Test resolve state with temperature_difference sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -2133,7 +2133,7 @@ def test_str_temperature_difference(self): def test_str_temperature_difference_2byte(self): """Test resolve state with temperature_difference_2byte sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -2153,7 +2153,7 @@ def test_str_temperature_difference_2byte(self): def test_str_temperature_f(self): """Test resolve state with temperature_f sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="temperature_f" ) @@ -2170,7 +2170,7 @@ def test_str_temperature_f(self): def test_str_thermal_capacity(self): """Test resolve state with thermal_capacity sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -2192,7 +2192,7 @@ def test_str_thermal_capacity(self): def test_str_thermal_conductivity(self): """Test resolve state with thermal_conductivity sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -2214,7 +2214,7 @@ def test_str_thermal_conductivity(self): def test_str_thermoelectric_power(self): """Test resolve state with thermoelectric_power sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -2236,7 +2236,7 @@ def test_str_thermoelectric_power(self): def test_str_time_1(self): """Test resolve state with time_1 sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="time_1" ) @@ -2253,7 +2253,7 @@ def test_str_time_1(self): def test_str_time_2(self): """Test resolve state with time_2 sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="time_2" ) @@ -2270,7 +2270,7 @@ def test_str_time_2(self): def test_str_time_period_100msec(self): """Test resolve state with time_period_100msec sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -2290,7 +2290,7 @@ def test_str_time_period_100msec(self): def test_str_time_period_10msec(self): """Test resolve state with time_period_10msec sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -2310,7 +2310,7 @@ def test_str_time_period_10msec(self): def test_str_time_period_hrs(self): """Test resolve state with time_period_hrs sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -2330,7 +2330,7 @@ def test_str_time_period_hrs(self): def test_str_time_period_min(self): """Test resolve state with time_period_min sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -2350,7 +2350,7 @@ def test_str_time_period_min(self): def test_str_time_period_msec(self): """Test resolve state with time_period_msec sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -2370,7 +2370,7 @@ def test_str_time_period_msec(self): def test_str_time_period_sec(self): """Test resolve state with time_period_sec sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", @@ -2390,7 +2390,7 @@ def test_str_time_period_sec(self): def test_str_time_seconds(self): """Test resolve state with time_seconds sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="time_seconds" ) @@ -2409,7 +2409,7 @@ def test_str_time_seconds(self): def test_str_torque(self): """Test resolve state with torque sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="torque" ) @@ -2428,7 +2428,7 @@ def test_str_torque(self): def test_str_voltage(self): """Test resolve state with voltage sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="voltage" ) @@ -2445,7 +2445,7 @@ def test_str_voltage(self): def test_str_volume(self): """Test resolve state with volume sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="volume" ) @@ -2464,7 +2464,7 @@ def test_str_volume(self): def test_str_volume_flow(self): """Test resolve state with volume_flow sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="volume_flow" ) @@ -2481,7 +2481,7 @@ def test_str_volume_flow(self): def test_str_volume_flux(self): """Test resolve state with volume_flux sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="volume_flux" ) @@ -2500,7 +2500,7 @@ def test_str_volume_flux(self): def test_str_weight(self): """Test resolve state with weight sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="weight" ) @@ -2519,7 +2519,7 @@ def test_str_weight(self): def test_str_work(self): """Test resolve state with work sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="work" ) @@ -2538,7 +2538,7 @@ def test_str_work(self): def test_str_wind_speed_ms(self): """Test resolve state with wind_speed_ms sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="wind_speed_ms" ) @@ -2555,7 +2555,7 @@ def test_str_wind_speed_ms(self): def test_str_wind_speed_kmh(self): """Test resolve state with wind_speed_kmh sensor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="wind_speed_kmh" ) @@ -2575,7 +2575,7 @@ def test_str_wind_speed_kmh(self): # def test_sync(self): """Test sync function / sending group reads to KNX bus.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", value_type="temperature", group_address_state="1/2/3" ) @@ -2594,7 +2594,7 @@ def test_sync(self): # def test_has_group_address(self): """Test sensor has group address.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", value_type="temperature", group_address_state="1/2/3" ) @@ -2606,7 +2606,7 @@ def test_has_group_address(self): # def test_process(self): """Test process / reading telegrams from telegram queue.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", value_type="temperature", group_address_state="1/2/3" ) @@ -2620,7 +2620,7 @@ def test_process(self): def test_process_callback(self): """Test process / reading telegrams from telegram queue. Test if callback is called.""" # pylint: disable=no-self-use - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, "TestSensor", group_address_state="1/2/3", value_type="temperature" ) diff --git a/test/devices_tests/switch_test.py b/test/devices_tests/switch_test.py index b503accfa..42f651b2f 100644 --- a/test/devices_tests/switch_test.py +++ b/test/devices_tests/switch_test.py @@ -26,7 +26,7 @@ def tearDown(self): # def test_sync(self): """Test sync function / sending group reads to KNX bus.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() switch = Switch(xknx, "TestOutlet", group_address_state="1/2/3") self.loop.run_until_complete(switch.sync()) @@ -39,7 +39,7 @@ def test_sync(self): def test_sync_state_address(self): """Test sync function / sending group reads to KNX bus. Test with Switch with explicit state address.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() switch = Switch( xknx, "TestOutlet", group_address="1/2/3", group_address_state="1/2/4" ) @@ -57,7 +57,7 @@ def test_sync_state_address(self): # def test_process(self): """Test process / reading telegrams from telegram queue. Test if device was updated.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() switch = Switch(xknx, "TestOutlet", group_address="1/2/3") self.assertEqual(switch.state, False) @@ -80,7 +80,7 @@ def test_process_callback(self): """Test process / reading telegrams from telegram queue. Test if callback was called.""" # pylint: disable=no-self-use - xknx = XKNX(loop=self.loop) + xknx = XKNX() switch = Switch(xknx, "TestOutlet", group_address="1/2/3") after_update_callback = Mock() @@ -101,7 +101,7 @@ async def async_after_update_callback(device): # def test_set_on(self): """Test switching on switch.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() switch = Switch(xknx, "TestOutlet", group_address="1/2/3") self.loop.run_until_complete(switch.set_on()) self.assertEqual(xknx.telegrams.qsize(), 1) @@ -115,7 +115,7 @@ def test_set_on(self): # def test_set_off(self): """Test switching off switch.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() switch = Switch(xknx, "TestOutlet", group_address="1/2/3") self.loop.run_until_complete(switch.set_off()) self.assertEqual(xknx.telegrams.qsize(), 1) @@ -129,7 +129,7 @@ def test_set_off(self): # def test_do(self): """Test 'do' functionality.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() switch = Switch(xknx, "TestOutlet", group_address="1/2/3") self.loop.run_until_complete(switch.do("on")) self.loop.run_until_complete(xknx.devices.process(xknx.telegrams.get_nowait())) @@ -140,7 +140,7 @@ def test_do(self): def test_wrong_do(self): """Test wrong do command.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() switch = Switch(xknx, "TestOutlet", group_address="1/2/3") with patch("logging.Logger.warning") as mock_warn: self.loop.run_until_complete(switch.do("execute")) @@ -154,7 +154,7 @@ def test_wrong_do(self): # def test_has_group_address(self): """Test has_group_address.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() switch = Switch(xknx, "TestOutlet", group_address="1/2/3") self.assertTrue(switch.has_group_address(GroupAddress("1/2/3"))) self.assertFalse(switch.has_group_address(GroupAddress("2/2/2"))) diff --git a/test/devices_tests/weather_test.py b/test/devices_tests/weather_test.py index 3051e0875..942aaeda6 100644 --- a/test/devices_tests/weather_test.py +++ b/test/devices_tests/weather_test.py @@ -24,7 +24,7 @@ def tearDown(self): def test_temperature(self): """Test resolve state with temperature.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() weather = Weather(name="weather", xknx=xknx, group_address_temperature="1/3/4") weather._temperature.payload = DPTArray((0x19, 0xA)) @@ -35,7 +35,7 @@ def test_temperature(self): def test_brightness(self): """Test resolve state for brightness east, west and south.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() weather: Weather = Weather( name="weather", xknx=xknx, @@ -77,7 +77,7 @@ def test_brightness(self): def test_pressure(self): """Test resolve state with pressure.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() weather = Weather(name="weather", xknx=xknx, group_address_air_pressure="1/3/4") weather._air_pressure.payload = DPTArray((0x6C, 0xAD)) @@ -87,7 +87,7 @@ def test_pressure(self): def test_humidity(self): """Test humidity.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() weather = Weather(name="weather", xknx=xknx, group_address_humidity="1/2/4") weather._humidity.payload = DPTArray( ( @@ -102,7 +102,7 @@ def test_humidity(self): def test_wind_speed(self): """Test wind speed received.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() weather: Weather = Weather( name="weather", xknx=xknx, group_address_brightness_east="1/3/8" ) @@ -120,7 +120,7 @@ def test_wind_speed(self): def test_state_lightning(self): """Test current_state returns lightning if wind alarm and rain alarm are true.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() weather: Weather = Weather( name="weather", xknx=xknx, @@ -135,7 +135,7 @@ def test_state_lightning(self): def test_state_snowy_rainy(self): """Test snow rain if frost alarm and rain alarm are true.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() weather: Weather = Weather( name="weather", xknx=xknx, @@ -150,7 +150,7 @@ def test_state_snowy_rainy(self): def test_wind_alarm(self): """Test basic state mapping.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() weather: Weather = Weather( name="weather", xknx=xknx, @@ -165,7 +165,7 @@ def test_wind_alarm(self): def test_rain_alarm(self): """Test basic state mapping.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() weather: Weather = Weather( name="weather", xknx=xknx, @@ -180,7 +180,7 @@ def test_rain_alarm(self): def test_cloudy_summer(self): """Test cloudy summer if illuminance matches defined interval.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() weather: Weather = Weather( name="weather", xknx=xknx, @@ -203,7 +203,7 @@ def test_cloudy_summer(self): def test_sunny_summer(self): """Test returns sunny condition if illuminance is in defined interval""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() weather: Weather = Weather( name="weather", xknx=xknx, @@ -227,7 +227,7 @@ def test_sunny_summer(self): def test_sunny_winter(self): """Test sunny winter if illuminance matches defined interval.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() weather: Weather = Weather( name="weather", xknx=xknx, @@ -250,7 +250,7 @@ def test_sunny_winter(self): def test_cloudy_winter(self): """Test cloudy winter if illuminance matches defined interval.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() weather: Weather = Weather( name="weather", xknx=xknx, @@ -274,7 +274,7 @@ def test_cloudy_winter(self): def test_day_night(self): """Test day night mapping.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() weather: Weather = Weather( name="weather", xknx=xknx, group_address_day_night="1/3/20" ) @@ -285,7 +285,7 @@ def test_day_night(self): def test_weather_default(self): """Test default state mapping.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() weather: Weather = Weather(name="weather", xknx=xknx) self.assertEqual(weather.ha_current_state(), WeatherCondition.exceptional) @@ -295,7 +295,7 @@ def test_weather_default(self): # def test_expose_sensor(self): """Test default state mapping.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() Weather( name="weather", xknx=xknx, @@ -323,7 +323,7 @@ def test_expose_sensor(self): # def test_iter_remote_values(self): """Test sensor has group address.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() weather = Weather( name="weather", xknx=xknx, @@ -341,7 +341,7 @@ def test_iter_remote_values(self): # def test_has_group_address(self): """Test sensor has group address.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() weather = Weather(name="weather", xknx=xknx, group_address_temperature="1/3/4") self.assertTrue(weather._temperature.has_group_address(GroupAddress("1/3/4"))) self.assertFalse(weather._temperature.has_group_address(GroupAddress("1/2/4"))) diff --git a/test/io_tests/connect_test.py b/test/io_tests/connect_test.py index d1324560b..7f322a20b 100644 --- a/test/io_tests/connect_test.py +++ b/test/io_tests/connect_test.py @@ -29,7 +29,7 @@ def tearDown(self): def test_connect(self): """Test connecting from KNX bus.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() udp_client = UDPClient(xknx, ("192.168.1.1", 0), ("192.168.1.2", 1234)) connect = Connect(xknx, udp_client) connect.timeout_in_seconds = 0 diff --git a/test/io_tests/connectionstate_test.py b/test/io_tests/connectionstate_test.py index 065dd4528..4c5a1336f 100644 --- a/test/io_tests/connectionstate_test.py +++ b/test/io_tests/connectionstate_test.py @@ -28,7 +28,7 @@ def tearDown(self): def test_connectionstate(self): """Test connectionstateing from KNX bus.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() communication_channel_id = 23 udp_client = UDPClient(xknx, ("192.168.1.1", 0), ("192.168.1.2", 1234)) connectionstate = ConnectionState(xknx, udp_client, communication_channel_id) diff --git a/test/io_tests/disconnect_test.py b/test/io_tests/disconnect_test.py index 97801e6ac..f602021e9 100644 --- a/test/io_tests/disconnect_test.py +++ b/test/io_tests/disconnect_test.py @@ -22,7 +22,7 @@ def tearDown(self): def test_disconnect(self): """Test disconnecting from KNX bus.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() communication_channel_id = 23 udp_client = UDPClient(xknx, ("192.168.1.1", 0), ("192.168.1.2", 1234)) disconnect = Disconnect(xknx, udp_client, communication_channel_id) diff --git a/test/io_tests/gateway_scanner_test.py b/test/io_tests/gateway_scanner_test.py index 1a27a1f0a..5c2146151 100644 --- a/test/io_tests/gateway_scanner_test.py +++ b/test/io_tests/gateway_scanner_test.py @@ -124,7 +124,7 @@ def test_gateway_scan_filter_match(self): def test_search_response_reception(self): """Test function of gateway scanner.""" # pylint: disable=protected-access - xknx = XKNX(loop=self.loop) + xknx = XKNX() gateway_scanner = GatewayScanner(xknx) test_search_response = fake_router_search_response(xknx) udp_client_mock = unittest.mock.create_autospec(UDPClient) @@ -141,7 +141,7 @@ def test_search_response_reception(self): def test_scan_timeout(self, netifaces_mock): """Test gateway scanner timeout.""" # pylint: disable=protected-access - xknx = XKNX(loop=self.loop) + xknx = XKNX() # No interface shall be found netifaces_mock.interfaces.return_value = [] @@ -164,7 +164,7 @@ def test_scan_timeout(self, netifaces_mock): def test_send_search_requests(self, _search_interface_mock, netifaces_mock): """Test finding all valid interfaces to send search requests to. No requests are sent.""" # pylint: disable=protected-access - xknx = XKNX(loop=self.loop) + xknx = XKNX() netifaces_mock.interfaces.return_value = self.fake_interfaces netifaces_mock.ifaddresses = lambda interface: self.fake_ifaddresses[interface] diff --git a/test/io_tests/request_response_test.py b/test/io_tests/request_response_test.py index 65521db58..bd43ebf11 100644 --- a/test/io_tests/request_response_test.py +++ b/test/io_tests/request_response_test.py @@ -21,7 +21,7 @@ def tearDown(self): def test_create_knxipframe_err(self): """Test if create_knxipframe of base class raises an exception.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() udp_client = UDPClient(xknx, ("192.168.1.1", 0), ("192.168.1.2", 1234)) request_response = RequestResponse(xknx, udp_client, DisconnectResponse) request_response.timeout_in_seconds = 0 diff --git a/test/io_tests/tunnelling_test.py b/test/io_tests/tunnelling_test.py index a31db5020..6f29ad1c1 100644 --- a/test/io_tests/tunnelling_test.py +++ b/test/io_tests/tunnelling_test.py @@ -25,7 +25,7 @@ def tearDown(self): def test_tunnelling(self): """Test tunnelling from KNX bus.""" # pylint: disable=too-many-locals - xknx = XKNX(loop=self.loop) + xknx = XKNX() communication_channel_id = 23 udp_client = UDPClient(xknx, ("192.168.1.1", 0), ("192.168.1.2", 1234)) telegram = Telegram(GroupAddress("1/2/3"), payload=DPTArray((0x1, 0x2, 0x3))) diff --git a/test/knxip_tests/body_test.py b/test/knxip_tests/body_test.py index 4cac8ec9b..f63e068fb 100644 --- a/test/knxip_tests/body_test.py +++ b/test/knxip_tests/body_test.py @@ -23,7 +23,7 @@ def tearDown(self): def test_warn_calculated_length(self): """Test correct warn message if calculated_length is missing.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() body = KNXIPBody(xknx) with patch("logging.Logger.warning") as mock_warn: body.calculated_length() @@ -33,7 +33,7 @@ def test_warn_calculated_length(self): def test_warn_to_knx(self): """Test correct warn message if to_knx is missing.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() body = KNXIPBody(xknx) with patch("logging.Logger.warning") as mock_warn: body.to_knx() @@ -43,7 +43,7 @@ def test_warn_to_knx(self): def test_warn_from_knx(self): """Test correct warn message if from_knx is missing.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() body = KNXIPBody(xknx) with patch("logging.Logger.warning") as mock_warn: body.from_knx((0x75, 0x0B, 0x1C, 0x17, 0x07, 0x18, 0x00, 0x00)) diff --git a/test/knxip_tests/connect_request_test.py b/test/knxip_tests/connect_request_test.py index c5fd00b47..8cf873d8c 100644 --- a/test/knxip_tests/connect_request_test.py +++ b/test/knxip_tests/connect_request_test.py @@ -57,7 +57,7 @@ def test_connect_request(self): 0x02, 0x00, ) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) knxipframe.from_knx(raw) @@ -111,7 +111,7 @@ def test_from_knx_wrong_length_of_cri(self): 0x02, 0x00, ) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) with self.assertRaises(CouldNotParseKNXIP): knxipframe.from_knx(raw) @@ -145,7 +145,7 @@ def test_from_knx_wrong_cri(self): 0x04, 0x02, ) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) with self.assertRaises(CouldNotParseKNXIP): knxipframe.from_knx(raw) diff --git a/test/knxip_tests/connect_response_test.py b/test/knxip_tests/connect_response_test.py index 52212dd2f..2c9ba7852 100644 --- a/test/knxip_tests/connect_response_test.py +++ b/test/knxip_tests/connect_response_test.py @@ -52,7 +52,7 @@ def test_connect_response(self): 0x11, 0xFF, ) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) knxipframe.from_knx(raw) self.assertTrue(isinstance(knxipframe.body, ConnectResponse)) @@ -101,7 +101,7 @@ def test_from_knx_wrong_crd(self): 0x11, 0xFF, ) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) with self.assertRaises(CouldNotParseKNXIP): knxipframe.from_knx(raw) @@ -128,7 +128,7 @@ def test_from_knx_wrong_crd2(self): 0x04, 0x04, ) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) with self.assertRaises(CouldNotParseKNXIP): knxipframe.from_knx(raw) @@ -136,7 +136,7 @@ def test_from_knx_wrong_crd2(self): def test_connect_response_connection_error(self): """Test parsing and streaming connection response KNX/IP packet with error.""" raw = (0x06, 0x10, 0x02, 0x06, 0x00, 0x08, 0x00, 0x24) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) knxipframe.from_knx(raw) self.assertTrue(isinstance(knxipframe.body, ConnectResponse)) diff --git a/test/knxip_tests/connectionstate_request_test.py b/test/knxip_tests/connectionstate_request_test.py index 2d12bac45..af5aa7371 100644 --- a/test/knxip_tests/connectionstate_request_test.py +++ b/test/knxip_tests/connectionstate_request_test.py @@ -41,7 +41,7 @@ def test_connection_state_request(self): 0xC3, 0xB4, ) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) knxipframe.from_knx(raw) @@ -63,7 +63,7 @@ def test_connection_state_request(self): def test_from_knx_wrong_info(self): """Test parsing and streaming wrong ConnectionStateRequest.""" raw = (0x06, 0x10, 0x02, 0x07, 0x00, 0x010) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) with self.assertRaises(CouldNotParseKNXIP): knxipframe.from_knx(raw) diff --git a/test/knxip_tests/connectionstate_response_test.py b/test/knxip_tests/connectionstate_response_test.py index 354ade8f8..92c283151 100644 --- a/test/knxip_tests/connectionstate_response_test.py +++ b/test/knxip_tests/connectionstate_response_test.py @@ -24,7 +24,7 @@ def tearDown(self): def test_disconnect_response(self): """Test parsing and streaming connection state response KNX/IP packet.""" raw = (0x06, 0x10, 0x02, 0x08, 0x00, 0x08, 0x15, 0x21) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) knxipframe.from_knx(raw) @@ -44,7 +44,7 @@ def test_disconnect_response(self): def test_from_knx_wrong_header(self): """Test parsing and streaming wrong ConnectionStateResponse (wrong header length).""" raw = (0x06, 0x10, 0x02, 0x08, 0x00, 0x08, 0x15) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) with self.assertRaises(CouldNotParseKNXIP): knxipframe.from_knx(raw) diff --git a/test/knxip_tests/disconnect_request_test.py b/test/knxip_tests/disconnect_request_test.py index f2ea5fdd5..71eea2057 100644 --- a/test/knxip_tests/disconnect_request_test.py +++ b/test/knxip_tests/disconnect_request_test.py @@ -41,7 +41,7 @@ def test_disconnect_request(self): 0xC3, 0xB4, ) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) knxipframe.from_knx(raw) @@ -63,7 +63,7 @@ def test_disconnect_request(self): def test_from_knx_wrong_length(self): """Test parsing and streaming wrong DisconnectRequest.""" raw = (0x06, 0x10, 0x02, 0x09, 0x00, 0x10) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) with self.assertRaises(CouldNotParseKNXIP): knxipframe.from_knx(raw) diff --git a/test/knxip_tests/disconnect_response_test.py b/test/knxip_tests/disconnect_response_test.py index 27dfdca16..b4b064be9 100644 --- a/test/knxip_tests/disconnect_response_test.py +++ b/test/knxip_tests/disconnect_response_test.py @@ -24,7 +24,7 @@ def tearDown(self): def test_disconnect_response(self): """Test parsing and streaming DisconnectResponse KNX/IP packet.""" raw = (0x06, 0x10, 0x02, 0x0A, 0x00, 0x08, 0x15, 0x25) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) knxipframe.from_knx(raw) @@ -46,7 +46,7 @@ def test_disconnect_response(self): def test_from_knx_wrong_length(self): """Test parsing and streaming wrong DisconnectResponse.""" raw = (0x06, 0x10, 0x02, 0x0A, 0x00, 0x08, 0x15) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) with self.assertRaises(CouldNotParseKNXIP): knxipframe.from_knx(raw) diff --git a/test/knxip_tests/header_test.py b/test/knxip_tests/header_test.py index 7843b21d1..7aed13042 100644 --- a/test/knxip_tests/header_test.py +++ b/test/knxip_tests/header_test.py @@ -24,7 +24,7 @@ def tearDown(self): def test_from_knx(self): """Test parsing and streaming wrong Header (wrong length byte).""" raw = (0x06, 0x10, 0x04, 0x21, 0x00, 0x0A) - xknx = XKNX(loop=self.loop) + xknx = XKNX() header = KNXIPHeader(xknx) self.assertEqual(header.from_knx(raw), 6) self.assertEqual(header.header_length, 6) @@ -36,7 +36,7 @@ def test_from_knx(self): def test_set_length(self): """Test setting length.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() header = KNXIPHeader(xknx) header.set_length(DisconnectRequest(xknx)) # 6 (header) + 2 + 8 (HPAI length) @@ -44,7 +44,7 @@ def test_set_length(self): def test_set_length_error(self): """Test setting length with wrong type.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() header = KNXIPHeader(xknx) with self.assertRaises(TypeError): header.set_length(2) @@ -52,7 +52,7 @@ def test_set_length_error(self): def test_from_knx_wrong_header(self): """Test parsing and streaming wrong Header (wrong length).""" raw = (0x06, 0x10, 0x04, 0x21, 0x00) - xknx = XKNX(loop=self.loop) + xknx = XKNX() header = KNXIPHeader(xknx) with self.assertRaises(CouldNotParseKNXIP): header.from_knx(raw) @@ -60,7 +60,7 @@ def test_from_knx_wrong_header(self): def test_from_knx_wrong_header2(self): """Test parsing and streaming wrong Header (wrong length byte).""" raw = (0x05, 0x10, 0x04, 0x21, 0x00, 0x0A) - xknx = XKNX(loop=self.loop) + xknx = XKNX() header = KNXIPHeader(xknx) with self.assertRaises(CouldNotParseKNXIP): header.from_knx(raw) @@ -68,7 +68,7 @@ def test_from_knx_wrong_header2(self): def test_from_knx_wrong_header3(self): """Test parsing and streaming wrong Header (wrong protocol version).""" raw = (0x06, 0x11, 0x04, 0x21, 0x00, 0x0A) - xknx = XKNX(loop=self.loop) + xknx = XKNX() header = KNXIPHeader(xknx) with self.assertRaises(CouldNotParseKNXIP): header.from_knx(raw) diff --git a/test/knxip_tests/knxip_test.py b/test/knxip_tests/knxip_test.py index 5b3a7c925..8e16826e1 100644 --- a/test/knxip_tests/knxip_test.py +++ b/test/knxip_tests/knxip_test.py @@ -23,7 +23,7 @@ def tearDown(self): def test_wrong_init(self): """Testing init method with wrong service_type_ident.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) with self.assertRaises(TypeError): knxipframe.init(23) @@ -49,7 +49,7 @@ def test_parsing_too_long_knxip(self): 0xB4, 0x00, ) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) with self.assertRaises(CouldNotParseKNXIP): knxipframe.from_knx(raw) diff --git a/test/knxip_tests/routing_indication_test.py b/test/knxip_tests/routing_indication_test.py index d62f696ee..e4631de1b 100644 --- a/test/knxip_tests/routing_indication_test.py +++ b/test/knxip_tests/routing_indication_test.py @@ -45,7 +45,7 @@ def test_from_knx(self): 0x40, 0xF0, ) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) knxipframe.from_knx(raw) @@ -80,7 +80,7 @@ def test_from_knx_to_knx(self): 0x40, 0xF0, ) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) knxipframe.from_knx(raw) @@ -92,7 +92,7 @@ def test_from_knx_to_knx(self): def test_telegram_set(self): """Test parsing and streaming CEMIFrame KNX/IP packet with DPTArray/DPTTime as payload.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) knxipframe.init(KNXIPServiceType.ROUTING_INDICATION) knxipframe.body.cemi.src_addr = PhysicalAddress("1.2.2") @@ -156,7 +156,7 @@ def test_telegram_get(self): 0x40, 0xF0, ) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) knxipframe.from_knx(raw) @@ -197,7 +197,7 @@ def test_EndTOEnd_group_write_binary_on(self): 0x00, 0x81, ) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) knxipframe.from_knx(raw) telegram = knxipframe.body.cemi.telegram @@ -236,7 +236,7 @@ def test_EndTOEnd_group_write_binary_off(self): 0x00, 0x80, ) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) knxipframe.from_knx(raw) telegram = knxipframe.body.cemi.telegram @@ -276,7 +276,7 @@ def test_EndTOEnd_group_write_1byte(self): 0x80, 0x65, ) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) knxipframe.from_knx(raw) telegram = knxipframe.body.cemi.telegram @@ -319,7 +319,7 @@ def test_EndTOEnd_group_write_2bytes(self): 0x07, 0xC1, ) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) knxipframe.from_knx(raw) telegram = knxipframe.body.cemi.telegram @@ -363,7 +363,7 @@ def test_EndTOEnd_group_read(self): 0x00, 0x00, ) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) knxipframe.from_knx(raw) telegram = knxipframe.body.cemi.telegram @@ -404,7 +404,7 @@ def test_EndTOEnd_group_response(self): 0x00, 0x41, ) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) knxipframe.from_knx(raw) telegram = knxipframe.body.cemi.telegram @@ -431,7 +431,7 @@ def test_maximum_apci(self): telegram = Telegram( group_address=GroupAddress(337), payload=DPTBinary(DPTBinary.APCI_MAX_VALUE) ) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) knxipframe.init(KNXIPServiceType.ROUTING_INDICATION) knxipframe.body.cemi.src_addr = PhysicalAddress("1.3.1") @@ -467,7 +467,7 @@ def test_maximum_apci(self): def test_from_knx_invalid_cemi(self): """Test parsing and streaming CEMIFrame KNX/IP packet with unsupported CEMICode.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() ri = RoutingIndication(xknx) self.assertEqual(11, ri.from_knx([43, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0])) diff --git a/test/knxip_tests/search_request_test.py b/test/knxip_tests/search_request_test.py index d86f8fa00..2ad0be8b3 100644 --- a/test/knxip_tests/search_request_test.py +++ b/test/knxip_tests/search_request_test.py @@ -38,7 +38,7 @@ def test_search_request(self): 0x0E, 0x57, ) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) knxipframe.from_knx(raw) diff --git a/test/knxip_tests/search_response_test.py b/test/knxip_tests/search_response_test.py index fe0c3046b..a8d7d6593 100644 --- a/test/knxip_tests/search_response_test.py +++ b/test/knxip_tests/search_response_test.py @@ -112,7 +112,7 @@ def test_search_response(self): 0x07, 0x01, ) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) self.assertEqual(knxipframe.from_knx(raw), 80) self.assertEqual(knxipframe.to_knx(), list(raw)) @@ -142,6 +142,6 @@ def test_search_response(self): def test_unknown_device_name(self): """Test device_name if no DIBDeviceInformation is present.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() search_response = SearchResponse(xknx) self.assertEqual(search_response.device_name, "UNKNOWN") diff --git a/test/knxip_tests/tunnelling_ack_test.py b/test/knxip_tests/tunnelling_ack_test.py index 3e4d2d039..df57439fb 100644 --- a/test/knxip_tests/tunnelling_ack_test.py +++ b/test/knxip_tests/tunnelling_ack_test.py @@ -24,7 +24,7 @@ def tearDown(self): def test_connect_request(self): """Test parsing and streaming tunneling ACK KNX/IP packet.""" raw = (0x06, 0x10, 0x04, 0x21, 0x00, 0x0A, 0x04, 0x2A, 0x17, 0x00) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) knxipframe.from_knx(raw) @@ -44,7 +44,7 @@ def test_connect_request(self): def test_from_knx_wrong_ack_information(self): """Test parsing and streaming wrong TunnellingAck (wrong length byte).""" raw = (0x06, 0x10, 0x04, 0x21, 0x00, 0x0A, 0x03, 0x2A, 0x17, 0x00) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) with self.assertRaises(CouldNotParseKNXIP): knxipframe.from_knx(raw) @@ -52,7 +52,7 @@ def test_from_knx_wrong_ack_information(self): def test_from_knx_wrong_ack_information2(self): """Test parsing and streaming wrong TunnellingAck (wrong length).""" raw = (0x06, 0x10, 0x04, 0x21, 0x00, 0x0A, 0x04, 0x2A, 0x17) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) with self.assertRaises(CouldNotParseKNXIP): knxipframe.from_knx(raw) diff --git a/test/knxip_tests/tunnelling_request_test.py b/test/knxip_tests/tunnelling_request_test.py index fefa76c61..d334b1cd3 100644 --- a/test/knxip_tests/tunnelling_request_test.py +++ b/test/knxip_tests/tunnelling_request_test.py @@ -48,7 +48,7 @@ def test_connect_request(self): 0x00, 0x81, ) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) knxipframe.from_knx(raw) @@ -75,7 +75,7 @@ def test_connect_request(self): def test_from_knx_wrong_header(self): """Test parsing and streaming wrong TunnellingRequest (wrong header length byte).""" raw = (0x06, 0x10, 0x04, 0x20, 0x00, 0x15, 0x03) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) with self.assertRaises(CouldNotParseKNXIP): knxipframe.from_knx(raw) @@ -83,7 +83,7 @@ def test_from_knx_wrong_header(self): def test_from_knx_wrong_header2(self): """Test parsing and streaming wrong TunnellingRequest (wrong header length).""" raw = (0x06, 0x10, 0x04, 0x20, 0x00, 0x15, 0x04) - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) with self.assertRaises(CouldNotParseKNXIP): knxipframe.from_knx(raw) diff --git a/test/remote_value_tests/remote_value_1count_test.py b/test/remote_value_tests/remote_value_1count_test.py index fbbec8b90..6a3ad382b 100644 --- a/test/remote_value_tests/remote_value_1count_test.py +++ b/test/remote_value_tests/remote_value_1count_test.py @@ -23,19 +23,19 @@ def tearDown(self): def test_to_knx(self): """Test to_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValue1Count(xknx) self.assertEqual(remote_value.to_knx(100), DPTArray((0x64,))) def test_from_knx(self): """Test from_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValue1Count(xknx) self.assertEqual(remote_value.from_knx(DPTArray((0x64,))), 100) def test_set(self): """Test setting value.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValue1Count(xknx, group_address=GroupAddress("1/2/3")) self.loop.run_until_complete(remote_value.set(100)) self.assertEqual(xknx.telegrams.qsize(), 1) @@ -56,7 +56,7 @@ def test_set(self): def test_process(self): """Test process telegram.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValue1Count(xknx, group_address=GroupAddress("1/2/3")) telegram = Telegram( group_address=GroupAddress("1/2/3"), payload=DPTArray((0x64,)) @@ -66,7 +66,7 @@ def test_process(self): def test_to_process_error(self): """Test process errornous telegram.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValue1Count(xknx, group_address=GroupAddress("1/2/3")) with self.assertRaises(CouldNotParseTelegram): telegram = Telegram( diff --git a/test/remote_value_tests/remote_value_climate_mode_test.py b/test/remote_value_tests/remote_value_climate_mode_test.py index 2fe0872c2..57fdae6c1 100644 --- a/test/remote_value_tests/remote_value_climate_mode_test.py +++ b/test/remote_value_tests/remote_value_climate_mode_test.py @@ -28,7 +28,7 @@ def tearDown(self): def test_to_knx_operation_mode(self): """Test to_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueClimateMode( xknx, climate_mode_type=RemoteValueClimateMode.ClimateModeType.HVAC_MODE ) @@ -38,7 +38,7 @@ def test_to_knx_operation_mode(self): def test_to_knx_binary(self): """Test to_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueBinaryOperationMode( xknx, operation_mode=HVACOperationMode.COMFORT ) @@ -49,7 +49,7 @@ def test_to_knx_binary(self): def test_from_knx_binary_error(self): """Test from_knx function with invalid payload.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueBinaryOperationMode( xknx, operation_mode=HVACOperationMode.COMFORT ) @@ -58,7 +58,7 @@ def test_from_knx_binary_error(self): def test_to_knx_heat_cool(self): """Test to_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueBinaryHeatCool( xknx, operation_mode=HVACOperationMode.HEAT ) @@ -67,7 +67,7 @@ def test_to_knx_heat_cool(self): def test_from_knx_operation_mode(self): """Test from_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueClimateMode( xknx, climate_mode_type=RemoteValueClimateMode.ClimateModeType.HVAC_MODE ) @@ -77,7 +77,7 @@ def test_from_knx_operation_mode(self): def test_from_knx_binary_heat_cool(self): """Test from_knx function with invalid payload.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueBinaryHeatCool( xknx, operation_mode=HVACOperationMode.HEAT ) @@ -86,13 +86,13 @@ def test_from_knx_binary_heat_cool(self): def test_from_knx_operation_mode_error(self): """Test from_knx function with invalid payload.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() with self.assertRaises(ConversionError): RemoteValueClimateMode(xknx, climate_mode_type=None) def test_from_knx_binary(self): """Test from_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueBinaryOperationMode( xknx, operation_mode=HVACOperationMode.COMFORT ) @@ -103,7 +103,7 @@ def test_from_knx_binary(self): def test_from_knx_heat_cool(self): """Test from_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueBinaryHeatCool( xknx, operation_mode=HVACOperationMode.HEAT ) @@ -114,25 +114,25 @@ def test_from_knx_heat_cool(self): def test_from_knx_unsupported_operation_mode(self): """Test from_knx function with unsupported operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() with self.assertRaises(ConversionError): RemoteValueBinaryHeatCool(xknx, operation_mode=HVACOperationMode.NODEM) def test_from_knx_unknown_operation_mode(self): """Test from_knx function with unsupported operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() with self.assertRaises(ConversionError): RemoteValueBinaryHeatCool(xknx, operation_mode=None) def test_supported_operation_modes_not_implemented(self): """Test from_knx function with unsupported operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() with self.assertRaises(NotImplementedError): _RemoteValueBinaryClimateMode.supported_operation_modes() def test_to_knx_error_operation_mode(self): """Test to_knx function with wrong parameter.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueClimateMode( xknx, climate_mode_type=RemoteValueClimateMode.ClimateModeType.HVAC_MODE ) @@ -143,7 +143,7 @@ def test_to_knx_error_operation_mode(self): def test_to_knx_error_binary(self): """Test to_knx function with wrong parameter.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueBinaryOperationMode( xknx, operation_mode=HVACOperationMode.NIGHT ) @@ -154,7 +154,7 @@ def test_to_knx_error_binary(self): def test_set_operation_mode(self): """Test setting value.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueClimateMode( xknx, group_address=GroupAddress("1/2/3"), @@ -177,7 +177,7 @@ def test_set_operation_mode(self): def test_set_binary(self): """Test setting value.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueBinaryOperationMode( xknx, group_address=GroupAddress("1/2/3"), @@ -200,7 +200,7 @@ def test_set_binary(self): def test_process_operation_mode(self): """Test process telegram.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueClimateMode( xknx, group_address=GroupAddress("1/2/3"), @@ -214,7 +214,7 @@ def test_process_operation_mode(self): def test_process_binary(self): """Test process telegram.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueBinaryOperationMode( xknx, group_address=GroupAddress("1/2/3"), @@ -228,7 +228,7 @@ def test_process_binary(self): def test_to_process_error_operation_mode(self): """Test process errornous telegram.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueClimateMode( xknx, group_address=GroupAddress("1/2/3"), @@ -253,7 +253,7 @@ def test_to_process_error_operation_mode(self): def test_to_process_error_heat_cool(self): """Test process errornous telegram.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueBinaryHeatCool( xknx, group_address=GroupAddress("1/2/3"), diff --git a/test/remote_value_tests/remote_value_color_rgb_test.py b/test/remote_value_tests/remote_value_color_rgb_test.py index e5d0f6a1f..57af5763c 100644 --- a/test/remote_value_tests/remote_value_color_rgb_test.py +++ b/test/remote_value_tests/remote_value_color_rgb_test.py @@ -23,7 +23,7 @@ def tearDown(self): def test_to_knx(self): """Test to_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueColorRGB(xknx) self.assertEqual( remote_value.to_knx((100, 101, 102)), DPTArray((0x64, 0x65, 0x66)) @@ -34,7 +34,7 @@ def test_to_knx(self): def test_from_knx(self): """Test from_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueColorRGB(xknx) self.assertEqual( remote_value.from_knx(DPTArray((0x64, 0x65, 0x66))), (100, 101, 102) @@ -42,7 +42,7 @@ def test_from_knx(self): def test_to_knx_error(self): """Test to_knx function with wrong parametern.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueColorRGB(xknx) with self.assertRaises(ConversionError): remote_value.to_knx((100, 101, 102, 103)) @@ -57,7 +57,7 @@ def test_to_knx_error(self): def test_set(self): """Test setting value.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueColorRGB(xknx, group_address=GroupAddress("1/2/3")) self.loop.run_until_complete(remote_value.set((100, 101, 102))) self.assertEqual(xknx.telegrams.qsize(), 1) @@ -76,7 +76,7 @@ def test_set(self): def test_process(self): """Test process telegram.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueColorRGB(xknx, group_address=GroupAddress("1/2/3")) telegram = Telegram( group_address=GroupAddress("1/2/3"), payload=DPTArray((0x64, 0x65, 0x66)) @@ -86,7 +86,7 @@ def test_process(self): def test_to_process_error(self): """Test process errornous telegram.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueColorRGB(xknx, group_address=GroupAddress("1/2/3")) with self.assertRaises(CouldNotParseTelegram): telegram = Telegram( diff --git a/test/remote_value_tests/remote_value_color_rgbw_test.py b/test/remote_value_tests/remote_value_color_rgbw_test.py index cb7944c25..d5eb2c2c5 100644 --- a/test/remote_value_tests/remote_value_color_rgbw_test.py +++ b/test/remote_value_tests/remote_value_color_rgbw_test.py @@ -23,7 +23,7 @@ def tearDown(self): def test_to_knx(self): """Test to_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueColorRGBW(xknx) input_list = [100, 101, 102, 127] input_tuple = (100, 101, 102, 127) @@ -37,7 +37,7 @@ def test_to_knx(self): def test_from_knx(self): """Test from_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueColorRGBW(xknx) self.assertEqual( remote_value.from_knx(DPTArray((0x64, 0x65, 0x66, 0x7F, 0x00, 0x00))), @@ -62,7 +62,7 @@ def test_from_knx(self): def test_to_knx_error(self): """Test to_knx function with wrong parametern.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueColorRGBW(xknx) with self.assertRaises(ConversionError): remote_value.to_knx((101, 102, 103)) @@ -85,7 +85,7 @@ def test_to_knx_error(self): def test_set(self): """Test setting value.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueColorRGBW(xknx, group_address=GroupAddress("1/2/3")) self.loop.run_until_complete(remote_value.set((100, 101, 102, 103))) self.assertEqual(xknx.telegrams.qsize(), 1) @@ -110,7 +110,7 @@ def test_set(self): def test_process(self): """Test process telegram.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueColorRGBW(xknx, group_address=GroupAddress("1/2/3")) telegram = Telegram( group_address=GroupAddress("1/2/3"), @@ -121,7 +121,7 @@ def test_process(self): def test_to_process_error(self): """Test process errornous telegram.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueColorRGBW(xknx, group_address=GroupAddress("1/2/3")) with self.assertRaises(CouldNotParseTelegram): telegram = Telegram( diff --git a/test/remote_value_tests/remote_value_datetime_test.py b/test/remote_value_tests/remote_value_datetime_test.py index c083a0712..c1b18ce48 100644 --- a/test/remote_value_tests/remote_value_datetime_test.py +++ b/test/remote_value_tests/remote_value_datetime_test.py @@ -30,13 +30,13 @@ def tearDown(self): def test_init_raises_keyerror(self): """Test init raises KeyError if not supported.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() with self.assertRaises(ConversionError): RemoteValueDateTime(xknx, value_type="trees_are_important") def test_from_knx(self): """Test parsing of RV with datetime object.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() rv = RemoteValueDateTime(xknx, value_type="datetime") self.assertEqual( rv.from_knx(DPTArray((0x75, 0x0B, 0x1C, 0x17, 0x07, 0x18, 0x20, 0x80))), @@ -45,14 +45,14 @@ def test_from_knx(self): def test_to_knx(self): """Testing date time object.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() rv = RemoteValueDateTime(xknx, value_type="datetime") array = rv.to_knx(time.strptime("2017-11-28 23:7:24", "%Y-%m-%d %H:%M:%S")) self.assertEqual(array.value, (0x75, 0x0B, 0x1C, 0x57, 0x07, 0x18, 0x20, 0x80)) def test_payload_valid(self): """Testing KNX/Byte representation of DPTDateTime object.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() rv = RemoteValueDateTime(xknx, value_type="datetime") self.assertTrue( rv.payload_valid(DPTArray((0x75, 0x0B, 0x1C, 0x57, 0x07, 0x18, 0x20, 0x80))) @@ -60,7 +60,7 @@ def test_payload_valid(self): def test_payload_invalid(self): """Testing KNX/Byte representation of DPTDateTime object.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() rv = RemoteValueDateTime(xknx, value_type="datetime") self.assertFalse( rv.payload_valid(DPTArray((0x0B, 0x1C, 0x57, 0x07, 0x18, 0x20, 0x80))) diff --git a/test/remote_value_tests/remote_value_dpt_2_byte_unsigned_test.py b/test/remote_value_tests/remote_value_dpt_2_byte_unsigned_test.py index b41eeeec1..7b67a870d 100644 --- a/test/remote_value_tests/remote_value_dpt_2_byte_unsigned_test.py +++ b/test/remote_value_tests/remote_value_dpt_2_byte_unsigned_test.py @@ -23,19 +23,19 @@ def tearDown(self): def test_to_knx(self): """Test to_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueDpt2ByteUnsigned(xknx) self.assertEqual(remote_value.to_knx(2571), DPTArray((0x0A, 0x0B))) def test_from_knx(self): """Test from_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueDpt2ByteUnsigned(xknx) self.assertEqual(remote_value.from_knx(DPTArray((0x0A, 0x0B))), 2571) def test_to_knx_error(self): """Test to_knx function with wrong parameters.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueDpt2ByteUnsigned(xknx) with self.assertRaises(ConversionError): remote_value.to_knx(65536) @@ -44,7 +44,7 @@ def test_to_knx_error(self): def test_set(self): """Test setting value.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueDpt2ByteUnsigned( xknx, group_address=GroupAddress("1/2/3") ) @@ -72,7 +72,7 @@ def test_set(self): def test_process(self): """Test process telegram.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueDpt2ByteUnsigned( xknx, group_address=GroupAddress("1/2/3") ) @@ -84,7 +84,7 @@ def test_process(self): def test_to_process_error(self): """Test process errornous telegram.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueDpt2ByteUnsigned( xknx, group_address=GroupAddress("1/2/3") ) diff --git a/test/remote_value_tests/remote_value_dpt_value_1_ucount_test.py b/test/remote_value_tests/remote_value_dpt_value_1_ucount_test.py index be8b857dd..3d1c56ae4 100644 --- a/test/remote_value_tests/remote_value_dpt_value_1_ucount_test.py +++ b/test/remote_value_tests/remote_value_dpt_value_1_ucount_test.py @@ -23,19 +23,19 @@ def tearDown(self): def test_to_knx(self): """Test to_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueDptValue1Ucount(xknx) self.assertEqual(remote_value.to_knx(10), DPTArray((0x0A,))) def test_from_knx(self): """Test from_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueDptValue1Ucount(xknx) self.assertEqual(remote_value.from_knx(DPTArray((0x0A,))), 10) def test_to_knx_error(self): """Test to_knx function with wrong parametern.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueDptValue1Ucount(xknx) with self.assertRaises(ConversionError): remote_value.to_knx(256) @@ -44,7 +44,7 @@ def test_to_knx_error(self): def test_set(self): """Test setting value.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueDptValue1Ucount( xknx, group_address=GroupAddress("1/2/3") ) @@ -63,7 +63,7 @@ def test_set(self): def test_process(self): """Test process telegram.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueDptValue1Ucount( xknx, group_address=GroupAddress("1/2/3") ) @@ -75,7 +75,7 @@ def test_process(self): def test_to_process_error(self): """Test process errornous telegram.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueDptValue1Ucount( xknx, group_address=GroupAddress("1/2/3") ) diff --git a/test/remote_value_tests/remote_value_scaling_test.py b/test/remote_value_tests/remote_value_scaling_test.py index ad7633c3f..5191546f6 100644 --- a/test/remote_value_tests/remote_value_scaling_test.py +++ b/test/remote_value_tests/remote_value_scaling_test.py @@ -130,6 +130,6 @@ def test_calc_100_200(self): def test_value_unit(self): """Test for the unit_of_measurement.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueScaling(xknx) self.assertEqual(remote_value.unit_of_measurement, "%") diff --git a/test/remote_value_tests/remote_value_scene_number_test.py b/test/remote_value_tests/remote_value_scene_number_test.py index 7a1400744..e16057e35 100644 --- a/test/remote_value_tests/remote_value_scene_number_test.py +++ b/test/remote_value_tests/remote_value_scene_number_test.py @@ -23,19 +23,19 @@ def tearDown(self): def test_to_knx(self): """Test to_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueSceneNumber(xknx) self.assertEqual(remote_value.to_knx(11), DPTArray((0x0A,))) def test_from_knx(self): """Test from_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueSceneNumber(xknx) self.assertEqual(remote_value.from_knx(DPTArray((0x0A,))), 11) def test_to_knx_error(self): """Test to_knx function with wrong parametern.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueSceneNumber(xknx) with self.assertRaises(ConversionError): remote_value.to_knx(100) @@ -44,7 +44,7 @@ def test_to_knx_error(self): def test_set(self): """Test setting value.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueSceneNumber(xknx, group_address=GroupAddress("1/2/3")) self.loop.run_until_complete(remote_value.set(11)) self.assertEqual(xknx.telegrams.qsize(), 1) @@ -61,7 +61,7 @@ def test_set(self): def test_process(self): """Test process telegram.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueSceneNumber(xknx, group_address=GroupAddress("1/2/3")) telegram = Telegram( group_address=GroupAddress("1/2/3"), payload=DPTArray((0x0A,)) @@ -71,7 +71,7 @@ def test_process(self): def test_to_process_error(self): """Test process errornous telegram.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueSceneNumber(xknx, group_address=GroupAddress("1/2/3")) with self.assertRaises(CouldNotParseTelegram): telegram = Telegram( diff --git a/test/remote_value_tests/remote_value_sensor_test.py b/test/remote_value_tests/remote_value_sensor_test.py index a756c1ff1..1eb6b655a 100644 --- a/test/remote_value_tests/remote_value_sensor_test.py +++ b/test/remote_value_tests/remote_value_sensor_test.py @@ -22,7 +22,7 @@ def tearDown(self): def test_wrong_value_type(self): """Test initializing with wrong value_type.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() with self.assertRaises(ConversionError): RemoteValueSensor(xknx=xknx, value_type="wrong_value_type") diff --git a/test/remote_value_tests/remote_value_step_test.py b/test/remote_value_tests/remote_value_step_test.py index 82c32902c..43a46f603 100644 --- a/test/remote_value_tests/remote_value_step_test.py +++ b/test/remote_value_tests/remote_value_step_test.py @@ -23,7 +23,7 @@ def tearDown(self): def test_to_knx(self): """Test to_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueStep(xknx) self.assertEqual( remote_value.to_knx(RemoteValueStep.Direction.INCREASE), DPTBinary(1) @@ -34,7 +34,7 @@ def test_to_knx(self): def test_from_knx(self): """Test from_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueStep(xknx) self.assertEqual( remote_value.from_knx(DPTBinary(1)), RemoteValueStep.Direction.INCREASE @@ -45,7 +45,7 @@ def test_from_knx(self): def test_to_knx_invert(self): """Test to_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueStep(xknx, invert=True) self.assertEqual( remote_value.to_knx(RemoteValueStep.Direction.INCREASE), DPTBinary(0) @@ -56,7 +56,7 @@ def test_to_knx_invert(self): def test_from_knx_invert(self): """Test from_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueStep(xknx, invert=True) self.assertEqual( remote_value.from_knx(DPTBinary(1)), RemoteValueStep.Direction.DECREASE @@ -67,14 +67,14 @@ def test_from_knx_invert(self): def test_to_knx_error(self): """Test to_knx function with wrong parametern.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueStep(xknx) with self.assertRaises(ConversionError): remote_value.to_knx(1) def test_set(self): """Test setting value.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueStep(xknx, group_address=GroupAddress("1/2/3")) self.loop.run_until_complete(remote_value.decrease()) self.assertEqual(xknx.telegrams.qsize(), 1) @@ -91,7 +91,7 @@ def test_set(self): def test_process(self): """Test process telegram.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueStep(xknx, group_address=GroupAddress("1/2/3")) telegram = Telegram(group_address=GroupAddress("1/2/3"), payload=DPTBinary(0)) self.assertEqual(remote_value.value, None) @@ -100,7 +100,7 @@ def test_process(self): def test_to_process_error(self): """Test process errornous telegram.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueStep(xknx, group_address=GroupAddress("1/2/3")) with self.assertRaises(CouldNotParseTelegram): telegram = Telegram( diff --git a/test/remote_value_tests/remote_value_string_test.py b/test/remote_value_tests/remote_value_string_test.py index 908616791..45057f8c2 100644 --- a/test/remote_value_tests/remote_value_string_test.py +++ b/test/remote_value_tests/remote_value_string_test.py @@ -23,7 +23,7 @@ def tearDown(self): def test_to_knx(self): """Test to_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueString(xknx) self.assertEqual( remote_value.to_knx("KNX is OK"), @@ -49,7 +49,7 @@ def test_to_knx(self): def test_from_knx(self): """Test from_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueString(xknx) self.assertEqual( remote_value.from_knx( @@ -77,14 +77,14 @@ def test_from_knx(self): def test_to_knx_error(self): """Test to_knx function with wrong parametern.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueString(xknx) with self.assertRaises(ConversionError): remote_value.to_knx("123456789012345") def test_set(self): """Test setting value.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueString(xknx, group_address=GroupAddress("1/2/3")) self.loop.run_until_complete(remote_value.set("asdf")) self.assertEqual(xknx.telegrams.qsize(), 1) @@ -109,7 +109,7 @@ def test_set(self): def test_process(self): """Test process telegram.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueString(xknx, group_address=GroupAddress("1/2/3")) telegram = Telegram( group_address=GroupAddress("1/2/3"), @@ -137,7 +137,7 @@ def test_process(self): def test_to_process_error(self): """Test process errornous telegram.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueString(xknx, group_address=GroupAddress("1/2/3")) with self.assertRaises(CouldNotParseTelegram): telegram = Telegram( diff --git a/test/remote_value_tests/remote_value_switch_test.py b/test/remote_value_tests/remote_value_switch_test.py index 4060281f5..13d409f3c 100644 --- a/test/remote_value_tests/remote_value_switch_test.py +++ b/test/remote_value_tests/remote_value_switch_test.py @@ -23,42 +23,42 @@ def tearDown(self): def test_to_knx(self): """Test to_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueSwitch(xknx) self.assertEqual(remote_value.to_knx(True), DPTBinary(True)) self.assertEqual(remote_value.to_knx(False), DPTBinary(False)) def test_from_knx(self): """Test from_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueSwitch(xknx) self.assertEqual(remote_value.from_knx(DPTBinary(True)), True) self.assertEqual(remote_value.from_knx(DPTBinary(0)), False) def test_to_knx_invert(self): """Test to_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueSwitch(xknx, invert=True) self.assertEqual(remote_value.to_knx(True), DPTBinary(0)) self.assertEqual(remote_value.to_knx(False), DPTBinary(1)) def test_from_knx_invert(self): """Test from_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueSwitch(xknx, invert=True) self.assertEqual(remote_value.from_knx(DPTBinary(1)), False) self.assertEqual(remote_value.from_knx(DPTBinary(0)), True) def test_to_knx_error(self): """Test to_knx function with wrong parametern.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueSwitch(xknx) with self.assertRaises(ConversionError): remote_value.to_knx(1) def test_set(self): """Test setting value.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueSwitch(xknx, group_address=GroupAddress("1/2/3")) self.loop.run_until_complete(remote_value.on()) self.assertEqual(xknx.telegrams.qsize(), 1) @@ -75,7 +75,7 @@ def test_set(self): def test_process(self): """Test process telegram.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueSwitch(xknx, group_address=GroupAddress("1/2/3")) telegram = Telegram(group_address=GroupAddress("1/2/3"), payload=DPTBinary(1)) self.assertEqual(remote_value.value, None) @@ -85,7 +85,7 @@ def test_process(self): def test_process_off(self): """Test process OFF telegram.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueSwitch(xknx, group_address=GroupAddress("1/2/3")) telegram = Telegram(group_address=GroupAddress("1/2/3"), payload=DPTBinary(0)) self.assertEqual(remote_value.value, None) @@ -95,7 +95,7 @@ def test_process_off(self): def test_to_process_error(self): """Test process errornous telegram.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueSwitch(xknx, group_address=GroupAddress("1/2/3")) with self.assertRaises(CouldNotParseTelegram): telegram = Telegram( diff --git a/test/remote_value_tests/remote_value_test.py b/test/remote_value_tests/remote_value_test.py index 587412f57..d04153ccc 100644 --- a/test/remote_value_tests/remote_value_test.py +++ b/test/remote_value_tests/remote_value_test.py @@ -24,7 +24,7 @@ def tearDown(self): def test_warn_payload_valid(self): """Test for warning if payload_valid is not implemented.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValue(xknx) with patch("logging.Logger.warning") as mock_warn: remote_value.payload_valid(DPTBinary(0)) @@ -34,7 +34,7 @@ def test_warn_payload_valid(self): def test_warn_to_knx(self): """Test for warning if to_knx is not implemented.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValue(xknx) with patch("logging.Logger.warning") as mock_warn: remote_value.to_knx(23) @@ -44,7 +44,7 @@ def test_warn_to_knx(self): def test_warn_from_knx(self): """Test for warning if from_knx is not implemented.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValue(xknx) with patch("logging.Logger.warning") as mock_warn: remote_value.from_knx(DPTBinary(0)) @@ -54,7 +54,7 @@ def test_warn_from_knx(self): def test_info_set_uninitialized(self): """Test for info if RemoteValue is not initialized.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValue(xknx) with patch("logging.Logger.info") as mock_info: self.loop.run_until_complete(remote_value.set(23)) @@ -67,7 +67,7 @@ def test_info_set_uninitialized(self): def test_info_set_unwritable(self): """Test for warning if RemoteValue is read only.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValue(xknx, group_address_state=GroupAddress("1/2/3")) with patch("logging.Logger.warning") as mock_info: self.loop.run_until_complete(remote_value.set(23)) @@ -80,13 +80,13 @@ def test_info_set_unwritable(self): def test_default_value_unit(self): """Test for the default value of unit_of_measurement.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValue(xknx) self.assertEqual(remote_value.unit_of_measurement, None) def test_process_invalid_payload(self): """Test if exception is raised when processing telegram with invalid payload.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValue(xknx) with patch("xknx.remote_value.RemoteValue.payload_valid") as patch_valid, patch( "xknx.remote_value.RemoteValue.has_group_address" @@ -100,7 +100,7 @@ def test_process_invalid_payload(self): def test_read_state(self): """Test read state while waiting for the result.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueSwitch(xknx, group_address_state="1/2/3") with patch("xknx.remote_value.RemoteValue.payload_valid") as patch_valid, patch( @@ -119,7 +119,7 @@ def test_read_state(self): def test_read_state_none(self): """Test read state while waiting for the result but got None.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueSwitch(xknx, group_address_state="1/2/3") with patch("xknx.remote_value.RemoteValue.payload_valid") as patch_valid, patch( @@ -141,7 +141,7 @@ def test_read_state_none(self): def test_eq(self): """Test __eq__ operator.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value1 = RemoteValue(xknx, group_address=GroupAddress("1/1/1")) remote_value2 = RemoteValue(xknx, group_address=GroupAddress("1/1/1")) remote_value3 = RemoteValue(xknx, group_address=GroupAddress("1/1/2")) diff --git a/test/remote_value_tests/remote_value_updown_test.py b/test/remote_value_tests/remote_value_updown_test.py index b53603e81..74653130e 100644 --- a/test/remote_value_tests/remote_value_updown_test.py +++ b/test/remote_value_tests/remote_value_updown_test.py @@ -23,7 +23,7 @@ def tearDown(self): def test_to_knx(self): """Test to_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueUpDown(xknx) self.assertEqual( remote_value.to_knx(RemoteValueUpDown.Direction.UP), DPTBinary(0) @@ -34,7 +34,7 @@ def test_to_knx(self): def test_from_knx(self): """Test from_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueUpDown(xknx) self.assertEqual( remote_value.from_knx(DPTBinary(0)), RemoteValueUpDown.Direction.UP @@ -45,7 +45,7 @@ def test_from_knx(self): def test_to_knx_invert(self): """Test to_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueUpDown(xknx, invert=True) self.assertEqual( remote_value.to_knx(RemoteValueUpDown.Direction.UP), DPTBinary(1) @@ -56,7 +56,7 @@ def test_to_knx_invert(self): def test_from_knx_invert(self): """Test from_knx function with normal operation.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueUpDown(xknx, invert=True) self.assertEqual( remote_value.from_knx(DPTBinary(0)), RemoteValueUpDown.Direction.DOWN @@ -67,14 +67,14 @@ def test_from_knx_invert(self): def test_to_knx_error(self): """Test to_knx function with wrong parametern.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueUpDown(xknx) with self.assertRaises(ConversionError): remote_value.to_knx(1) def test_set(self): """Test setting value.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueUpDown(xknx, group_address=GroupAddress("1/2/3")) self.loop.run_until_complete(remote_value.down()) self.assertEqual(xknx.telegrams.qsize(), 1) @@ -91,7 +91,7 @@ def test_set(self): def test_process(self): """Test process telegram.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueUpDown(xknx, group_address=GroupAddress("1/2/3")) telegram = Telegram(group_address=GroupAddress("1/2/3"), payload=DPTBinary(1)) self.assertEqual(remote_value.value, None) @@ -100,7 +100,7 @@ def test_process(self): def test_to_process_error(self): """Test process errornous telegram.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValueUpDown(xknx, group_address=GroupAddress("1/2/3")) with self.assertRaises(CouldNotParseTelegram): telegram = Telegram( diff --git a/test/str_test.py b/test/str_test.py index dc0e02216..a1b3260ba 100644 --- a/test/str_test.py +++ b/test/str_test.py @@ -73,7 +73,7 @@ def tearDown(self): def test_remote_value(self): """Test string representation of remote value.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() remote_value = RemoteValue( xknx, group_address="1/2/3", @@ -93,7 +93,7 @@ def test_remote_value(self): def test_binary_sensor(self): """Test string representation of binary sensor object.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() binary_sensor = BinarySensor( xknx, name="Fnord", group_address_state="1/2/3", device_class="motion" ) @@ -104,7 +104,7 @@ def test_binary_sensor(self): def test_climate(self): """Test string representation of climate object.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate = Climate( xknx, name="Wohnzimmer", @@ -129,7 +129,7 @@ def test_climate(self): def test_climate_mode(self): """Test string representation of climate mode object.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() climate_mode = ClimateMode( xknx, name="Wohnzimmer Mode", @@ -153,7 +153,7 @@ def test_climate_mode(self): def test_cover(self): """Test string representation of cover object.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cover = Cover( xknx, name="Rolladen", @@ -177,7 +177,7 @@ def test_cover(self): def test_fan(self): """Test string representation of fan object.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() fan = Fan( xknx, name="Dunstabzug", @@ -191,7 +191,7 @@ def test_fan(self): def test_light(self): """Test string representation of non dimmable light object.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, name="Licht", @@ -205,7 +205,7 @@ def test_light(self): def test_light_dimmable(self): """Test string representation of dimmable light object.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, name="Licht", @@ -222,7 +222,7 @@ def test_light_dimmable(self): def test_light_color(self): """Test string representation of dimmable light object.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() light = Light( xknx, name="Licht", @@ -240,7 +240,7 @@ def test_light_color(self): def test_notification(self): """Test string representation of notification object.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() notification = Notification( xknx, name="Alarm", group_address="1/2/3", group_address_state="1/2/4" ) @@ -261,7 +261,7 @@ def test_notification(self): def test_scene(self): """Test string representation of scene object.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() scene = Scene(xknx, name="Romantic", group_address="1/2/3", scene_number=23) self.assertEqual( str(scene), @@ -270,7 +270,7 @@ def test_scene(self): def test_sensor(self): """Test string representation of sensor object.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = Sensor( xknx, name="MeinSensor", group_address_state="1/2/3", value_type="percent" ) @@ -292,7 +292,7 @@ def test_sensor(self): def test_expose_sensor(self): """Test string representation of expose sensor object.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() sensor = ExposeSensor( xknx, name="MeinSensor", group_address="1/2/3", value_type="percent" ) @@ -309,7 +309,7 @@ def test_expose_sensor(self): def test_switch(self): """Test string representation of switch object.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() switch = Switch( xknx, name="Schalter", group_address="1/2/3", group_address_state="1/2/4" ) @@ -320,7 +320,7 @@ def test_switch(self): def test_weather(self): """Test string representation of switch object.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() weather = Weather( xknx, "Home", @@ -369,7 +369,7 @@ def test_weather(self): def test_datetime(self): """Test string representation of datetime object.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() dateTime = DateTime(xknx, name="Zeit", group_address="1/2/3", localtime=False) self.assertEqual( str(dateTime), @@ -378,13 +378,13 @@ def test_datetime(self): def test_action_base(self): """Test string representation of action base.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() action_base = ActionBase(xknx, hook="off", counter="2") self.assertEqual(str(action_base), '') def test_action(self): """Test string representation of action.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() action = Action(xknx, hook="on", target="Licht1", method="off", counter=2) self.assertEqual( str(action), @@ -393,7 +393,7 @@ def test_action(self): def test_action_callback(self): """Test string representation of action callback.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() def cb(): # noqa: D401 """Callback.""" @@ -526,7 +526,7 @@ def test_hpai(self): def test_header(self): """Test string representation of KNX/IP-Header.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() header = KNXIPHeader(xknx) header.total_length = 42 self.assertEqual( @@ -537,7 +537,7 @@ def test_header(self): def test_connect_request(self): """Test string representation of KNX/IP ConnectRequest.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() connect_request = ConnectRequest(xknx) connect_request.request_type = ConnectRequestType.TUNNEL_CONNECTION connect_request.control_endpoint = HPAI(ip_addr="192.168.42.1", port=33941) @@ -550,7 +550,7 @@ def test_connect_request(self): def test_connect_response(self): """Test string representatoin of KNX/IP ConnectResponse.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() connect_response = ConnectResponse(xknx) connect_response.communication_channel = 13 connect_response.request_type = ConnectRequestType.TUNNEL_CONNECTION @@ -564,7 +564,7 @@ def test_connect_response(self): def test_disconnect_request(self): """Test string representation of KNX/IP DisconnectRequest.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() disconnect_request = DisconnectRequest(xknx) disconnect_request.communication_channel_id = 13 disconnect_request.control_endpoint = HPAI(ip_addr="192.168.42.1", port=33941) @@ -575,7 +575,7 @@ def test_disconnect_request(self): def test_disconnect_response(self): """Test string representation of KNX/IP DisconnectResponse.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() disconnect_response = DisconnectResponse(xknx) disconnect_response.communication_channel_id = 23 self.assertEqual( @@ -585,7 +585,7 @@ def test_disconnect_response(self): def test_connectionstate_request(self): """Test string representation of KNX/IP ConnectionStateRequest.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() connectionstate_request = ConnectionStateRequest(xknx) connectionstate_request.communication_channel_id = 23 connectionstate_request.control_endpoint = HPAI( @@ -598,7 +598,7 @@ def test_connectionstate_request(self): def test_connectionstate_response(self): """Test string representation of KNX/IP ConnectionStateResponse.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() connectionstate_response = ConnectionStateResponse(xknx) connectionstate_response.communication_channel_id = 23 self.assertEqual( @@ -608,7 +608,7 @@ def test_connectionstate_response(self): def test_search_reqeust(self): """Test string representation of KNX/IP SearchRequest.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() search_request = SearchRequest(xknx) self.assertEqual( str(search_request), @@ -617,7 +617,7 @@ def test_search_reqeust(self): def test_search_response(self): """Test string representation of KNX/IP SearchResponse.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() search_response = SearchResponse(xknx) search_response.control_endpoint = HPAI(ip_addr="192.168.42.1", port=33941) search_response.dibs.append(DIBGeneric()) @@ -632,7 +632,7 @@ def test_search_response(self): def test_tunnelling_request(self): """Test string representation of KNX/IP TunnellingRequest.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() tunnelling_request = TunnellingRequest(xknx) tunnelling_request.communication_channel_id = 23 tunnelling_request.sequence_counter = 42 @@ -644,7 +644,7 @@ def test_tunnelling_request(self): def test_tunnelling_ack(self): """Test string representation of KNX/IP TunnellingAck.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() tunnelling_ack = TunnellingAck(xknx) tunnelling_ack.communication_channel_id = 23 tunnelling_ack.sequence_counter = 42 @@ -655,7 +655,7 @@ def test_tunnelling_ack(self): def test_cemi_frame(self): """Test string representation of KNX/IP CEMI Frame.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() cemi_frame = CEMIFrame(xknx) cemi_frame.src_addr = GroupAddress("1/2/3") cemi_frame.telegram = Telegram( @@ -669,7 +669,7 @@ def test_cemi_frame(self): def test_knxip_frame(self): """Test string representation of KNX/IP Frame.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() knxipframe = KNXIPFrame(xknx) knxipframe.init(KNXIPServiceType.SEARCH_REQUEST) self.assertEqual( @@ -703,7 +703,7 @@ def test_gateway_descriptor(self): # def test_routing_indication_str(self): """Test string representation of GatewayDescriptor.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() ri = RoutingIndication(xknx) self.assertEqual( str(ri), diff --git a/test/xknx_test.py b/test/xknx_test.py index f265200d9..5facb2225 100644 --- a/test/xknx_test.py +++ b/test/xknx_test.py @@ -32,7 +32,7 @@ def tearDown(self): def test_log_to_file(self): """Test logging enable.""" - XKNX(loop=self.loop, log_directory="/tmp/") + XKNX(log_directory="/tmp/") self.assertTrue(os.path.isfile("/tmp/xknx.log")) @@ -40,7 +40,7 @@ def test_log_to_file(self): def test_log_to_file_when_dir_does_not_exist(self): """Test logging enable with non existent directory.""" - XKNX(loop=self.loop, log_directory="/xknx/is/fun") + XKNX(log_directory="/xknx/is/fun") self.assertFalse(os.path.isfile("/xknx/is/fun/xknx.log")) @@ -50,7 +50,7 @@ def test_register_telegram_cb(self): async def telegram_received(telegram): """Telegram received.""" - xknx = XKNX(loop=self.loop, telegram_received_cb=telegram_received) + xknx = XKNX(telegram_received_cb=telegram_received) self.assertEqual(len(xknx.telegram_queue.telegram_received_cbs), 1) @@ -60,14 +60,14 @@ def test_register_device_cb(self): async def device_update(device): """Device updated.""" - xknx = XKNX(loop=self.loop, device_updated_cb=device_update) + xknx = XKNX(device_updated_cb=device_update) self.assertEqual(len(xknx.devices.device_updated_cbs), 1) @patch("xknx.io.KNXIPInterface.start", new_callable=AsyncMock) def test_xknx_start(self, start_mock): """Test xknx start.""" - xknx = XKNX(loop=self.loop, state_updater=True) + xknx = XKNX(state_updater=True) self.loop.run_until_complete(xknx.start()) @@ -79,7 +79,7 @@ def test_xknx_start_as_context_manager(self, ipinterface_mock): """Test xknx start.""" async def run_in_contextmanager(): - async with XKNX(loop=self.loop, state_updater=True) as xknx: + async with XKNX(state_updater=True) as xknx: self.assertTrue(xknx.started.is_set()) ipinterface_mock.assert_called_once() @@ -88,7 +88,7 @@ async def run_in_contextmanager(): @patch("xknx.io.KNXIPInterface.start", new_callable=AsyncMock) def test_xknx_start_and_stop_with_dedicated_connection_config(self, start_mock): """Test xknx start and stop with connection config.""" - xknx = XKNX(loop=self.loop) + xknx = XKNX() connection_config = ConnectionConfig(connection_type=ConnectionType.TUNNELING) xknx.connection_config = connection_config diff --git a/xknx/core/state_updater.py b/xknx/core/state_updater.py index bb2ccbaf2..f29021843 100644 --- a/xknx/core/state_updater.py +++ b/xknx/core/state_updater.py @@ -167,7 +167,7 @@ def start(self): def _start_waiting(self): """Start StateTracker - wait for value to expire.""" - self._task = self.xknx.loop.create_task(self._update_loop()) + self._task = asyncio.create_task(self._update_loop()) def stop(self): """Stop StateTracker.""" @@ -204,4 +204,4 @@ def _read_state(self): self.device_name, self.feature_name, ) - self.xknx.loop.create_task(self._read_state_awaitable()) + asyncio.create_task(self._read_state_awaitable()) diff --git a/xknx/core/value_reader.py b/xknx/core/value_reader.py index 22346ed58..6106b8fe0 100644 --- a/xknx/core/value_reader.py +++ b/xknx/core/value_reader.py @@ -76,9 +76,8 @@ def timeout(self): async def start_timeout(self): """Start timeout. Register callback for no answer received within timeout.""" - self.timeout_handle = self.xknx.loop.call_later( - self.timeout_in_seconds, self.timeout - ) + loop = asyncio.get_running_loop() + self.timeout_handle = loop.call_later(self.timeout_in_seconds, self.timeout) async def stop_timeout(self): """Stop timeout.""" diff --git a/xknx/devices/binary_sensor.py b/xknx/devices/binary_sensor.py index 70dcdaa96..d6f5175ce 100644 --- a/xknx/devices/binary_sensor.py +++ b/xknx/devices/binary_sensor.py @@ -115,7 +115,7 @@ async def _set_internal_state(self, state): if self.ignore_internal_state: if self._context_task: self._context_task.cancel() - self._context_task = self.xknx.loop.create_task( + self._context_task = asyncio.create_task( self._counter_task(self._context_timeout) ) else: @@ -179,7 +179,7 @@ async def process_group_write(self, telegram): if self.reset_after is not None and self.state: if self._reset_task: self._reset_task.cancel() - self._reset_task = self.xknx.loop.create_task( + self._reset_task = asyncio.create_task( self._reset_state(self.reset_after / 1000) ) diff --git a/xknx/devices/datetime.py b/xknx/devices/datetime.py index af7ddd886..70ed6088b 100644 --- a/xknx/devices/datetime.py +++ b/xknx/devices/datetime.py @@ -68,7 +68,8 @@ async def broadcast_loop(self, minutes: int): await asyncio.sleep(minutes * 60) if self.localtime: - return self.xknx.loop.create_task(broadcast_loop(self, minutes=minutes)) + loop = asyncio.get_event_loop() + return loop.create_task(broadcast_loop(self, minutes=minutes)) return None async def broadcast_localtime(self, response=False): diff --git a/xknx/io/gateway_scanner.py b/xknx/io/gateway_scanner.py index d5520aa84..42b8fc831 100644 --- a/xknx/io/gateway_scanner.py +++ b/xknx/io/gateway_scanner.py @@ -205,9 +205,8 @@ def _timeout(self): async def _start_timeout(self): """Start time out.""" - self._timeout_handle = self.xknx.loop.call_later( - self.timeout_in_seconds, self._timeout - ) + loop = asyncio.get_running_loop() + self._timeout_handle = loop.call_later(self.timeout_in_seconds, self._timeout) async def _stop_timeout(self): """Stop/cancel timeout.""" diff --git a/xknx/io/knxip_interface.py b/xknx/io/knxip_interface.py index 179ed9987..55ba0ae34 100644 --- a/xknx/io/knxip_interface.py +++ b/xknx/io/knxip_interface.py @@ -167,7 +167,7 @@ async def stop(self): def telegram_received(self, telegram): """Put received telegram into queue. Callback for having received telegram.""" - self.xknx.loop.create_task(self.xknx.telegrams.put(telegram)) + self.xknx.telegrams.put_nowait(telegram) async def send_telegram(self, telegram): """Send telegram to connected device (either Tunneling or Routing).""" diff --git a/xknx/io/request_response.py b/xknx/io/request_response.py index 2ca0322fb..d5a8e72f8 100644 --- a/xknx/io/request_response.py +++ b/xknx/io/request_response.py @@ -80,9 +80,8 @@ def timeout(self): async def start_timeout(self): """Start timeout.""" - self.timeout_handle = self.xknx.loop.call_later( - self.timeout_in_seconds, self.timeout - ) + loop = asyncio.get_running_loop() + self.timeout_handle = loop.call_later(self.timeout_in_seconds, self.timeout) async def stop_timeout(self): """Stop timeout.""" diff --git a/xknx/io/tunnel.py b/xknx/io/tunnel.py index 00ac6a229..34f5612d6 100644 --- a/xknx/io/tunnel.py +++ b/xknx/io/tunnel.py @@ -119,12 +119,11 @@ async def connect(self): await connect.start() if not connect.success: if self.auto_reconnect: - msg = "Could not connect to KNX. Retry in {} seconds.".format( - self.auto_reconnect_wait + logger.warning( + "Could not connect to KNX. Retry in %s seconds.", + self.auto_reconnect_wait, ) - logger.warning(msg) - task = self.xknx.loop.create_task(self.schedule_reconnect()) - self._reconnect_task = task + self._reconnect_task = asyncio.create_task(self.schedule_reconnect()) return raise CommunicationError( "Could not establish connection", not self._is_reconnecting @@ -255,7 +254,7 @@ async def stop(self): async def start_heartbeat(self): """Start heartbeat for monitoring state of tunnel, as suggested by 03.08.02 KNX Core 5.4.""" - self._heartbeat_task = self.xknx.loop.create_task(self.do_heartbeat()) + self._heartbeat_task = asyncio.create_task(self.do_heartbeat()) async def stop_heartbeat(self): """Stop heartbeat task if running.""" diff --git a/xknx/io/udp_client.py b/xknx/io/udp_client.py index 54df4fcac..3c75bbea1 100644 --- a/xknx/io/udp_client.py +++ b/xknx/io/udp_client.py @@ -154,16 +154,16 @@ async def connect(self): multicast=self.multicast, data_received_callback=self.data_received_callback, ) - + loop = asyncio.get_running_loop() if self.multicast: sock = UDPClient.create_multicast_sock(self.local_addr[0], self.remote_addr) - (transport, _) = await self.xknx.loop.create_datagram_endpoint( + (transport, _) = await loop.create_datagram_endpoint( lambda: udp_client_factory, sock=sock ) self.transport = transport else: - (transport, _) = await self.xknx.loop.create_datagram_endpoint( + (transport, _) = await loop.create_datagram_endpoint( lambda: udp_client_factory, local_addr=self.local_addr, remote_addr=self.remote_addr, diff --git a/xknx/xknx.py b/xknx/xknx.py index 7a2ae8e7f..a6322d809 100644 --- a/xknx/xknx.py +++ b/xknx/xknx.py @@ -32,7 +32,6 @@ class XKNX: def __init__( self, config=None, - loop=None, own_address=DEFAULT_ADDRESS, address_format=GroupAddressType.LONG, telegram_received_cb=None, @@ -49,7 +48,6 @@ def __init__( # pylint: disable=too-many-arguments self.devices = Devices() self.telegrams = asyncio.Queue() - self.loop = loop or asyncio.get_event_loop() self.sigint_received = asyncio.Event() self.telegram_queue = TelegramQueue(self) self.state_updater = StateUpdater(self) @@ -81,8 +79,8 @@ def __del__(self): """Destructor. Cleaning up if this was not done before.""" if self.started.is_set(): try: - task = self.loop.create_task(self.stop()) - self.loop.run_until_complete(task) + loop = asyncio.get_event_loop() + loop.run_until_complete(self.stop()) except RuntimeError as exp: logger.warning("Could not close loop, reason: %s", exp) @@ -141,7 +139,8 @@ def sigint_handler(): if platform == "win32": logger.warning("Windows does not support signals") else: - self.loop.add_signal_handler(signal.SIGINT, sigint_handler) + loop = asyncio.get_running_loop() + loop.add_signal_handler(signal.SIGINT, sigint_handler) logger.warning("Press Ctrl+C to stop") await self.sigint_received.wait()