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']
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]
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]