示例#1
0
    def test_cmp_by_priority_prefer_installed_multi_repositories(self):
        """
        Check packages from multiple repositories are sorted accordingt to
        repository priority.
        """
        numpy_1_6_0 = P("numpy-1.6.0")
        numpy_1_6_1 = P("numpy-1.6.1")
        numpy_1_7_0 = P("numpy-1.7.0")
        i_numpy_1_6_0 = P("numpy-1.6.0")

        remote_repository = Repository([numpy_1_7_0, numpy_1_6_1, numpy_1_6_0],
                                       "remote")
        installed_repository = Repository([i_numpy_1_6_0], "installed")

        r_sorted_packages = [
            i_numpy_1_6_0, numpy_1_7_0, numpy_1_6_1, numpy_1_6_0
        ]

        pool = Pool([installed_repository, remote_repository])
        pool.set_repository_order("installed", "remote")
        policy = DefaultPolicy()

        queue = [numpy_1_7_0, i_numpy_1_6_0, numpy_1_6_0, numpy_1_6_1]

        def _cmp(a, b):
            return policy.cmp_by_priority_prefer_installed(pool, {}, a, b)

        self.assertEqual(r_sorted_packages, sorted_with_cmp(queue, cmp=_cmp))
示例#2
0
        def _assert_sort_by_priority(package, r_sorted_packages):
            remote_repository = Repository(packages)
            pool = Pool([remote_repository])
            policy = DefaultPolicy()

            # We reverse the list to ensure queue is not originally in the
            # final order
            queue = reversed(packages)
            def _cmp(a, b):
                return policy.cmp_by_priority_prefer_installed(pool, {}, a, b)

            self.assertEqual(r_sorted_packages, sorted_with_cmp(queue, cmp=_cmp))
示例#3
0
        def _assert_sort_by_priority(package, r_sorted_packages):
            remote_repository = Repository(packages)
            pool = Pool([remote_repository])
            policy = DefaultPolicy()

            # We reverse the list to ensure queue is not originally in the
            # final order
            queue = reversed(packages)

            def _cmp(a, b):
                return policy.cmp_by_priority_prefer_installed(pool, {}, a, b)

            self.assertEqual(r_sorted_packages, sorted_with_cmp(queue,
                                                                cmp=_cmp))
示例#4
0
    def test_cmp_by_priority_prefer_installed_same_repository_simple(self):
        """
        Check packages from a same repository are sorted by their id.
        """
        numpy_1_6_0 = P("numpy-1.6.0")
        numpy_1_6_1 = P("numpy-1.6.1")
        numpy_1_7_0 = P("numpy-1.7.0")

        remote_repository = Repository([numpy_1_7_0, numpy_1_6_1, numpy_1_6_0], "remote")
        r_sorted_packages = [numpy_1_7_0, numpy_1_6_1, numpy_1_6_0]

        pool = Pool([remote_repository])
        policy = DefaultPolicy()

        queue = [numpy_1_7_0, numpy_1_6_0, numpy_1_6_1]
        def _cmp(a, b):
            return policy.cmp_by_priority_prefer_installed(pool, {}, a, b)

        self.assertEqual(r_sorted_packages, sorted_with_cmp(queue, cmp=_cmp))
示例#5
0
    def test_cmp_by_priority_prefer_installed_same_repository_simple(self):
        """
        Check packages from a same repository are sorted by their id.
        """
        numpy_1_6_0 = P("numpy-1.6.0")
        numpy_1_6_1 = P("numpy-1.6.1")
        numpy_1_7_0 = P("numpy-1.7.0")

        remote_repository = Repository([numpy_1_7_0, numpy_1_6_1, numpy_1_6_0],
                                       "remote")
        r_sorted_packages = [numpy_1_7_0, numpy_1_6_1, numpy_1_6_0]

        pool = Pool([remote_repository])
        policy = DefaultPolicy()

        queue = [numpy_1_7_0, numpy_1_6_0, numpy_1_6_1]

        def _cmp(a, b):
            return policy.cmp_by_priority_prefer_installed(pool, {}, a, b)

        self.assertEqual(r_sorted_packages, sorted_with_cmp(queue, cmp=_cmp))
示例#6
0
    def test_cmp_by_priority_prefer_installed_multi_repositories(self):
        """
        Check packages from multiple repositories are sorted accordingt to
        repository priority.
        """
        numpy_1_6_0 = P("numpy-1.6.0")
        numpy_1_6_1 = P("numpy-1.6.1")
        numpy_1_7_0 = P("numpy-1.7.0")
        i_numpy_1_6_0 = P("numpy-1.6.0")

        remote_repository = Repository([numpy_1_7_0, numpy_1_6_1, numpy_1_6_0], "remote")
        installed_repository = Repository([i_numpy_1_6_0], "installed")

        r_sorted_packages = [i_numpy_1_6_0, numpy_1_7_0, numpy_1_6_1, numpy_1_6_0]

        pool = Pool([installed_repository, remote_repository])
        pool.set_repository_order("installed", "remote")
        policy = DefaultPolicy()

        queue = [numpy_1_7_0, i_numpy_1_6_0, numpy_1_6_0, numpy_1_6_1]
        def _cmp(a, b):
            return policy.cmp_by_priority_prefer_installed(pool, {}, a, b)

        self.assertEqual(r_sorted_packages, sorted_with_cmp(queue, cmp=_cmp))