def test_it_should_add_all_values(self): configs = [ { 'section1': { 'key1': 1 } }, { 'section2': { 'key2': 2 } }, { 'section3': { 'key3': 3 } }, ] result = merge(configs) assert_that( result, has_entries({ 'section1': has_entry('key1', 1), 'section2': has_entry('key2', 2), 'section3': has_entry('key3', 3), }))
def test_it_should_ignore_scalar_values_given_as_configs(self): configs = [ { 'section': { 'key': 1 } }, { 'section': None }, { 'section': { 'key': 2 } }, { 'section': [] }, { 'section': { 'key': 3 } }, ] result = merge(configs) assert_that(result, has_entry('section', has_entry('key', 3)))
def test_it_should_give_priority_to_last_value(self): configs = [ {'key': 1}, {'key': 2}, {'key': 3}, ] result = merge(configs) assert_that(result, has_entry('key', 3))
def test_it_should_merge_dicts_recursively(self): configs = [ {'section': {'lv1': {'lv2': {'lv3': 1}}}}, {'section': {'lv1': {'lv2': {'lv3': 2}}}}, {'section': {'lv1': {'lv2': {'lv3': 3}}}}, ] result = merge(configs) assert_that(result, has_entry( 'section', has_entry( 'lv1', has_entry( 'lv2', has_entry( 'lv3', 3))) ))