Esempio n. 1
0
    def test_set_obj_value_existing_path(self):
        # Arrange
        obj = {'test1': {'test2': [{'key1': 'val1'}]}}
        path = ('test1', 'test2')

        val = [{'key2': 'val2'}]

        expected_result = {
            'test1': {
                'test2': [
                    {
                        'key1': 'val1'
                    },
                    {
                        'key2': 'val2'
                    },
                ]
            }
        }

        # Act
        actual_result = util.set_obj_value(obj, path, val)

        # Assert
        self.assertEqual(expected_result, actual_result)
Esempio n. 2
0
    def test_set_obj_value_new_path_string(self):
        # Arrange
        obj = {}
        path = ('test1', 'test2')

        val = '42'

        expected_result = {'test1': {'test2': '42'}}

        # Act
        actual_result = util.set_obj_value(obj, path, val)

        # Assert
        self.assertEqual(expected_result, actual_result)