def test_merge_different_types_strict(strict_config): base = NodeMap('base', {'merged_key': {'a': 'b'}}) other = NodeMap('other', {'merged_key': 1}) with pytest.raises(RuntimeError) as error: merge_factory(base, other, strict_config) error_message = ("Cannot merge `{'a': 'b'}` and `1` with key `merged_key`") assert str(error.value) == error_message
def merge(self, other: LayerProtocol) -> None: """Implement merge functionality.""" self.__tree = merge_factory(self.tree(), other.tree(), self.config)
def test_merge_nodemap_nodemap_empty(default_config): base = NodeMap('base', {}) other = NodeMap('other', {}) expected = NodeMap('expected', {}) assert merge_factory(base, other, default_config) == expected
def test_merge_nodemap_nodemap_override(default_config): base = NodeMap('base', {'db': {'master': {'host': 'base'}}}) other = NodeMap('other', {'db': {'master': {'host': 'other'}}}) result = merge_factory(base, other, default_config) assert result.db.master.host == 'other'
def test_merge_nodemap_nodemap_extend(default_config): base = NodeMap('base', {'master': {'host': 'master'}}) other = NodeMap('other', {'slave': {'host': 'slave'}}) result = merge_factory(base, other, default_config) assert 'master' in result assert 'slave' in result
def test_merge_node_node(default_config): base = Node('base', 'node_A') other = Node('other', 'node_B') assert merge_factory(base, other, default_config) == other
def test_merge_nodemap_nodelist(default_config): base = NodeMap('base', {'db': {'master': {'host': 'base'}}}) other = NodeList('base', [1]) assert merge_factory(base, other, default_config) == other
def test_merge_nodelist_nodelist_extend(extend_list_config): base = NodeList('base', [1]) other = NodeList('other', [2]) expected = NodeList('base', [1, 2]) assert merge_factory(base, other, extend_list_config) == expected
def test_merge_nodelist_nodelist_override(default_config): base = NodeList('base', [1]) other = NodeList('other', [2]) assert merge_factory(base, other, default_config) == other
def test_merge_node_nodemap(default_config): base = Node('base', 'node_A') other = NodeMap('other', {'db': {'master': {'host': 'other'}}}) assert merge_factory(base, other, default_config) == other