def test_merging_plain_descriptors(): desc1 = TestDescriptor({'name': 'foo', 'a': 1, 'b': 2}) desc2 = TestDescriptor({'name': 'foo', 'b': 5, 'c': 3}) expected = TestDescriptor({'name': 'foo', 'a': 1, 'b': 2, 'c': 3}) assert expected == _merge_descriptors(desc1, desc2) assert expected.items() == _merge_descriptors(desc1, desc2).items()
def test_merging_description_override(): desc1 = Image({'name': 'foo', 'version': 1}, None) desc2 = Overrides({'name': 'mod1', 'description': 'mod_desc'}) merged = _merge_descriptors(desc2, desc1) assert 'description' in merged
def test_merging_description_modules(): desc1 = Module({'name': 'foo'}, None) desc2 = Module({'name': 'mod1', 'description': 'mod_desc'}, None) merged = _merge_descriptors(desc1, desc2) assert 'description' not in merged
def test_merging_emdedded_descriptors(): desc1 = TestDescriptor({ 'name': 'a', 'a': 1, 'b': { 'name': 'b', 'b1': 10, 'b2': 20 } }) desc2 = TestDescriptor({ 'b': { 'name': 'b', 'b2': 50, 'b3': 30 }, 'c': { 'name': 'c' } }) expected = TestDescriptor({ 'name': 'a', 'a': 1, 'b': { 'name': 'b', 'b1': 10, 'b2': 20, 'b3': 30 }, 'c': { 'name': 'c' } }) assert expected == _merge_descriptors(desc1, desc2)