Exemplo n.º 1
0
    def test_merge_dicts_overlapping(self):
        low_priority = {'a': 'low_a', 'b': 'low_b', 'd': 'low_d'}
        high_priority = {'a': 'high_a', 'b': 'high_b', 'e': 'high_e'}
        expected = {'a': 'high_a', 'b': 'high_b', 'd': 'low_d', 'e': 'high_e'}

        self.assertDictEqual(expected,
                             utils.merge_dicts(low_priority, high_priority))
Exemplo n.º 2
0
    def merge(self, higher_priority_env):
        """
        Merge self with higher_priority_env.
        :param higher_priority_env: EnvvarCollector: environment to merge with
        :return EnvvarCollector
        """

        envvars_map = utils.merge_dicts(low_priority=self.map,
                                        high_priority=higher_priority_env.map)
        to_remove = self.to_remove | higher_priority_env.to_remove

        return EnvvarCollector(envvars_map, to_remove)
Exemplo n.º 3
0
    def merge(self, higher_priority_env):
        """
        Merge self with higher_priority_env.
        :param higher_priority_env: EnvvarCollector: environment to merge with
        :return EnvvarCollector
        """

        envvars_map = utils.merge_dicts(low_priority=self.map,
                                        high_priority=higher_priority_env.map)
        to_remove = self.to_remove | higher_priority_env.to_remove

        return EnvvarCollector(envvars_map, to_remove)
Exemplo n.º 4
0
    def test_merge_dicts_not_overlapping(self):
        low_priority = {1: 1, 2: 2, 3: 3}
        high_priority = {'a': 'high_a', 'b': 'high_b', 'e': 'high_e'}
        expected = {
            1: 1,
            2: 2,
            3: 3,
            'a': 'high_a',
            'b': 'high_b',
            'e': 'high_e'
        }

        self.assertDictEqual(expected,
                             utils.merge_dicts(low_priority, high_priority))
Exemplo n.º 5
0
 def test_merge_dicts_one_empty(self):
     mock_dict = {'abc': 123, 'bcd': 555}
     self.assertDictEqual(mock_dict, utils.merge_dicts(mock_dict, {}))
     self.assertDictEqual(mock_dict, utils.merge_dicts({}, mock_dict))
Exemplo n.º 6
0
 def test_merge_dicts_both_empty(self):
     self.assertDictEqual({}, utils.merge_dicts({}, {}))