Exemple #1
0
def test_set_message_fields_none():
    # Smoke-test on a bunch of messages
    msgs = []
    msgs.extend(message_fixtures.get_msg_arrays())
    msgs.extend(message_fixtures.get_msg_basic_types())
    msgs.extend(message_fixtures.get_msg_bounded_sequences())
    msgs.extend(message_fixtures.get_msg_builtins())
    msgs.extend(message_fixtures.get_msg_constants())
    msgs.extend(message_fixtures.get_msg_defaults())
    msgs.extend(message_fixtures.get_msg_empty())
    msgs.extend(message_fixtures.get_msg_multi_nested())
    msgs.extend(message_fixtures.get_msg_nested())
    msgs.extend(message_fixtures.get_msg_strings())
    msgs.extend(message_fixtures.get_msg_unbounded_sequences())

    for m in msgs:
        original_m = copy.copy(m)
        set_message_fields(m, {})
        # Assert message is not modified when setting no fields
        assert original_m == m
def test_primitives():
    # Smoke-test the formatters on a bunch of messages
    msgs = []
    msgs.extend(message_fixtures.get_msg_arrays())
    msgs.extend(message_fixtures.get_msg_basic_types())
    msgs.extend(message_fixtures.get_msg_bounded_sequences())
    msgs.extend(message_fixtures.get_msg_builtins())
    msgs.extend(message_fixtures.get_msg_constants())
    msgs.extend(message_fixtures.get_msg_defaults())
    msgs.extend(message_fixtures.get_msg_empty())
    msgs.extend(message_fixtures.get_msg_multi_nested())
    msgs.extend(message_fixtures.get_msg_nested())
    msgs.extend(message_fixtures.get_msg_strings())
    msgs.extend(message_fixtures.get_msg_unbounded_sequences())
    for m in msgs:
        message_to_csv(m, 100)
        message_to_csv(m, None)
        message_to_ordereddict(m, 100)
        message_to_ordereddict(m, None)
        message_to_yaml(m, 100)
        message_to_yaml(m, None)
Exemple #3
0
def test_primitives():
    register_yaml_representer()
    # Smoke-test the formatters on a bunch of messages
    msgs = []
    msgs.extend(message_fixtures.get_msg_bounded_array_nested())
    msgs.extend(message_fixtures.get_msg_bounded_array_primitives())
    msgs.extend(message_fixtures.get_msg_builtins())
    msgs.extend(message_fixtures.get_msg_dynamic_array_nested())
    msgs.extend(message_fixtures.get_msg_dynamic_array_primitives())
    msgs.extend(message_fixtures.get_msg_dynamic_array_primitives_nested())
    msgs.extend(message_fixtures.get_msg_empty())
    msgs.extend(message_fixtures.get_msg_nested())
    msgs.extend(message_fixtures.get_msg_primitives())
    msgs.extend(message_fixtures.get_msg_static_array_nested())
    msgs.extend(message_fixtures.get_msg_static_array_primitives())
    args = Namespace()
    args.full_length = False
    args.truncate_length = DEFAULT_TRUNCATE_LENGTH
    for m in msgs:
        msg_to_yaml(args, m)
        msg_to_csv(args, m)