Exemplo n.º 1
0
    def test_merging_doc_example(self):
        a = {
            "a": {
                "foo": 1,
                "bar": True
            },
            "b": {
                "foo": 3,
                "bar": False,
                "nested": {
                    "a": 1,
                    "b": 2
                }
            }
        }
        b = {
            "a": {
                "baz": "hi"
            },
            "b": {
                "foo": 10,
                "baz": "boz",
                "nested": {
                    "b": 10
                }
            },
            "c": ["alice"]
        }
        c = {
            "c": ["bill", "ben"]
        }

        expected = {
            "a": {
                "foo": 1,
                "bar": True,
                "baz": "hi"
            },
            "b": {
                "foo": 10,
                "bar": False,
                "baz": "boz",
                "nested": {
                    "a": 1,
                    "b": 10
                }
            },
            "c": ["alice", "bill", "ben"]
        }
        self.assertEqual(jsonmerge.json_merge_all([a, b, c]), expected)
Exemplo n.º 2
0
    def test_merging_doc_example(self):
        a = {
            "a": {
                "foo": 1,
                "bar": True
            },
            "b": {
                "foo": 3,
                "bar": False,
                "nested": {
                    "a": 1,
                    "b": 2
                }
            }
        }
        b = {
            "a": {
                "baz": "hi"
            },
            "b": {
                "foo": 10,
                "baz": "boz",
                "nested": {
                    "b": 10
                }
            },
            "c": ["alice"]
        }
        c = {"c": ["bill", "ben"]}

        expected = {
            "a": {
                "foo": 1,
                "bar": True,
                "baz": "hi"
            },
            "b": {
                "foo": 10,
                "bar": False,
                "baz": "boz",
                "nested": {
                    "a": 1,
                    "b": 10
                }
            },
            "c": ["alice", "bill", "ben"]
        }
        self.assertEqual(jsonmerge.json_merge_all([a, b, c]), expected)
Exemplo n.º 3
0
 def test_merging_nothing_results_in_exception(self):
     with self.assertRaises(ValueError):
         jsonmerge.json_merge_all([])
Exemplo n.º 4
0
 def test_merging_nothing_results_in_exception(self):
     with self.assertRaises(ValueError):
         jsonmerge.json_merge_all([])