Skip to content

Commit

Permalink
Change init order
Browse files Browse the repository at this point in the history
  • Loading branch information
elupus committed Feb 12, 2024
1 parent f267595 commit 77ff4e5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
3 changes: 1 addition & 2 deletions RFXtrx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1027,8 +1027,7 @@ class Connect:
Has methods for sensors.
"""
# pylint: disable=too-many-instance-attributes, too-many-arguments
def __init__(self, event_callback=None,
transport=None,
def __init__(self, transport, event_callback=None,
modes=None):
self._run_event = threading.Event()
self._sensors = {}
Expand Down
2 changes: 1 addition & 1 deletion examples/receive.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def main():

modes_list = sys.argv[2].split() if len(sys.argv) > 2 else None
print ("modes: ", modes_list)
core = RFXtrx.Connect(print_callback, modes=modes_list, transport=RFXtrx.PySerialTransport(rfxcom_device))
core = RFXtrx.Connect(RFXtrx.PySerialTransport(rfxcom_device), print_callback, modes=modes_list)
core.connect()

print (core)
Expand Down
14 changes: 7 additions & 7 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def setUp(self):

def test_constructor(self):
global num_calbacks
core = RFXtrx.Connect(event_callback=_callback, transport=RFXtrx.DummyTransport2(self.path))
core = RFXtrx.Connect(RFXtrx.DummyTransport2(self.path), event_callback=_callback)
core.connect()
while num_calbacks < 7:
time.sleep(0.1)
Expand All @@ -31,14 +31,14 @@ def test_constructor(self):

def test_invalid_packet(self):
bytes_array = bytearray([0x09, 0x11, 0xd7, 0x00, 0x01, 0x1d, 0x14, 0x02, 0x79, 0x0a])
core = RFXtrx.Connect(event_callback=_callback, transport=RFXtrx.DummyTransport(self.path))
core = RFXtrx.Connect(RFXtrx.DummyTransport(self.path), event_callback=_callback)
core.connect()
event = core.transport.parse(bytes_array)
self.assertIsNone(event)

def test_format_packet(self):
# Lighting1
core = RFXtrx.Connect(event_callback=_callback, transport=RFXtrx.DummyTransport(self.path))
core = RFXtrx.Connect(RFXtrx.DummyTransport(self.path), event_callback=_callback)
core.connect()
bytes_array = bytearray([0x07, 0x10, 0x00, 0x2a, 0x45, 0x05, 0x01, 0x70])
event = core.transport.parse(bytes_array)
Expand Down Expand Up @@ -361,7 +361,7 @@ def test_equal_check(self):
self.assertFalse(temphum==energy)

def test_equal_device_check(self):
core = RFXtrx.Connect(event_callback=_callback, transport=RFXtrx.DummyTransport(self.path))
core = RFXtrx.Connect(RFXtrx.DummyTransport(self.path), event_callback=_callback)
core.connect()
data1 = bytearray(b'\x11\x5A\x01\x00\x2E\xB2\x03\x00\x00'
b'\x02\xB4\x00\x00\x0C\x46\xA8\x11\x69')
Expand Down Expand Up @@ -395,7 +395,7 @@ def test_equal_device_check(self):
core.close_connection()

def test_get_device(self):
core = RFXtrx.Connect(event_callback=_callback, transport=RFXtrx.DummyTransport(self.path))
core = RFXtrx.Connect(RFXtrx.DummyTransport(self.path), event_callback=_callback)
core.connect()
# Lighting1
bytes_array = bytearray([0x07, 0x10, 0x00, 0x2a, 0x45, 0x05, 0x01, 0x70])
Expand Down Expand Up @@ -442,7 +442,7 @@ def test_get_device(self):
core.close_connection()

def test_set_recmodes(self):
core = RFXtrx.Connect(event_callback=_callback, transport=RFXtrx.DummyTransport(self.path))
core = RFXtrx.Connect(RFXtrx.DummyTransport(self.path), event_callback=_callback)
core.connect()
time.sleep(0.2)
self.assertEqual(None, core._modes)
Expand All @@ -464,7 +464,7 @@ def test_set_recmodes(self):
core.set_recmodes(['arc', 'oregon', 'unknown-mode'])

def test_receive(self):
core = RFXtrx.Connect(event_callback=_callback, transport=RFXtrx.DummyTransport(self.path))
core = RFXtrx.Connect(RFXtrx.DummyTransport(self.path), event_callback=_callback)
core.connect()
time.sleep(0.2)
# Lighting1
Expand Down

0 comments on commit 77ff4e5

Please sign in to comment.