コード例 #1
0
 def test_lower_precedence(self):
     new_doc = {'name': 'molly', 'identifiers': ['bar:xyz'],
             'bar_url': 'https://github.com/mollyproject/mollyproject'}
     merged_doc = merge_docs(self.current_doc, new_doc, 9)
     self.assertEqual(self.current_doc['name'], merged_doc['name'])
     self.assertEqual(self.current_doc['meta_precedence'], merged_doc['meta_precedence'])
     self.assertEqual(new_doc['bar_url'], merged_doc['bar_url'])
     self.assertEqual(set(['foo:123', 'bar:xyz']), set(merged_doc['identifiers']))
コード例 #2
0
 def test_merge_direction(self):
     """Tests the new document values are copied over to the current doc"""
     key = 'mykey'
     original_value = 'some value'
     current_doc = {key: original_value}
     new_doc = {key: 'some other value'}
     merged_doc = merge_docs(current_doc, new_doc, 9)
     self.assertEqual(merged_doc[key], new_doc[key])
     # original value changed
     self.assertNotEqual(merged_doc[key], original_value)