Drop dummy connection (#37805)

We now mock the module
This commit is contained in:
Joakim Plate 2020-07-13 03:40:45 +02:00 committed by GitHub
parent 8e71559068
commit aaa073183c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 11 additions and 76 deletions

View file

@ -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),

View file

@ -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}},
}
},

View file

@ -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()

View file

@ -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},

View file

@ -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()

View file

@ -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": {},

View file

@ -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()