コード例 #1
0
def test_skip_upload_doesnt_match(response_kwargs):
    assert not upload.skip_upload(
        response=pretend.stub(**response_kwargs),
        skip_existing=True,
        package=package_file.PackageFile.from_filename(helpers.WHEEL_FIXTURE,
                                                       None),
    )
コード例 #2
0
def test_skip_upload_respects_skip_existing():
    assert not upload.skip_upload(
        response=pretend.stub(),
        skip_existing=False,
        package=package_file.PackageFile.from_filename(helpers.WHEEL_FIXTURE,
                                                       None),
    )
コード例 #3
0
def test_skip_existing_skips_files_on_repository(response_kwargs):
    assert upload.skip_upload(
        response=pretend.stub(**response_kwargs),
        skip_existing=True,
        package=package_file.PackageFile.from_filename(helpers.WHEEL_FIXTURE,
                                                       None),
    )
コード例 #4
0
ファイル: test_upload.py プロジェクト: timgates42/twine
def test_skip_upload_respects_skip_existing(monkeypatch):
    response = pretend.stub(
        status_code=400,
        reason='A file named "twine-1.5.0-py2.py3-none-any.whl" already '
        'exists for twine-1.5.0.')

    pkg = package.PackageFile.from_filename(WHEEL_FIXTURE, None)
    assert upload.skip_upload(
        response=response, skip_existing=False, package=pkg) is False
コード例 #5
0
ファイル: test_upload.py プロジェクト: warner/twine
def test_skip_existing_skips_files_already_on_PyPI(monkeypatch):
    response = pretend.stub(
        status_code=400,
        reason='A file named "twine-1.5.0-py2.py3-none-any.whl" already '
               'exists for twine-1.5.0.')

    pkg = package.PackageFile.from_filename(WHEEL_FIXTURE, None)
    assert upload.skip_upload(response=response,
                              skip_existing=True,
                              package=pkg) is True
コード例 #6
0
ファイル: test_upload.py プロジェクト: ojii/twine
def test_skip_existing_skips_files_already_on_pypiserver(monkeypatch):
    # pypiserver (https://pypi.python.org/pypi/pypiserver) responds with 409
    response = pretend.stub(
        status_code=409,
        reason='A file named "twine-1.5.0-py2.py3-none-any.whl" already '
        'exists for twine-1.5.0.')

    pkg = package.PackageFile.from_filename(WHEEL_FIXTURE, None)
    assert upload.skip_upload(
        response=response, skip_existing=True, package=pkg) is True
コード例 #7
0
ファイル: test_upload.py プロジェクト: timgates42/twine
def test_skip_existing_skips_files_already_on_nexus(monkeypatch):
    # Nexus Repository Manager (https://www.sonatype.com/nexus-repository-oss)
    # responds with 400 when the file already exists
    response = pretend.stub(
        status_code=400,
        reason="Repository does not allow updating assets: pypi for url: "
        "http://www.foo.bar")

    pkg = package.PackageFile.from_filename(WHEEL_FIXTURE, None)
    assert upload.skip_upload(
        response=response, skip_existing=True, package=pkg) is True
コード例 #8
0
ファイル: test_upload.py プロジェクト: Brightcells/twine
def test_skip_existing_skips_files_already_on_pypiserver(monkeypatch):
    # pypiserver (https://pypi.python.org/pypi/pypiserver) responds with 409
    response = pretend.stub(
        status_code=409,
        reason='A file named "twine-1.5.0-py2.py3-none-any.whl" already '
               'exists for twine-1.5.0.')

    pkg = package.PackageFile.from_filename(WHEEL_FIXTURE, None)
    assert upload.skip_upload(response=response,
                              skip_existing=True,
                              package=pkg) is True
コード例 #9
0
ファイル: test_upload.py プロジェクト: timgates42/twine
def test_skip_existing_skips_files_already_on_artifactory(monkeypatch):
    # Artifactory (https://jfrog.com/artifactory/) responds with 403
    # when the file already exists.
    response = pretend.stub(
        status_code=403,
        text="Not enough permissions to overwrite artifact "
        "'pypi-local:twine/1.5.0/twine-1.5.0-py2.py3-none-any.whl'"
        "(user 'twine-deployer' needs DELETE permission).")

    pkg = package.PackageFile.from_filename(WHEEL_FIXTURE, None)
    assert upload.skip_upload(
        response=response, skip_existing=True, package=pkg) is True
コード例 #10
0
    def upload(self, poet):
        """
        Upload packages represented by a Poet instance.

        :param poet: The Poet instance representing the package.
        :type poet: poet.poet.Poet
        """
        skip_existing = False
        dists = find_dists([
            os.path.join(os.path.join(poet.base_dir, 'dist'),
                         '{}-{}*'.format(poet.name, poet.version))
        ])

        uploads = [i for i in dists if not i.endswith(".asc")]

        for filename in uploads:
            package = PackageFile.from_filename(filename, None)
            skip_message = (
                " - Skipping <comment>{0}</> because it appears to already exist"
                .format(package.basefilename))

            # Note: The skip_existing check *needs* to be first, because otherwise
            #       we're going to generate extra HTTP requests against a hardcoded
            #       URL for no reason.
            if skip_existing and self._repository.package_is_uploaded(package):
                self._output.writeln(skip_message)
                continue

            resp = self._repository.upload(package)

            # Bug 92. If we get a redirect we should abort because something seems
            # funky. The behaviour is not well defined and redirects being issued
            # by PyPI should never happen in reality. This should catch malicious
            # redirects as well.
            if resp.is_redirect:
                raise RedirectDetected(
                    ('"{0}" attempted to redirect to "{1}" during upload.'
                     ' Aborting...').format(self._repository.url,
                                            resp.headers["location"]))

            if skip_upload(resp, skip_existing, package):
                self._output.writeln(skip_message)

                continue

            twine.utils.check_status_code(resp)

        # Bug 28. Try to silence a ResourceWarning by clearing the connection
        # pool.
        self._repository.close()