def test_regression_185(self):
        # Given
        repository_info1 = RepositoryInfo("repo1")

        packages_definition = textwrap.dedent(u"""\
        dummy 1.0.1-1
        dummy_with_appinst 1.0.0-1
        dummy_with_entry_points 1.0.0-1
        dummy_with_proxy 1.3.40-3
        dummy_with_proxy_scripts 1.0.0-1
        dummy_with_proxy_softlink 1.0.0-1
        nose 1.2.1-1
        nose 1.3.0-1
        nose 1.3.0-2\
        """)
        packages = self.packages_from_definition(packages_definition,
                                                 repository_info1)
        repository = Repository()

        package = packages[0]

        # When
        repository.find_packages(package.name)
        repository.add_package(package)

        # Then
        self.assertTrue(packages[0] in repository)
        self.assertEqual(len(repository), 1)
        self.assertEqual(list(repository), [package])
    def test_find_packages(self):
        # Given
        packages_definition = textwrap.dedent(u"""\
        dummy 1.0.1-1
        dummy_with_appinst 1.0.0-1
        dummy_with_entry_points 1.0.0-1
        dummy_with_proxy 1.3.40-3
        dummy_with_proxy_scripts 1.0.0-1
        dummy_with_proxy_softlink 1.0.0-1
        nose 1.3.0-1
        nose 1.2.1-1
        nose 1.3.0-2\
        """)
        packages = self.packages_from_definition(packages_definition)
        repository = Repository(packages)

        r_versions = (V("1.2.1-1"), V("1.3.0-1"), V("1.3.0-2"))

        # When
        packages = repository.find_packages("nose")

        # Then
        self.assertEqual(len(packages), 3)
        self.assertEqual(tuple(p.version for p in packages), r_versions)

        # When
        packages = repository.find_packages("non_existing_package")

        # Then
        self.assertEqual(len(packages), 0)
Esempio n. 3
0
    def test_find_packages(self):
        # Given
        packages_definition = textwrap.dedent(u"""\
        dummy 1.0.1-1
        dummy_with_appinst 1.0.0-1
        dummy_with_entry_points 1.0.0-1
        dummy_with_proxy 1.3.40-3
        dummy_with_proxy_scripts 1.0.0-1
        dummy_with_proxy_softlink 1.0.0-1
        nose 1.3.0-1
        nose 1.2.1-1
        nose 1.3.0-2\
        """)
        packages = self.packages_from_definition(packages_definition)
        repository = Repository(packages)

        r_versions = (V("1.2.1-1"), V("1.3.0-1"), V("1.3.0-2"))

        # When
        packages = repository.find_packages("nose")

        # Then
        self.assertEqual(len(packages), 3)
        self.assertEqual(tuple(p.version for p in packages), r_versions)

        # When
        packages = repository.find_packages("non_existing_package")

        # Then
        self.assertEqual(len(packages), 0)
Esempio n. 4
0
    def test_regression_185(self):
        # Given
        repository_info1 = RepositoryInfo("repo1")

        packages_definition = textwrap.dedent(u"""\
        dummy 1.0.1-1
        dummy_with_appinst 1.0.0-1
        dummy_with_entry_points 1.0.0-1
        dummy_with_proxy 1.3.40-3
        dummy_with_proxy_scripts 1.0.0-1
        dummy_with_proxy_softlink 1.0.0-1
        nose 1.2.1-1
        nose 1.3.0-1
        nose 1.3.0-2\
        """)
        packages = self.packages_from_definition(
            packages_definition, repository_info1
        )
        repository = Repository()

        package = packages[0]

        # When
        repository.find_packages(package.name)
        repository.add_package(package)

        # Then
        self.assertTrue(packages[0] in repository)
        self.assertEqual(len(repository), 1)
        self.assertEqual(list(repository), [package])
def _convert_upgrade_request_if_needed(request, remote_repositories,
                                       installed_repository):

    if len(request.jobs) == 1 and request.jobs[0].kind == JobType.upgrade:
        upgrade_request = attr.assoc(request, jobs=[])
        remote_repository = Repository()
        for repository in remote_repositories:
            remote_repository.update(repository)

        latest_packages = []
        for package in installed_repository:
            candidates = remote_repository.find_packages(package.name)
            # candidates may be empty (e.g. when repository configuration
            # changed, and an installed package is coming from a repository not
            # configured in the remote list)
            if len(candidates) > 0:
                latest_packages.append(candidates[-1])

        for p in latest_packages:
            upgrade_request.install(
                InstallRequirement._from_string("{} == {}".format(p.name, p.version))
            )

        return upgrade_request
    else:
        return request