How to use the dictdiffer.utils.is_super_path 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_utils.py View on Github external
def test_is_super_path(self):
        # # True
        path1 = ('authors', 1, 'name')
        path2 = ('authors', 1, 'name')
        self.assertTrue(is_super_path(path1, path2))

        path1 = ('authors', 1)
        path2 = ('authors', 1, 'name')
        self.assertTrue(is_super_path(path1, path2))

        path1 = ('authors',)
        path2 = ('authors', 1, 'name')
        self.assertTrue(is_super_path(path1, path2))

        # # False
        path1 = ('authors', 1, 'name')
        path2 = ('authors', 1, 'surname')
        self.assertFalse(is_super_path(path1, path2))

        path1 = ('authors', 2)
        path2 = ('authors', 1, 'surname')
        self.assertFalse(is_super_path(path1, path2))

        path1 = ('author',)
        path2 = ('authors', 1, 'surname')
github inveniosoftware / dictdiffer / tests / test_utils.py View on Github external
path1 = ('authors', 1)
        path2 = ('authors', 1, 'name')
        self.assertTrue(is_super_path(path1, path2))

        path1 = ('authors',)
        path2 = ('authors', 1, 'name')
        self.assertTrue(is_super_path(path1, path2))

        # # False
        path1 = ('authors', 1, 'name')
        path2 = ('authors', 1, 'surname')
        self.assertFalse(is_super_path(path1, path2))

        path1 = ('authors', 2)
        path2 = ('authors', 1, 'surname')
        self.assertFalse(is_super_path(path1, path2))

        path1 = ('author',)
        path2 = ('authors', 1, 'surname')
        self.assertFalse(is_super_path(path1, path2))
github inveniosoftware / dictdiffer / dictdiffer / conflict.py View on Github external
The conditions are:
        1. The paths are identical
        2. On of the paths is the super path of the other

        :param patch1: First patch tuple
        :param patch2: First patch tuple
        """
        path1 = get_path(patch1)
        path2 = get_path(patch2)

        if path1 == path2:
            return True
        elif is_super_path(path1, path2) and patch1[0] == 'remove':
            return True
        elif is_super_path(path2, path1) and patch2[0] == 'remove':
            return True

        return False
github inveniosoftware / dictdiffer / dictdiffer / conflict.py View on Github external
def _is_conflict(self, patch1, patch2):
        """Decide on a conflict between two patches.

        The conditions are:
        1. The paths are identical
        2. On of the paths is the super path of the other

        :param patch1: First patch tuple
        :param patch2: First patch tuple
        """
        path1 = get_path(patch1)
        path2 = get_path(patch2)

        if path1 == path2:
            return True
        elif is_super_path(path1, path2) and patch1[0] == 'remove':
            return True
        elif is_super_path(path2, path1) and patch2[0] == 'remove':
            return True

        return False