コード例 #1
0
def test_append_to_field_some_simple_data():
    builder = ConferenceBuilder()

    builder._append_to('test_field', 'first_element')

    assert 'test_field' in builder.record
    assert builder.record['test_field'] == ['first_element']

    builder._append_to('test_field', 'second_element')

    assert builder.record['test_field'] == ['first_element', 'second_element']
コード例 #2
0
def test_append_to_field_from_kwargs():
    element_one = {
        'key': 'value',
        'list_key': ['some', 'values'],
        'dict_key': {
            'key': 'another_value',
            'something': 'else'
        }
    }

    element_two = {
        'key': 'value2',
        'other_list_key': ['some', 'values'],
    }

    builder = ConferenceBuilder()

    builder._append_to('some_field', **element_one)
    assert builder.record['some_field'] == [element_one]

    builder._append_to('some_field', element_two)
    assert builder.record['some_field'] == [element_one, element_two]
コード例 #3
0
def test_append_to_field_dumplicated_complex_data():
    element_one = {
        'key': 'value',
        'list_key': ['some', 'values'],
        'dict_key': {
            'key': 'another_value',
            'something': 'else'
        }
    }

    element_two = {
        'key': 'value2',
        'other_list_key': ['some', 'values'],
    }

    builder = ConferenceBuilder()

    builder._append_to('some_field', element_one)
    builder._append_to('some_field', element_two)
    builder._append_to('some_field', element_one)
    builder._append_to('some_field', element_two)

    assert builder.record['some_field'] == [element_one, element_two]