Exemple #1
0
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
Exemple #2
0
 def merge(self, other: LayerProtocol) -> None:
     """Implement merge functionality."""
     self.__tree = merge_factory(self.tree(), other.tree(), self.config)
Exemple #3
0
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
Exemple #4
0
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'
Exemple #5
0
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
Exemple #6
0
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
Exemple #7
0
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
Exemple #8
0
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
Exemple #9
0
def test_merge_nodelist_nodelist_override(default_config):
    base = NodeList('base', [1])
    other = NodeList('other', [2])
    assert merge_factory(base, other, default_config) == other
Exemple #10
0
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