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
6eaa2984
Unverified
Commit
6eaa2984
authored
Feb 13, 2021
by
Paul Sanders
Committed by
GitHub
Feb 13, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring uploader into a fixture (#3679)
* Relates-to: #3155 converting duplicted code to fixture
parent
74ec1690
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
9 deletions
+10
-9
tests/console/commands/debug/test_resolve.py
+1
-1
tests/publishing/test_uploader.py
+9
-8
No files found.
tests/console/commands/debug/test_resolve.py
View file @
6eaa2984
...
...
@@ -10,7 +10,7 @@ def tester(command_tester_factory):
@pytest.fixture
(
autouse
=
True
)
def
_add_packages
(
repo
):
def
_
_
add_packages
(
repo
):
cachy020
=
get_package
(
"cachy"
,
"0.2.0"
)
cachy020
.
add_dependency
(
Factory
.
create_dependency
(
"msgpack-python"
,
">=0.5 <0.6"
))
...
...
tests/publishing/test_uploader.py
View file @
6eaa2984
...
...
@@ -16,9 +16,13 @@ def project(name):
return
fixtures_dir
/
name
def
test_uploader_properly_handles_400_errors
(
http
):
@pytest.fixture
def
uploader
():
return
Uploader
(
Factory
()
.
create_poetry
(
project
(
"simple_project"
)),
NullIO
())
def
test_uploader_properly_handles_400_errors
(
http
,
uploader
):
http
.
register_uri
(
http
.
POST
,
"https://foo.com"
,
status
=
400
,
body
=
"Bad request"
)
uploader
=
Uploader
(
Factory
()
.
create_poetry
(
project
(
"simple_project"
)),
NullIO
())
with
pytest
.
raises
(
UploadError
)
as
e
:
uploader
.
upload
(
"https://foo.com"
)
...
...
@@ -26,9 +30,8 @@ def test_uploader_properly_handles_400_errors(http):
assert
"HTTP Error 400: Bad Request"
==
str
(
e
.
value
)
def
test_uploader_properly_handles_403_errors
(
http
):
def
test_uploader_properly_handles_403_errors
(
http
,
uploader
):
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"
)
...
...
@@ -36,9 +39,8 @@ def test_uploader_properly_handles_403_errors(http):
assert
"HTTP Error 403: Forbidden"
==
str
(
e
.
value
)
def
test_uploader_properly_handles_301_redirects
(
http
):
def
test_uploader_properly_handles_301_redirects
(
http
,
uploader
):
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"
)
...
...
@@ -48,12 +50,11 @@ def test_uploader_properly_handles_301_redirects(http):
)
def
test_uploader_registers_for_appropriate_400_errors
(
mocker
,
http
):
def
test_uploader_registers_for_appropriate_400_errors
(
mocker
,
http
,
uploader
):
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"
)
...
...
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