Update dependency pytest-asyncio to v1.2.0 (#492)
* Update dependency pytest-asyncio to v1.2.0 * don't stop the event loop between test set the loop_scope to session for async tests * remove loop_scope="session" --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Stefan Allius <stefan.allius@t-online.de>
This commit is contained in:
@@ -932,7 +932,7 @@ def config_tsun_dcu1():
|
||||
Proxy.class_init()
|
||||
Proxy.mqtt = Mqtt()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_read_message(device_ind_msg):
|
||||
Config.act_config = {'solarman':{'enabled': True}}
|
||||
m = MemoryStream(device_ind_msg, (0,))
|
||||
@@ -951,7 +951,7 @@ async def test_read_message(device_ind_msg):
|
||||
assert m.db.stat['proxy']['Invalid_Msg_Format'] == 0
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_invalid_start_byte(invalid_start_byte, device_ind_msg):
|
||||
# received a message with wrong start byte plus an valid message
|
||||
# the complete receive buffer must be cleared to
|
||||
@@ -974,7 +974,7 @@ async def test_invalid_start_byte(invalid_start_byte, device_ind_msg):
|
||||
assert m.db.stat['proxy']['Invalid_Msg_Format'] == 1
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_invalid_stop_byte(invalid_stop_byte):
|
||||
# received a message with wrong stop byte
|
||||
# the complete receive buffer must be cleared to
|
||||
@@ -996,7 +996,7 @@ async def test_invalid_stop_byte(invalid_stop_byte):
|
||||
assert m.db.stat['proxy']['Invalid_Msg_Format'] == 1
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_invalid_stop_byte2(invalid_stop_byte, device_ind_msg):
|
||||
# received a message with wrong stop byte plus an valid message
|
||||
# only the first message must be discarded
|
||||
@@ -1023,7 +1023,7 @@ async def test_invalid_stop_byte2(invalid_stop_byte, device_ind_msg):
|
||||
assert m.db.stat['proxy']['Invalid_Msg_Format'] == 1
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_invalid_stop_start_byte(invalid_stop_byte, invalid_start_byte):
|
||||
# received a message with wrong stop byte plus an invalid message
|
||||
# with fron start byte
|
||||
@@ -1047,7 +1047,7 @@ async def test_invalid_stop_start_byte(invalid_stop_byte, invalid_start_byte):
|
||||
assert m.db.stat['proxy']['Invalid_Msg_Format'] == 1
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_invalid_checksum(invalid_checksum, device_ind_msg):
|
||||
# received a message with wrong checksum plus an valid message
|
||||
# only the first message must be discarded
|
||||
@@ -1073,7 +1073,7 @@ async def test_invalid_checksum(invalid_checksum, device_ind_msg):
|
||||
assert m.db.stat['proxy']['Invalid_Msg_Format'] == 1
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_read_message_twice(config_no_tsun_inv1, device_ind_msg, device_rsp_msg):
|
||||
_ = config_no_tsun_inv1
|
||||
m = MemoryStream(device_ind_msg, (0,))
|
||||
@@ -1095,7 +1095,7 @@ async def test_read_message_twice(config_no_tsun_inv1, device_ind_msg, device_rs
|
||||
assert m.db.stat['proxy']['Invalid_Msg_Format'] == 0
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_read_message_in_chunks(device_ind_msg):
|
||||
Config.act_config = {'solarman':{'enabled': True}}
|
||||
m = MemoryStream(device_ind_msg, (4,11,0))
|
||||
@@ -1118,7 +1118,7 @@ async def test_read_message_in_chunks(device_ind_msg):
|
||||
assert m.db.stat['proxy']['Invalid_Msg_Format'] == 0
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_read_message_in_chunks2(my_loop, config_tsun_inv1, device_ind_msg):
|
||||
_ = config_tsun_inv1
|
||||
m = MemoryStream(device_ind_msg, (4,10,0))
|
||||
@@ -1144,7 +1144,7 @@ async def test_read_message_in_chunks2(my_loop, config_tsun_inv1, device_ind_msg
|
||||
assert m.db.stat['proxy']['Invalid_Msg_Format'] == 0
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_read_two_messages(my_loop, config_tsun_allow_all, device_ind_msg, device_rsp_msg, inverter_ind_msg, inverter_rsp_msg):
|
||||
_ = config_tsun_allow_all
|
||||
m = MemoryStream(device_ind_msg, (0,))
|
||||
@@ -1173,7 +1173,7 @@ async def test_read_two_messages(my_loop, config_tsun_allow_all, device_ind_msg,
|
||||
assert m.ifc.tx_fifo.get()==b''
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_read_two_messages2(my_loop, config_tsun_allow_all, inverter_ind_msg, inverter_ind_msg_81, inverter_rsp_msg, inverter_rsp_msg_81):
|
||||
_ = config_tsun_allow_all
|
||||
m = MemoryStream(inverter_ind_msg, (0,))
|
||||
@@ -1199,7 +1199,7 @@ async def test_read_two_messages2(my_loop, config_tsun_allow_all, inverter_ind_m
|
||||
assert m.ifc.tx_fifo.get()==b''
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_read_two_messages3(my_loop, config_tsun_allow_all, device_ind_msg2, device_rsp_msg2, inverter_ind_msg, inverter_rsp_msg):
|
||||
# test device message received after the inverter masg
|
||||
_ = config_tsun_allow_all
|
||||
@@ -1229,7 +1229,7 @@ async def test_read_two_messages3(my_loop, config_tsun_allow_all, device_ind_msg
|
||||
assert m.ifc.tx_fifo.get()==b''
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_read_two_messages4(my_loop, config_tsun_dcu1, dcu_dev_ind_msg, dcu_dev_rsp_msg, dcu_data_ind_msg, dcu_data_rsp_msg):
|
||||
_ = config_tsun_dcu1
|
||||
m = MemoryStream(dcu_dev_ind_msg, (0,))
|
||||
@@ -1258,7 +1258,7 @@ async def test_read_two_messages4(my_loop, config_tsun_dcu1, dcu_dev_ind_msg, dc
|
||||
assert m.ifc.tx_fifo.get()==b''
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_unkown_frame_code(my_loop, config_tsun_inv1, inverter_ind_msg_81, inverter_rsp_msg_81):
|
||||
_ = config_tsun_inv1
|
||||
m = MemoryStream(inverter_ind_msg_81, (0,))
|
||||
@@ -1277,7 +1277,7 @@ async def test_unkown_frame_code(my_loop, config_tsun_inv1, inverter_ind_msg_81,
|
||||
assert m.db.stat['proxy']['Invalid_Msg_Format'] == 0
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_unkown_message(my_loop, config_tsun_inv1, unknown_msg):
|
||||
_ = config_tsun_inv1
|
||||
m = MemoryStream(unknown_msg, (0,))
|
||||
@@ -1296,7 +1296,7 @@ async def test_unkown_message(my_loop, config_tsun_inv1, unknown_msg):
|
||||
assert m.db.stat['proxy']['Invalid_Msg_Format'] == 0
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_device_rsp(my_loop, config_tsun_inv1, device_rsp_msg):
|
||||
_ = config_tsun_inv1
|
||||
m = MemoryStream(device_rsp_msg, (0,), False)
|
||||
@@ -1315,7 +1315,7 @@ async def test_device_rsp(my_loop, config_tsun_inv1, device_rsp_msg):
|
||||
assert m.db.stat['proxy']['Invalid_Msg_Format'] == 0
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_inverter_rsp(my_loop, config_tsun_inv1, inverter_rsp_msg):
|
||||
_ = config_tsun_inv1
|
||||
m = MemoryStream(inverter_rsp_msg, (0,), False)
|
||||
@@ -1334,7 +1334,7 @@ async def test_inverter_rsp(my_loop, config_tsun_inv1, inverter_rsp_msg):
|
||||
assert m.db.stat['proxy']['Invalid_Msg_Format'] == 0
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_heartbeat_ind(my_loop, config_tsun_inv1, heartbeat_ind_msg, heartbeat_rsp_msg):
|
||||
_ = config_tsun_inv1
|
||||
m = MemoryStream(heartbeat_ind_msg, (0,))
|
||||
@@ -1352,7 +1352,7 @@ async def test_heartbeat_ind(my_loop, config_tsun_inv1, heartbeat_ind_msg, heart
|
||||
assert m.db.stat['proxy']['Invalid_Msg_Format'] == 0
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_heartbeat_ind2(my_loop, config_tsun_inv1, heartbeat_ind_msg, heartbeat_rsp_msg):
|
||||
_ = config_tsun_inv1
|
||||
m = MemoryStream(heartbeat_ind_msg, (0,))
|
||||
@@ -1371,7 +1371,7 @@ async def test_heartbeat_ind2(my_loop, config_tsun_inv1, heartbeat_ind_msg, hear
|
||||
assert m.db.stat['proxy']['Invalid_Msg_Format'] == 0
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_heartbeat_rsp(my_loop, config_tsun_inv1, heartbeat_rsp_msg):
|
||||
_ = config_tsun_inv1
|
||||
m = MemoryStream(heartbeat_rsp_msg, (0,), False)
|
||||
@@ -1390,7 +1390,7 @@ async def test_heartbeat_rsp(my_loop, config_tsun_inv1, heartbeat_rsp_msg):
|
||||
assert m.db.stat['proxy']['Invalid_Msg_Format'] == 0
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_sync_start_ind(my_loop, config_tsun_inv1, sync_start_ind_msg, sync_start_rsp_msg, sync_start_fwd_msg):
|
||||
_ = config_tsun_inv1
|
||||
m = MemoryStream(sync_start_ind_msg, (0,))
|
||||
@@ -1414,7 +1414,7 @@ async def test_sync_start_ind(my_loop, config_tsun_inv1, sync_start_ind_msg, syn
|
||||
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_sync_start_rsp(my_loop, config_tsun_inv1, sync_start_rsp_msg):
|
||||
_ = config_tsun_inv1
|
||||
m = MemoryStream(sync_start_rsp_msg, (0,), False)
|
||||
@@ -1433,7 +1433,7 @@ async def test_sync_start_rsp(my_loop, config_tsun_inv1, sync_start_rsp_msg):
|
||||
assert m.db.stat['proxy']['Invalid_Msg_Format'] == 0
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_sync_end_ind(my_loop, config_tsun_inv1, sync_end_ind_msg, sync_end_rsp_msg):
|
||||
_ = config_tsun_inv1
|
||||
m = MemoryStream(sync_end_ind_msg, (0,))
|
||||
@@ -1451,7 +1451,7 @@ async def test_sync_end_ind(my_loop, config_tsun_inv1, sync_end_ind_msg, sync_en
|
||||
assert m.db.stat['proxy']['Invalid_Msg_Format'] == 0
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_sync_end_rsp(my_loop, config_tsun_inv1, sync_end_rsp_msg):
|
||||
_ = config_tsun_inv1
|
||||
m = MemoryStream(sync_end_rsp_msg, (0,), False)
|
||||
@@ -1470,7 +1470,7 @@ async def test_sync_end_rsp(my_loop, config_tsun_inv1, sync_end_rsp_msg):
|
||||
assert m.db.stat['proxy']['Invalid_Msg_Format'] == 0
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_build_modell_600(my_loop, config_tsun_allow_all, inverter_ind_msg):
|
||||
_ = config_tsun_allow_all
|
||||
m = MemoryStream(inverter_ind_msg, (0,))
|
||||
@@ -1491,7 +1491,7 @@ async def test_build_modell_600(my_loop, config_tsun_allow_all, inverter_ind_msg
|
||||
assert m.ifc.tx_fifo.get()==b''
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_build_modell_1600(my_loop, config_tsun_allow_all, inverter_ind_msg1600):
|
||||
_ = config_tsun_allow_all
|
||||
m = MemoryStream(inverter_ind_msg1600, (0,))
|
||||
@@ -1505,7 +1505,7 @@ async def test_build_modell_1600(my_loop, config_tsun_allow_all, inverter_ind_ms
|
||||
assert 'TSOL-MS1600' == m.db.get_db_value(Register.EQUIPMENT_MODEL, 0)
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_build_modell_1800(my_loop, config_tsun_allow_all, inverter_ind_msg1800):
|
||||
_ = config_tsun_allow_all
|
||||
m = MemoryStream(inverter_ind_msg1800, (0,))
|
||||
@@ -1519,7 +1519,7 @@ async def test_build_modell_1800(my_loop, config_tsun_allow_all, inverter_ind_ms
|
||||
assert 'TSOL-MS1800' == m.db.get_db_value(Register.EQUIPMENT_MODEL, 0)
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_build_modell_2000(my_loop, config_tsun_allow_all, inverter_ind_msg2000):
|
||||
_ = config_tsun_allow_all
|
||||
m = MemoryStream(inverter_ind_msg2000, (0,))
|
||||
@@ -1533,7 +1533,7 @@ async def test_build_modell_2000(my_loop, config_tsun_allow_all, inverter_ind_ms
|
||||
assert 'TSOL-MS2000' == m.db.get_db_value(Register.EQUIPMENT_MODEL, 0)
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_build_modell_800(my_loop, config_tsun_allow_all, inverter_ind_msg800):
|
||||
_ = config_tsun_allow_all
|
||||
m = MemoryStream(inverter_ind_msg800, (0,))
|
||||
@@ -1547,7 +1547,7 @@ async def test_build_modell_800(my_loop, config_tsun_allow_all, inverter_ind_msg
|
||||
assert 'TSOL-MS800' == m.db.get_db_value(Register.EQUIPMENT_MODEL, 0)
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_build_modell_900(my_loop, config_tsun_allow_all, inverter_ind_msg900):
|
||||
_ = config_tsun_allow_all
|
||||
m = MemoryStream(inverter_ind_msg900, (0,))
|
||||
@@ -1561,7 +1561,7 @@ async def test_build_modell_900(my_loop, config_tsun_allow_all, inverter_ind_msg
|
||||
assert 'TSOL-MSxx00' == m.db.get_db_value(Register.EQUIPMENT_MODEL, 0)
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_build_logger_modell(my_loop, config_tsun_allow_all, device_ind_msg):
|
||||
_ = config_tsun_allow_all
|
||||
m = MemoryStream(device_ind_msg, (0,))
|
||||
@@ -1573,7 +1573,7 @@ async def test_build_logger_modell(my_loop, config_tsun_allow_all, device_ind_ms
|
||||
assert 'V1.1.00.0B' == m.db.get_db_value(Register.COLLECTOR_FW_VERSION, 0).rstrip('\00')
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_msg_iterator(my_loop, config_tsun_inv1):
|
||||
Message._registry.clear()
|
||||
m1 = SolarmanV5(None, ('test1.local', 1234), ifc=AsyncIfcImpl(), server_side=True, client_mode=False)
|
||||
@@ -1595,7 +1595,7 @@ async def test_msg_iterator(my_loop, config_tsun_inv1):
|
||||
assert test1 == 1
|
||||
assert test2 == 1
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_proxy_counter(my_loop, config_tsun_inv1):
|
||||
m = SolarmanV5(None, ('test.local', 1234), ifc=AsyncIfcImpl(), server_side=True, client_mode=False)
|
||||
assert m.new_data == {}
|
||||
@@ -1614,7 +1614,7 @@ async def test_proxy_counter(my_loop, config_tsun_inv1):
|
||||
assert 0 == m.db.stat['proxy']['Unknown_Msg']
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_msg_build_modbus_req(my_loop, config_tsun_inv1, device_ind_msg, device_rsp_msg, inverter_ind_msg, inverter_rsp_msg, msg_modbus_cmd):
|
||||
_ = config_tsun_inv1
|
||||
m = MemoryStream(device_ind_msg, (0,), True)
|
||||
@@ -1649,7 +1649,7 @@ async def test_msg_build_modbus_req(my_loop, config_tsun_inv1, device_ind_msg, d
|
||||
assert m.ifc.tx_fifo.get()== b''
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_at_cmd(my_loop, config_tsun_allow_all, device_ind_msg, device_rsp_msg, inverter_ind_msg, inverter_rsp_msg, at_command_ind_msg, at_command_rsp_msg):
|
||||
_ = config_tsun_allow_all
|
||||
m = MemoryStream(device_ind_msg, (0,), True)
|
||||
@@ -1709,7 +1709,7 @@ async def test_at_cmd(my_loop, config_tsun_allow_all, device_ind_msg, device_rsp
|
||||
assert Proxy.mqtt.data == ""
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_at_cmd_blocked(my_loop, config_tsun_allow_all, device_ind_msg, device_rsp_msg, inverter_ind_msg, inverter_rsp_msg, at_command_ind_msg):
|
||||
_ = config_tsun_allow_all
|
||||
m = MemoryStream(device_ind_msg, (0,), True)
|
||||
@@ -1744,7 +1744,7 @@ async def test_at_cmd_blocked(my_loop, config_tsun_allow_all, device_ind_msg, de
|
||||
assert Proxy.mqtt.data == "'AT+WEBU' is forbidden"
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_at_cmd_ind(my_loop, config_tsun_inv1, at_command_ind_msg, at_command_rsp_msg):
|
||||
_ = config_tsun_inv1
|
||||
m = MemoryStream(at_command_ind_msg, (0,), False)
|
||||
@@ -1780,7 +1780,7 @@ async def test_at_cmd_ind(my_loop, config_tsun_inv1, at_command_ind_msg, at_comm
|
||||
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_at_cmd_ind_block(my_loop, config_tsun_inv1, at_command_ind_msg_block):
|
||||
_ = config_tsun_inv1
|
||||
m = MemoryStream(at_command_ind_msg_block, (0,), False)
|
||||
@@ -1809,7 +1809,7 @@ async def test_at_cmd_ind_block(my_loop, config_tsun_inv1, at_command_ind_msg_bl
|
||||
assert Proxy.mqtt.data == ""
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_msg_at_command_rsp1(my_loop, config_tsun_inv1, at_command_rsp_msg):
|
||||
_ = config_tsun_inv1
|
||||
m = MemoryStream(at_command_rsp_msg)
|
||||
@@ -1829,7 +1829,7 @@ async def test_msg_at_command_rsp1(my_loop, config_tsun_inv1, at_command_rsp_msg
|
||||
assert m.db.stat['proxy']['Modbus_Command'] == 0
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_msg_at_command_rsp2(my_loop, config_tsun_inv1, at_command_rsp_msg):
|
||||
_ = config_tsun_inv1
|
||||
m = MemoryStream(at_command_rsp_msg)
|
||||
@@ -1851,7 +1851,7 @@ async def test_msg_at_command_rsp2(my_loop, config_tsun_inv1, at_command_rsp_msg
|
||||
assert Proxy.mqtt.data == "+ok"
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_msg_at_command_rsp3(my_loop, config_tsun_inv1, at_command_interim_rsp_msg):
|
||||
_ = config_tsun_inv1
|
||||
m = MemoryStream(at_command_interim_rsp_msg)
|
||||
@@ -1877,7 +1877,7 @@ async def test_msg_at_command_rsp3(my_loop, config_tsun_inv1, at_command_interim
|
||||
assert Proxy.mqtt.data == ""
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_msg_modbus_req(my_loop, config_tsun_inv1, msg_modbus_cmd, msg_modbus_cmd_fwd):
|
||||
_ = config_tsun_inv1
|
||||
m = MemoryStream(b'')
|
||||
@@ -1906,7 +1906,7 @@ async def test_msg_modbus_req(my_loop, config_tsun_inv1, msg_modbus_cmd, msg_mod
|
||||
assert m.db.stat['proxy']['Invalid_Msg_Format'] == 0
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_msg_modbus_req_seq(my_loop, config_tsun_inv1, msg_modbus_cmd_seq):
|
||||
_ = config_tsun_inv1
|
||||
m = MemoryStream(b'')
|
||||
@@ -1935,7 +1935,7 @@ async def test_msg_modbus_req_seq(my_loop, config_tsun_inv1, msg_modbus_cmd_seq)
|
||||
assert m.db.stat['proxy']['Invalid_Msg_Format'] == 0
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_msg_modbus_req2(my_loop, config_tsun_inv1, msg_modbus_cmd_crc_err):
|
||||
_ = config_tsun_inv1
|
||||
m = MemoryStream(b'')
|
||||
@@ -1963,7 +1963,7 @@ async def test_msg_modbus_req2(my_loop, config_tsun_inv1, msg_modbus_cmd_crc_err
|
||||
assert m.db.stat['proxy']['Invalid_Msg_Format'] == 1
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_msg_unknown_cmd_req(my_loop, config_tsun_inv1, msg_unknown_cmd):
|
||||
_ = config_tsun_inv1
|
||||
m = MemoryStream(msg_unknown_cmd, (0,), False)
|
||||
@@ -1986,7 +1986,7 @@ async def test_msg_unknown_cmd_req(my_loop, config_tsun_inv1, msg_unknown_cmd):
|
||||
assert m.db.stat['proxy']['Invalid_Msg_Format'] == 0
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_msg_modbus_rsp1(my_loop, config_tsun_inv1, msg_modbus_rsp):
|
||||
'''Modbus response without a valid Modbus request must be dropped'''
|
||||
_ = config_tsun_inv1
|
||||
@@ -2006,7 +2006,7 @@ async def test_msg_modbus_rsp1(my_loop, config_tsun_inv1, msg_modbus_rsp):
|
||||
assert m.db.stat['proxy']['Modbus_Command'] == 0
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_msg_modbus_rsp2(my_loop, config_tsun_inv1, msg_modbus_rsp):
|
||||
'''Modbus response with a valid Modbus request must be forwarded'''
|
||||
_ = config_tsun_inv1 # setup config structure
|
||||
@@ -2044,7 +2044,7 @@ async def test_msg_modbus_rsp2(my_loop, config_tsun_inv1, msg_modbus_rsp):
|
||||
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_msg_modbus_rsp3(my_loop, config_tsun_inv1, msg_modbus_rsp):
|
||||
'''Modbus response with a valid Modbus request must be forwarded'''
|
||||
_ = config_tsun_inv1
|
||||
@@ -2081,7 +2081,7 @@ async def test_msg_modbus_rsp3(my_loop, config_tsun_inv1, msg_modbus_rsp):
|
||||
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_msg_unknown_rsp(my_loop, config_tsun_inv1, msg_unknown_cmd_rsp):
|
||||
_ = config_tsun_inv1
|
||||
m = MemoryStream(msg_unknown_cmd_rsp)
|
||||
@@ -2100,7 +2100,7 @@ async def test_msg_unknown_rsp(my_loop, config_tsun_inv1, msg_unknown_cmd_rsp):
|
||||
assert m.db.stat['proxy']['Modbus_Command'] == 0
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_msg_modbus_invalid(my_loop, config_tsun_inv1, msg_modbus_invalid):
|
||||
_ = config_tsun_inv1
|
||||
m = MemoryStream(msg_modbus_invalid, (0,), False)
|
||||
@@ -2115,7 +2115,7 @@ async def test_msg_modbus_invalid(my_loop, config_tsun_inv1, msg_modbus_invalid)
|
||||
assert m.db.stat['proxy']['Modbus_Command'] == 0
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_msg_modbus_fragment(my_loop, config_tsun_inv1, msg_modbus_rsp):
|
||||
_ = config_tsun_inv1
|
||||
# receive more bytes than expected (7 bytes from the next msg)
|
||||
@@ -2141,7 +2141,7 @@ async def test_msg_modbus_fragment(my_loop, config_tsun_inv1, msg_modbus_rsp):
|
||||
assert m.db.stat['proxy']['Modbus_Command'] == 0
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_modbus_polling(my_loop, config_tsun_inv1, heartbeat_ind_msg, heartbeat_rsp_msg):
|
||||
_ = config_tsun_inv1
|
||||
assert asyncio.get_running_loop()
|
||||
@@ -2181,7 +2181,7 @@ async def test_modbus_polling(my_loop, config_tsun_inv1, heartbeat_ind_msg, hear
|
||||
assert next(m.mb_timer.exp_count) == 4
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_modbus_scaning(config_tsun_scan, heartbeat_ind_msg, heartbeat_rsp_msg, msg_modbus_rsp, msg_modbus_rsp_inv_id2):
|
||||
_ = config_tsun_scan
|
||||
assert asyncio.get_running_loop()
|
||||
@@ -2254,7 +2254,7 @@ async def test_modbus_scaning(config_tsun_scan, heartbeat_ind_msg, heartbeat_rsp
|
||||
assert next(m.mb_timer.exp_count) == 3
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_modbus_scaning_inv_rsp(config_tsun_scan, heartbeat_ind_msg, heartbeat_rsp_msg, msg_modbus_rsp_mb_4):
|
||||
_ = config_tsun_scan
|
||||
assert asyncio.get_running_loop()
|
||||
@@ -2309,7 +2309,7 @@ async def test_modbus_scaning_inv_rsp(config_tsun_scan, heartbeat_ind_msg, heart
|
||||
assert next(m.mb_timer.exp_count) == 2
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_start_client_mode(my_loop, config_tsun_inv1, str_test_ip):
|
||||
_ = config_tsun_inv1
|
||||
assert asyncio.get_running_loop()
|
||||
@@ -2341,7 +2341,7 @@ async def test_start_client_mode(my_loop, config_tsun_inv1, str_test_ip):
|
||||
assert next(m.mb_timer.exp_count) == 3
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_start_client_mode_scan(config_tsun_scan_dcu, str_test_ip, dcu_modbus_rsp):
|
||||
_ = config_tsun_scan_dcu
|
||||
assert asyncio.get_running_loop()
|
||||
@@ -2414,7 +2414,7 @@ async def test_start_client_mode_scan(config_tsun_scan_dcu, str_test_ip, dcu_mod
|
||||
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_timeout(my_loop, config_tsun_inv1):
|
||||
_ = config_tsun_inv1
|
||||
m = MemoryStream(b'')
|
||||
@@ -2428,7 +2428,7 @@ async def test_timeout(my_loop, config_tsun_inv1):
|
||||
m.state = State.closed
|
||||
m.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_fnc_dispatch(my_loop, config_tsun_inv1):
|
||||
def msg():
|
||||
return
|
||||
@@ -2450,7 +2450,7 @@ async def test_fnc_dispatch(my_loop, config_tsun_inv1):
|
||||
assert _obj == m.msg_unknown
|
||||
assert _str == "'msg_unknown'"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_timestamp(my_loop, config_tsun_inv1):
|
||||
m = MemoryStream(b'')
|
||||
ts = m._timestamp()
|
||||
@@ -2477,7 +2477,7 @@ class InverterTest(InverterBase):
|
||||
dst.ifc.tx_add(src.ifc.fwd_fifo.get())
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_proxy_at_cmd(my_loop, config_tsun_inv1, patch_open_connection, at_command_ind_msg, at_command_rsp_msg):
|
||||
_ = config_tsun_inv1
|
||||
_ = patch_open_connection
|
||||
@@ -2515,7 +2515,7 @@ async def test_proxy_at_cmd(my_loop, config_tsun_inv1, patch_open_connection, at
|
||||
assert Proxy.mqtt.key == ''
|
||||
assert Proxy.mqtt.data == ""
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_proxy_at_blocked(my_loop, config_tsun_inv1, patch_open_connection, at_command_ind_msg_block, at_command_rsp_msg):
|
||||
_ = config_tsun_inv1
|
||||
_ = patch_open_connection
|
||||
@@ -2553,7 +2553,7 @@ async def test_proxy_at_blocked(my_loop, config_tsun_inv1, patch_open_connection
|
||||
assert Proxy.mqtt.key == 'tsun/inv1/at_resp'
|
||||
assert Proxy.mqtt.data == "+ok"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_dcu_cmd(my_loop, config_tsun_allow_all, dcu_dev_ind_msg, dcu_dev_rsp_msg, dcu_data_ind_msg, dcu_data_rsp_msg, dcu_command_ind_msg, dcu_command_rsp_msg):
|
||||
'''test dcu_power command fpr a DCU device with sensor 0x3026'''
|
||||
_ = config_tsun_allow_all
|
||||
@@ -2600,7 +2600,7 @@ async def test_dcu_cmd(my_loop, config_tsun_allow_all, dcu_dev_ind_msg, dcu_dev_
|
||||
assert Proxy.mqtt.data == "+ok"
|
||||
Proxy.mqtt.clear() # clear last test result
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_dcu_cmd_not_supported(my_loop, config_tsun_allow_all, device_ind_msg, device_rsp_msg, inverter_ind_msg, inverter_rsp_msg):
|
||||
'''test that an inverter don't accept the dcu_power command'''
|
||||
_ = config_tsun_allow_all
|
||||
@@ -2632,7 +2632,7 @@ async def test_dcu_cmd_not_supported(my_loop, config_tsun_allow_all, device_ind_
|
||||
assert m.sent_pdu == b''
|
||||
Proxy.mqtt.clear() # clear last test result
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_proxy_dcu_cmd(my_loop, config_tsun_dcu1, patch_open_connection, dcu_command_ind_msg, dcu_command_rsp_msg):
|
||||
_ = config_tsun_inv1
|
||||
_ = patch_open_connection
|
||||
|
||||
Reference in New Issue
Block a user