Exemplo n.º 1
0
def test_parse_streams_skips_stream_info_if_remove_config_and_channel_name_schema_and_topic_not_specified(
):
    message = serialise_rf5k(
        UpdateType.REMOVE,
        [StreamInfo("", "", "", Protocol.PVA)],
    )
    config_message = deserialise_rf5k(message)
    streams = tuple(_parse_streams(CommandType.REMOVE, config_message.streams))
    assert not streams
Exemplo n.º 2
0
def test_parse_streams_parses_valid_add_config():
    test_channel_name = "test_channel"
    message = serialise_rf5k(
        UpdateType.ADD,
        [StreamInfo(test_channel_name, "f142", "output_topic", Protocol.PVA)],
    )
    config_message = deserialise_rf5k(message)
    streams = tuple(_parse_streams(CommandType.ADD, config_message.streams))
    assert len(streams) == 1
    assert streams[0].name == test_channel_name
Exemplo n.º 3
0
def test_parse_streams_skips_stream_info_if_add_config_and_topic_not_specified(
):
    empty_topic = ""
    message = serialise_rf5k(
        UpdateType.ADD,
        [StreamInfo("test_channel", "f142", empty_topic, Protocol.PVA)],
    )
    config_message = deserialise_rf5k(message)
    streams = tuple(_parse_streams(CommandType.ADD, config_message.streams))
    assert not streams
Exemplo n.º 4
0
def test_remove_config_is_valid_if_channel_name_not_specified_but_topic_is():
    test_topic = "output_topic"
    message = serialise_rf5k(
        UpdateType.REMOVE,
        [StreamInfo("", "", test_topic, Protocol.PVA)],
    )
    config_message = deserialise_rf5k(message)
    streams = tuple(_parse_streams(CommandType.REMOVE, config_message.streams))
    assert len(streams) == 1
    assert streams[0].output_topic == test_topic
Exemplo n.º 5
0
def test_remove_config_is_valid_with_all_channel_info_specified():
    test_channel_name = "test_channel"
    message = serialise_rf5k(
        UpdateType.REMOVE,
        [StreamInfo(test_channel_name, "f142", "output_topic", Protocol.PVA)],
    )
    config_message = deserialise_rf5k(message)
    streams = tuple(_parse_streams(CommandType.REMOVE, config_message.streams))
    assert len(streams) == 1
    assert streams[0].name == test_channel_name
Exemplo n.º 6
0
def test_parse_streams_skips_stream_info_if_add_config_and_schema_not_recognised(
):
    nonexistent_schema = "NONEXISTENT"
    message = serialise_rf5k(
        UpdateType.ADD,
        [
            StreamInfo("test_channel", nonexistent_schema, "output_topic",
                       Protocol.PVA)
        ],
    )
    config_message = deserialise_rf5k(message)
    streams = tuple(_parse_streams(CommandType.ADD, config_message.streams))
    assert not streams
Exemplo n.º 7
0
def test_parse_streams_parses_valid_stream_after_skipping_invalid_stream():
    nonexistent_schema = "NONEXISTENT"
    valid_stream_channel_name = "test_valid_stream"
    message = serialise_rf5k(
        UpdateType.ADD,
        [
            StreamInfo("test_invalid_stream", nonexistent_schema,
                       "output_topic", Protocol.PVA),
            StreamInfo(valid_stream_channel_name, "f142", "output_topic",
                       Protocol.PVA),
        ],
    )
    config_message = deserialise_rf5k(message)
    streams = tuple(_parse_streams(CommandType.ADD, config_message.streams))
    assert len(streams) == 1
    assert streams[0].name == valid_stream_channel_name