How to use the dictdiffer.merge.UnresolvedConflictsException function in dictdiffer

To help you get started, we’ve selected a few dictdiffer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github inveniosoftware / dictdiffer / tests / test_merge.py View on Github external
def test_run(self):
        lca = {'changeme': 'Jo'}
        first = {'changeme': 'Joe'}
        second = {'changeme': 'John'}

        m = Merger(lca, first, second, {})

        self.assertRaises(UnresolvedConflictsException, m.run)
github inveniosoftware / dictdiffer / tests / test_merge.py View on Github external
def test_continue_run_multiple_conflicts_per_patch(self):
        lca = {'foo': [{'x': 1}, {'y': 2}]}
        first = {'foo': [{'x': 1}, {'y': 2}, {'z': 4}]}
        second = {'bar': 'baz'}

        expected = {
            'f': {'foo': [{'x': 1}, {'y': 2}, {'z': 4}],
                  'bar': 'baz'},
            's': {'bar': 'baz'}}

        for resolution, expected_value in expected.items():
            m = Merger(lca, first, second, {})
            try:
                m.run()
            except UnresolvedConflictsException as e:
                m.continue_run([resolution for _ in e.content])

            self.assertEqual(patch(m.unified_patches, lca),
                             expected_value)
github mozilla-releng / balrog / auslib / db.py View on Github external
# Merger merges the patches into a single unified patch,
                        # but we need dictdiffer.patch to actually apply the patch
                        # to the original blob
                        unified_blob = dictdiffer.patch(m.unified_patches, ancestor_blob)
                        # converting the resultant dict into a blob and then
                        # converting it to JSON
                        what['data'] = unified_blob
                        # we want the data_version for the dictdiffer.merged blob to be one
                        # more than that of the latest blob
                        tip_data_version = tip_release['data_version']
                        super(Releases, self).update(where={"name": name}, what=what, changed_by=changed_by, old_data_version=tip_data_version,
                                                     transaction=transaction, dryrun=dryrun)
                        # cache will have a data_version of one plus the tip
                        # data_version
                        new_data_version = tip_data_version + 1
                    except dictdiffer.merge.UnresolvedConflictsException:
                        self.log.debug("latest version of release %s cannot be merged with new blob" % name)
                        raise e
            if not dryrun:
                cache.put("blob", name, {"data_version": new_data_version, "blob": blob})
                cache.put("blob_version", name, new_data_version)