def test_ensure_field_no_field(): builder = ConferenceBuilder() assert 'test_field' not in builder.record builder._ensure_field('test_field', default_value='test_value') assert 'test_field' in builder.record assert builder.record['test_field'] == 'test_value'
def test_ensure_field_separate(): builder = ConferenceBuilder() obj = {'field_one': 'value'} builder._ensure_field('test_field', default_value='test_value', obj=obj) builder._ensure_field('field_one', 'wrong_value', obj=obj) assert 'test_field' in obj assert obj['test_field'] == 'test_value' assert obj['field_one'] == 'value'