Exemplo n.º 1
0
def test_has_platform_adapter(test_case, protocol_gateway):
    pg_config = ProtocolGateway.create_default_configuration([{'platform': True}])
    test_case.assertEqual(True, protocol_gateway.has_platform_adapter(pg_config),
                          'ProtocolGateway should have a platform adapter!')

    pg_config = ProtocolGateway.create_default_configuration([{}])
    test_case.assertEqual(False, protocol_gateway.has_platform_adapter(pg_config),
                          'ProtocolGateway should not have a platform adapter!')
Exemplo n.º 2
0
def test_init_protocol_gateway(test_case):
    # create a configuration with 2 adapters: 1 platform and 1 not, the PG (use_platform_protocol_only=True) should filter only 1 of them
    mqtt_def_config_1 = MqttProtocolAdapter.create_default_configuration(is_platform_protocol=False)
    mqtt_def_config_2 = MqttProtocolAdapter.create_default_configuration(is_platform_protocol=True)
    protocol_gateway_config = ProtocolGateway.create_default_configuration([mqtt_def_config_1, mqtt_def_config_2])
    protocol_gateway = ProtocolGateway(protocol_gateway_config, 'TestProtocolGateway', use_platform_protocol_only=True)

    test_case.assertEqual(1, len(protocol_gateway.adapters))
Exemplo n.º 3
0
async def test_validate_platform_protocol_usage(test_case):
    mqtt_def_config = MqttProtocolAdapter.create_default_configuration(is_platform_protocol=True)
    protocol_gateway_config = ProtocolGateway.create_default_configuration([mqtt_def_config])
    protocol_gateway = ProtocolGateway(protocol_gateway_config, 'TestProtocolGateway', use_platform_protocol_only=True)
    publish_options = ProtocolGateway.create_publish_options(platform_protocol_only=False)
    with pytest.raises(Exception) as exc_info:
        await protocol_gateway.publish("test_topic", "test message", publish_options)
    test_case.assertEqual(
        f'Gateway is configured to only use the provided platform protocol. Runtime request for all protocols given.',
        str(exc_info.value))
Exemplo n.º 4
0
def protocol_gateway():
    mqtt_def_config = MqttProtocolAdapter.create_default_configuration(
        is_platform_protocol=True)
    protocol_gateway_config = ProtocolGateway.create_default_configuration(
        [mqtt_def_config])
    return ProtocolGateway(protocol_gateway_config, 'TestProtocolGateway')
        def __init__(self):
            mqtt_config = MqttProtocolAdapter.create_default_configuration()
            pg_config = ProtocolGateway.create_default_configuration(
                [mqtt_config])

            super().__init__('test-func-talent', pg_config)
Exemplo n.º 6
0
        def __init__(self):
            mocker.patch('src.iotea.core.talent.uuid4', wraps=mock_uuid)
            mqtt_config = MqttProtocolAdapter.create_default_configuration()
            pg_config = ProtocolGateway.create_default_configuration([mqtt_config])

            super().__init__('test-talent', pg_config)