Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python-poetry
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
python-poetry
Commits
3f7545d6
Commit
3f7545d6
authored
May 24, 2020
by
Dan Hipschman
Committed by
finswimmer
Aug 15, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Display better messages on legacy repo HTTP errors
parent
5dd5411e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
0 deletions
+39
-0
poetry/repositories/legacy_repository.py
+5
-0
tests/repositories/test_legacy_repository.py
+34
-0
No files found.
poetry/repositories/legacy_repository.py
View file @
3f7545d6
...
@@ -27,6 +27,7 @@ from poetry.utils.patterns import wheel_file_re
...
@@ -27,6 +27,7 @@ from poetry.utils.patterns import wheel_file_re
from
..inspection.info
import
PackageInfo
from
..inspection.info
import
PackageInfo
from
.auth
import
Auth
from
.auth
import
Auth
from
.exceptions
import
PackageNotFound
from
.exceptions
import
PackageNotFound
from
.exceptions
import
RepositoryError
from
.pypi_repository
import
PyPiRepository
from
.pypi_repository
import
PyPiRepository
...
@@ -361,8 +362,12 @@ class LegacyRepository(PyPiRepository):
...
@@ -361,8 +362,12 @@ class LegacyRepository(PyPiRepository):
def
_get
(
self
,
endpoint
):
# type: (str) -> Union[Page, None]
def
_get
(
self
,
endpoint
):
# type: (str) -> Union[Page, None]
url
=
self
.
_url
+
endpoint
url
=
self
.
_url
+
endpoint
try
:
response
=
self
.
session
.
get
(
url
)
response
=
self
.
session
.
get
(
url
)
if
response
.
status_code
==
404
:
if
response
.
status_code
==
404
:
return
return
response
.
raise_for_status
()
except
requests
.
HTTPError
as
e
:
raise
RepositoryError
(
e
)
return
Page
(
url
,
response
.
content
,
response
.
headers
)
return
Page
(
url
,
response
.
content
,
response
.
headers
)
tests/repositories/test_legacy_repository.py
View file @
3f7545d6
...
@@ -5,6 +5,7 @@ import pytest
...
@@ -5,6 +5,7 @@ import pytest
from
poetry.core.packages
import
Dependency
from
poetry.core.packages
import
Dependency
from
poetry.repositories.auth
import
Auth
from
poetry.repositories.auth
import
Auth
from
poetry.repositories.exceptions
import
PackageNotFound
from
poetry.repositories.exceptions
import
PackageNotFound
from
poetry.repositories.exceptions
import
RepositoryError
from
poetry.repositories.legacy_repository
import
LegacyRepository
from
poetry.repositories.legacy_repository
import
LegacyRepository
from
poetry.repositories.legacy_repository
import
Page
from
poetry.repositories.legacy_repository
import
Page
from
poetry.utils._compat
import
PY35
from
poetry.utils._compat
import
PY35
...
@@ -278,3 +279,36 @@ def test_username_password_special_chars():
...
@@ -278,3 +279,36 @@ def test_username_password_special_chars():
repo
=
MockRepository
(
auth
=
auth
)
repo
=
MockRepository
(
auth
=
auth
)
assert
"http://user
%3
A:
%2
F
%252
Fp
%40
ssword@legacy.foo.bar"
==
repo
.
authenticated_url
assert
"http://user
%3
A:
%2
F
%252
Fp
%40
ssword@legacy.foo.bar"
==
repo
.
authenticated_url
class
MockHttpRepository
(
LegacyRepository
):
def
__init__
(
self
,
endpoint_responses
,
http
):
base_url
=
"http://legacy.foo.bar"
super
(
MockHttpRepository
,
self
)
.
__init__
(
"legacy"
,
url
=
base_url
,
auth
=
None
,
disable_cache
=
True
)
for
endpoint
,
response
in
endpoint_responses
.
items
():
url
=
base_url
+
endpoint
http
.
register_uri
(
http
.
GET
,
url
,
status
=
response
)
def
test_get_200_returns_page
(
http
):
repo
=
MockHttpRepository
({
"/foo"
:
200
},
http
)
assert
repo
.
_get
(
"/foo"
)
def
test_get_404_returns_none
(
http
):
repo
=
MockHttpRepository
({
"/foo"
:
404
},
http
)
assert
repo
.
_get
(
"/foo"
)
is
None
def
test_get_4xx_and_5xx_raises
(
http
):
endpoints
=
{
"/{}"
.
format
(
code
):
code
for
code
in
{
401
,
403
,
500
}}
repo
=
MockHttpRepository
(
endpoints
,
http
)
for
endpoint
in
endpoints
:
with
pytest
.
raises
(
RepositoryError
):
repo
.
_get
(
endpoint
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment