def test_module_test_to_friend_and_back_fi(): try: test_client = connections.connect_test_module_client() test_client.enable_input_messages() friend_client = connections.connect_friend_module_client() friend_client.enable_input_messages() test_input_thread = test_client.wait_for_input_event_async( friend_to_test_input) friend_input_thread = friend_client.wait_for_input_event_async( test_to_friend_input) disconnect_edgehub() sent_message = test_utilities.max_random_string() test_client.send_output_event(test_to_friend_output, sent_message) connect_edgehub() midpoint_message = friend_input_thread.get(receive_timeout) assert midpoint_message == sent_message second_sent_message = test_utilities.max_random_string() friend_client.send_output_event(friend_to_test_output, second_sent_message) received_message = test_input_thread.get(receive_timeout) assert received_message == second_sent_message friend_client.disconnect() test_client.disconnect() finally: restart_edgehub(hard=True)
def test_module_method_from_friend_to_test(): """ invoke a method call from the friend module and respond to it from the test module """ module_client = connections.connect_test_module_client() friend_client = connections.connect_friend_module_client() do_module_method_call(friend_client, module_client, environment.edge_device_id, environment.module_id) module_client.disconnect() friend_client.disconnect()
async def test_module_method_from_friend_to_test_fi(): """ invoke a method call from the friend module and respond to it from the test module """ module_client = connections.connect_test_module_client() friend_client = connections.connect_friend_module_client() await asyncio.sleep(5) await do_module_method_call(friend_client, module_client, module_client.device_id, module_client.module_id) module_client.disconnect_sync() friend_client.disconnect_sync()
def test_module_to_friend_routing(): test_client = connections.connect_test_module_client() friend_client = connections.connect_friend_module_client() friend_client.enable_input_messages() friend_input_thread = friend_client.wait_for_input_event_async(test_to_friend_input) sent_message = test_utilities.max_random_string() test_client.send_output_event(test_to_friend_output, sent_message) received_message = friend_input_thread.get(receive_timeout) assert received_message == sent_message friend_client.disconnect() test_client.disconnect()
async def test_module_to_friend_routing(test_string): test_client = connections.connect_test_module_client() friend_client = connections.connect_friend_module_client() await friend_client.enable_input_messages() friend_input_future = asyncio.ensure_future( friend_client.wait_for_input_event(test_to_friend_input) ) await test_client.send_output_event(test_to_friend_output, test_string) received_message = await friend_input_future assert received_message == test_string friend_client.disconnect_sync() test_client.disconnect_sync()
async def test_module_to_friend_routing(sample_payload): payload = sample_payload() test_client = connections.connect_test_module_client() friend_client = connections.connect_friend_module_client() await friend_client.enable_input_messages() friend_input_future = asyncio.ensure_future( friend_client.wait_for_input_event(test_to_friend_input)) await test_client.send_output_event(test_to_friend_output, payload) received_message = await friend_input_future assert received_message == payload friend_client.disconnect_sync() test_client.disconnect_sync()
def test_module_method_from_friend_to_test_fi(): """ invoke a method call from the friend module and respond to it from the test module """ module_client = connections.connect_test_module_client() friend_client = connections.connect_friend_module_client() time.sleep(5) do_module_method_call( friend_client, module_client, get_current_config().test_module.device_id, get_current_config().test_module.module_id, ) module_client.disconnect() friend_client.disconnect()
def test_module_method_from_friend_to_test(): """ invoke a method call from the friend module and respond to it from the test module """ module_client = connections.connect_test_module_client() friend_client = connections.connect_friend_module_client() do_module_method_call( friend_client, module_client, runtime_config.test_module.device_id, runtime_config.test_module.module_id, ) module_client.disconnect() friend_client.disconnect()
def test_module_method_from_test_to_friend_fi(): """ invoke a method call from the test module and respond to it from the friend module """ module_client = connections.connect_test_module_client() friend_client = connections.connect_friend_module_client() time.sleep(5) do_module_method_call( module_client, friend_client, environment.edge_device_id, environment.friend_module_id, ) module_client.disconnect() friend_client.disconnect()
def friend(logger): friend = connections.connect_friend_module_client() yield friend logger(separator.format("friend module")) friend.disconnect_sync()