From aaa073183c9ec1911ea00057abfea38721b5a4d0 Mon Sep 17 00:00:00 2001 From: Joakim Plate Date: Mon, 13 Jul 2020 03:40:45 +0200 Subject: [PATCH] Drop dummy connection (#37805) We now mock the module --- homeassistant/components/rfxtrx/__init__.py | 9 +------- tests/components/rfxtrx/test_binary_sensor.py | 12 +--------- tests/components/rfxtrx/test_cover.py | 13 ++--------- tests/components/rfxtrx/test_init.py | 3 --- tests/components/rfxtrx/test_light.py | 14 ++---------- tests/components/rfxtrx/test_sensor.py | 22 +++---------------- tests/components/rfxtrx/test_switch.py | 14 ++---------- 7 files changed, 11 insertions(+), 76 deletions(-) diff --git a/homeassistant/components/rfxtrx/__init__.py b/homeassistant/components/rfxtrx/__init__.py index 4f757e3068d..d25c867c1db 100644 --- a/homeassistant/components/rfxtrx/__init__.py +++ b/homeassistant/components/rfxtrx/__init__.py @@ -36,7 +36,6 @@ CONF_FIRE_EVENT = "fire_event" CONF_DATA_BITS = "data_bits" CONF_AUTOMATIC_ADD = "automatic_add" CONF_SIGNAL_REPETITIONS = "signal_repetitions" -CONF_DUMMY = "dummy" CONF_DEBUG = "debug" CONF_OFF_DELAY = "off_delay" SIGNAL_EVENT = f"{DOMAIN}_event" @@ -94,7 +93,6 @@ DEVICE_SCHEMA = vol.Schema( BASE_SCHEMA = vol.Schema( { vol.Optional(CONF_DEBUG, default=False): cv.boolean, - vol.Optional(CONF_DUMMY, default=False): cv.boolean, vol.Optional(CONF_AUTOMATIC_ADD, default=False): cv.boolean, vol.Optional(CONF_DEVICES, default={}): {cv.string: DEVICE_SCHEMA}, } @@ -158,13 +156,8 @@ def setup(hass, config): host = config[DOMAIN].get(CONF_HOST) port = config[DOMAIN].get(CONF_PORT) debug = config[DOMAIN][CONF_DEBUG] - dummy_connection = config[DOMAIN][CONF_DUMMY] - if dummy_connection: - rfx_object = rfxtrxmod.Connect( - device, None, debug=debug, transport_protocol=rfxtrxmod.DummyTransport2, - ) - elif port is not None: + if port is not None: # If port is set then we create a TCP connection rfx_object = rfxtrxmod.Connect( (host, port), diff --git a/tests/components/rfxtrx/test_binary_sensor.py b/tests/components/rfxtrx/test_binary_sensor.py index 7893099c1ff..d694dcb34cf 100644 --- a/tests/components/rfxtrx/test_binary_sensor.py +++ b/tests/components/rfxtrx/test_binary_sensor.py @@ -14,13 +14,7 @@ async def test_one(hass, rfxtrx): assert await async_setup_component( hass, "rfxtrx", - { - "rfxtrx": { - "device": "abcd", - "dummy": True, - "devices": {"0b1100cd0213c7f230010f71": {}}, - } - }, + {"rfxtrx": {"device": "abcd", "devices": {"0b1100cd0213c7f230010f71": {}}}}, ) await hass.async_block_till_done() @@ -38,7 +32,6 @@ async def test_one_pt2262(hass, rfxtrx): { "rfxtrx": { "device": "abcd", - "dummy": True, "devices": { "0913000022670e013970": { "data_bits": 4, @@ -74,7 +67,6 @@ async def test_several(hass, rfxtrx): { "rfxtrx": { "device": "abcd", - "dummy": True, "devices": { "0b1100cd0213c7f230010f71": {}, "0b1100100118cdea02010f70": {}, @@ -109,7 +101,6 @@ async def test_discover(hass, rfxtrx): { "rfxtrx": { "device": "abcd", - "dummy": True, "automatic_add": True, "devices": { "0b1100cd0213c7f230010f71": {}, @@ -141,7 +132,6 @@ async def test_off_delay(hass, rfxtrx): { "rfxtrx": { "device": "abcd", - "dummy": True, "devices": {"0b1100100118cdea02010f70": {"off_delay": 5}}, } }, diff --git a/tests/components/rfxtrx/test_cover.py b/tests/components/rfxtrx/test_cover.py index 84c1e18ce5d..9a9b37f4e36 100644 --- a/tests/components/rfxtrx/test_cover.py +++ b/tests/components/rfxtrx/test_cover.py @@ -11,13 +11,7 @@ async def test_one_cover(hass, rfxtrx): assert await async_setup_component( hass, "rfxtrx", - { - "rfxtrx": { - "device": "abcd", - "dummy": True, - "devices": {"0b1400cd0213c7f20d010f51": {}}, - } - }, + {"rfxtrx": {"device": "abcd", "devices": {"0b1400cd0213c7f20d010f51": {}}}}, ) await hass.async_block_till_done() @@ -60,7 +54,6 @@ async def test_several_covers(hass, rfxtrx): { "rfxtrx": { "device": "abcd", - "dummy": True, "devices": { "0b1400cd0213c7f20d010f51": {}, "0A1400ADF394AB010D0060": {}, @@ -90,9 +83,7 @@ async def test_several_covers(hass, rfxtrx): async def test_discover_covers(hass, rfxtrx): """Test with discovery of covers.""" assert await async_setup_component( - hass, - "rfxtrx", - {"rfxtrx": {"device": "abcd", "dummy": True, "automatic_add": True}}, + hass, "rfxtrx", {"rfxtrx": {"device": "abcd", "automatic_add": True}} ) await hass.async_block_till_done() await hass.async_start() diff --git a/tests/components/rfxtrx/test_init.py b/tests/components/rfxtrx/test_init.py index c9da7fb23e6..b9668274cf1 100644 --- a/tests/components/rfxtrx/test_init.py +++ b/tests/components/rfxtrx/test_init.py @@ -16,7 +16,6 @@ async def test_valid_config(hass): "rfxtrx": { "device": "/dev/serial/by-id/usb" + "-RFXCOM_RFXtrx433_A1Y0NJGR-if00-port0", - "dummy": True, } }, ) @@ -31,7 +30,6 @@ async def test_valid_config2(hass): "rfxtrx": { "device": "/dev/serial/by-id/usb" + "-RFXCOM_RFXtrx433_A1Y0NJGR-if00-port0", - "dummy": True, "debug": True, } }, @@ -64,7 +62,6 @@ async def test_fire_event(hass): "rfxtrx": { "device": "/dev/serial/by-id/usb" + "-RFXCOM_RFXtrx433_A1Y0NJGR-if00-port0", - "dummy": True, "automatic_add": True, "devices": { "0b1100cd0213c7f210010f51": {rfxtrx.CONF_FIRE_EVENT: True}, diff --git a/tests/components/rfxtrx/test_light.py b/tests/components/rfxtrx/test_light.py index de8fbcbb1e2..53ddf8bc48c 100644 --- a/tests/components/rfxtrx/test_light.py +++ b/tests/components/rfxtrx/test_light.py @@ -13,13 +13,7 @@ async def test_one_light(hass, rfxtrx): assert await async_setup_component( hass, "rfxtrx", - { - "rfxtrx": { - "device": "abcd", - "dummy": True, - "devices": {"0b1100cd0213c7f210020f51": {}}, - } - }, + {"rfxtrx": {"device": "abcd", "devices": {"0b1100cd0213c7f210020f51": {}}}}, ) await hass.async_block_till_done() @@ -97,7 +91,6 @@ async def test_several_lights(hass, rfxtrx): { "rfxtrx": { "device": "abcd", - "dummy": True, "devices": { "0b1100cd0213c7f230020f71": {}, "0b1100100118cdea02020f70": {}, @@ -133,7 +126,6 @@ async def test_repetitions(hass, rfxtrx, repetitions): { "rfxtrx": { "device": "abcd", - "dummy": True, "devices": { "0b1100cd0213c7f230020f71": {"signal_repetitions": repetitions} }, @@ -153,9 +145,7 @@ async def test_repetitions(hass, rfxtrx, repetitions): async def test_discover_light(hass, rfxtrx): """Test with discovery of lights.""" assert await async_setup_component( - hass, - "rfxtrx", - {"rfxtrx": {"device": "abcd", "dummy": True, "automatic_add": True}}, + hass, "rfxtrx", {"rfxtrx": {"device": "abcd", "automatic_add": True}}, ) await hass.async_block_till_done() await hass.async_start() diff --git a/tests/components/rfxtrx/test_sensor.py b/tests/components/rfxtrx/test_sensor.py index d758fe8ff7e..91e010f9e54 100644 --- a/tests/components/rfxtrx/test_sensor.py +++ b/tests/components/rfxtrx/test_sensor.py @@ -20,13 +20,7 @@ async def test_one_sensor(hass, rfxtrx): assert await async_setup_component( hass, "rfxtrx", - { - "rfxtrx": { - "device": "abcd", - "dummy": True, - "devices": {"0a52080705020095220269": {}}, - } - }, + {"rfxtrx": {"device": "abcd", "devices": {"0a52080705020095220269": {}}}}, ) await hass.async_block_till_done() @@ -45,13 +39,7 @@ async def test_one_sensor_no_datatype(hass, rfxtrx): assert await async_setup_component( hass, "rfxtrx", - { - "rfxtrx": { - "device": "abcd", - "dummy": True, - "devices": {"0a52080705020095220269": {}}, - } - }, + {"rfxtrx": {"device": "abcd", "devices": {"0a52080705020095220269": {}}}}, ) await hass.async_block_till_done() @@ -97,7 +85,6 @@ async def test_several_sensors(hass, rfxtrx): { "rfxtrx": { "device": "abcd", - "dummy": True, "devices": { "0a52080705020095220269": {}, "0a520802060100ff0e0269": {}, @@ -139,9 +126,7 @@ async def test_several_sensors(hass, rfxtrx): async def test_discover_sensor(hass, rfxtrx): """Test with discovery of sensor.""" assert await async_setup_component( - hass, - "rfxtrx", - {"rfxtrx": {"device": "abcd", "dummy": True, "automatic_add": True}}, + hass, "rfxtrx", {"rfxtrx": {"device": "abcd", "automatic_add": True}}, ) await hass.async_block_till_done() await hass.async_start() @@ -244,7 +229,6 @@ async def test_update_of_sensors(hass, rfxtrx): { "rfxtrx": { "device": "abcd", - "dummy": True, "devices": { "0a52080705020095220269": {}, "0a520802060100ff0e0269": {}, diff --git a/tests/components/rfxtrx/test_switch.py b/tests/components/rfxtrx/test_switch.py index 6b01a0ec5e3..24d1cbbcdf0 100644 --- a/tests/components/rfxtrx/test_switch.py +++ b/tests/components/rfxtrx/test_switch.py @@ -13,13 +13,7 @@ async def test_one_switch(hass, rfxtrx): assert await async_setup_component( hass, "rfxtrx", - { - "rfxtrx": { - "device": "abcd", - "dummy": True, - "devices": {"0b1100cd0213c7f210010f51": {}}, - } - }, + {"rfxtrx": {"device": "abcd", "devices": {"0b1100cd0213c7f210010f51": {}}}}, ) await hass.async_block_till_done() @@ -56,7 +50,6 @@ async def test_several_switches(hass, rfxtrx): { "rfxtrx": { "device": "abcd", - "dummy": True, "devices": { "0b1100cd0213c7f230010f71": {}, "0b1100100118cdea02010f70": {}, @@ -92,7 +85,6 @@ async def test_repetitions(hass, rfxtrx, repetitions): { "rfxtrx": { "device": "abcd", - "dummy": True, "devices": { "0b1100cd0213c7f230010f71": {"signal_repetitions": repetitions} }, @@ -112,9 +104,7 @@ async def test_repetitions(hass, rfxtrx, repetitions): async def test_discover_switch(hass, rfxtrx): """Test with discovery of switches.""" assert await async_setup_component( - hass, - "rfxtrx", - {"rfxtrx": {"device": "abcd", "dummy": True, "automatic_add": True}}, + hass, "rfxtrx", {"rfxtrx": {"device": "abcd", "automatic_add": True}}, ) await hass.async_block_till_done() await hass.async_start()