Example #1
0
 def __init__(self, poetry: "Poetry", io: Union["BufferedIO",
                                                "ConsoleIO"]) -> None:
     self._poetry = poetry
     self._package = poetry.package
     self._io = io
     self._uploader = Uploader(poetry, io)
     self._authenticator = Authenticator(poetry.config, self._io)
Example #2
0
def test_uploader_properly_handles_403_errors(http):
    http.register_uri(http.POST, "https://foo.com", status=403, body="Unauthorized")
    uploader = Uploader(Factory().create_poetry(project("simple_project")), NullIO())

    with pytest.raises(UploadError) as e:
        uploader.upload("https://foo.com")

    assert "HTTP Error 403: Forbidden" == str(e.value)
Example #3
0
def test_uploader_registers_for_appropriate_400_errors(mocker, http):
    register = mocker.patch("poetry.publishing.uploader.Uploader._register")
    http.register_uri(
        http.POST, "https://foo.com", status=400, body="No package was ever registered"
    )
    uploader = Uploader(Factory().create_poetry(project("simple_project")), NullIO())

    with pytest.raises(UploadError):
        uploader.upload("https://foo.com")

    assert 1 == register.call_count
Example #4
0
def test_uploader_properly_handles_301_redirects(http):
    http.register_uri(http.POST,
                      "https://foo.com",
                      status=301,
                      body="Redirect")
    uploader = Uploader(Factory().create_poetry(project("simple_project")),
                        NullIO())

    with pytest.raises(UploadError) as e:
        uploader.upload("https://foo.com")

    assert "Redirects are not supported. Is the URL missing a trailing slash?" == str(
        e.value)
Example #5
0
 def __init__(self, poetry: Poetry, io: BufferedIO | ConsoleIO) -> None:
     self._poetry = poetry
     self._package = poetry.package
     self._io = io
     self._uploader = Uploader(poetry, io)
     self._authenticator = Authenticator(poetry.config, self._io)
Example #6
0
def uploader():
    return Uploader(Factory().create_poetry(project("simple_project")),
                    NullIO())
Example #7
0
def uploader(fixture_dir: "FixtureDirGetter") -> Uploader:
    return Uploader(Factory().create_poetry(fixture_dir("simple_project")),
                    NullIO())