Esempio n. 1
0
    def test_update_in_place(self):
        """
        Test update with defaults values in place.
        """

        group01 = {
            "defaults": {
                "enabled": True,
                "extra": ["test", "stage"]
            },
            "nodes": {
                "host01": {
                    "index": "foo",
                    "upstream": "bar"
                }
            },
        }

        host01 = {
            "enabled": True,
            "index": "foo",
            "upstream": "bar",
            "extra": ["test", "stage"],
        }

        defaults.update(group01["nodes"], group01["defaults"])
        self.assertEqual(group01["nodes"]["host01"], host01)
Esempio n. 2
0
    def test_update_in_place(self):
        '''
        Test update with defaults values in place.
        '''

        group01 = {
            'defaults': {
                'enabled': True,
                'extra': ['test', 'stage']
            },
            'nodes': {
                'host01': {
                    'index': 'foo',
                    'upstream': 'bar'
                }
            }
        }

        host01 = {
            'enabled': True,
            'index': 'foo',
            'upstream': 'bar',
            'extra': ['test', 'stage'],
        }

        defaults.update(group01['nodes'], group01['defaults'])
        self.assertEqual(group01['nodes']['host01'], host01)
Esempio n. 3
0
def test_update_with_defaults_none():
    group01 = {
        "defaults": {
            "enabled": True,
            "extra": ["test", "stage"]
        },
        "nodes": {
            "host01": {
                "index": "foo",
                "upstream": "bar"
            }
        },
    }

    host01 = {
        "index": "foo",
        "upstream": "bar",
    }

    defaults.update(group01["nodes"], None)
    assert group01["nodes"]["host01"] == host01
Esempio n. 4
0
def test_update_with_dest_none():
    group01 = {
        "defaults": {
            "enabled": True,
            "extra": ["test", "stage"]
        },
        "nodes": {
            "host01": {
                "index": "foo",
                "upstream": "bar"
            }
        },
    }

    ret = defaults.update(None, group01["defaults"], in_place=False)
    assert ret == {}