def test_merge_multiple_by(self):
     source = {
         "x": {
             "by-foo": {
                 "quick": "fox",
                 "default": ["a", "b", "c"]
             }
         }
     }
     dest = {
         "x": {
             "by-bar": {
                 "purple": "rain",
                 "default": ["x", "y", "z"]
             }
         }
     }
     expected = {
         "x": {
             "by-foo": {
                 "quick": "fox",
                 "default": ["a", "b", "c"]
             }
         }
     }  # source wins
     self.assertEqual(merge_to(source, dest), expected)
 def test_merge_to_dicts(self):
     source = {"a": 1, "b": 2}
     dest = {"b": "20", "c": 30}
     expected = {
         "a": 1,  # source only
         "b": 2,  # source overrides dest
         "c": 30,  # dest only
     }
     self.assertEqual(merge_to(source, dest), expected)
     self.assertEqual(dest, expected)
 def test_merge_diff_types(self):
     source = {"x": [1, 2]}
     dest = {"x": "abc"}
     expected = {"x": [1, 2]}  # source wins
     self.assertEqual(merge_to(source, dest), expected)
     self.assertEqual(dest, expected)
 def test_merge_to_lists(self):
     source = {"x": [3, 4]}
     dest = {"x": [1, 2]}
     expected = {"x": [1, 2, 3, 4]}  # dest first
     self.assertEqual(merge_to(source, dest), expected)
     self.assertEqual(dest, expected)