""" Unit tests for WebSocket transport plugin - virtual interface. Also test that our WebSocketDeviceAdapter works well with the HardwareManager. """ import json import queue import pytest import sys from devices_factory import build_report_device, build_tracing_device, get_tracing_device_string if sys.platform.startswith("win"): pytest.skip("skipping unix socket tests", allow_module_level=True) tracing_device_string = get_tracing_device_string() # Get traces sent from the config file with open(tracing_device_string.split('@')[-1], "r") as conf_file: config = json.load(conf_file) traces_sent = config['device']['ascii_data'] @pytest.mark.parametrize('server', [build_report_device()], indirect=True) def test_probe(hw): devices = hw.scan() assert isinstance(devices, list) assert len(devices) == 1 report_device = devices[0] assert report_device['uuid'] == 0x10
Unit tests for WebSocket transport plugin - ws handler in gateway agent. Also test that our WebSocketDeviceAdapter works well alone. """ import json import pytest import struct import threading import sys from devices_factory import build_report_device, build_tracing_device, get_tracing_device_string if sys.platform.startswith("win"): pytest.skip("skipping unix socket tests", allow_module_level=True) # Get traces sent from the config file with open(get_tracing_device_string().split('@')[-1], "r") as conf_file: config = json.load(conf_file) traces_sent = config['device']['ascii_data'] @pytest.mark.parametrize('server', [build_report_device()], indirect=True) def test_probe(device_adapter): scanned_devices = [] def on_scan_callback(adapter, device, expiration_time): scanned_devices.append(device) device_adapter.add_callback('on_scan', on_scan_callback) result = device_adapter.probe_sync() assert result['success'] is True