Пример #1
0
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
    def test_update(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.2.1-1
        nose 1.3.0-1
        nose 1.3.0-2\
        """)
        packages = self.packages_from_definition(packages_definition)

        # When
        repository = Repository(packages[:4])

        # Then
        self.assertEqual(len(repository), 4)

        # When
        repository.update(packages[4:])

        # Then
        self.assertEqual(len(repository), len(packages))
        self.assertEqual(list(repository), packages)
Пример #3
0
    def test_update(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.2.1-1
        nose 1.3.0-1
        nose 1.3.0-2\
        """)
        packages = self.packages_from_definition(packages_definition)

        # When
        repository = Repository(packages[:4])

        # Then
        self.assertEqual(len(repository), 4)

        # When
        repository.update(packages[4:])

        # Then
        self.assertEqual(len(repository), len(packages))
        self.assertEqual(list(repository), packages)