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
3c558566
Unverified
Commit
3c558566
authored
Mar 21, 2019
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tests
parent
d67cbbf1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
33 deletions
+23
-33
poetry/masonry/publishing/uploader.py
+2
-2
tests/conftest.py
+10
-0
tests/console/commands/test_publish.py
+3
-12
tests/masonry/publishing/test_uploader.py
+8
-19
No files found.
poetry/masonry/publishing/uploader.py
View file @
3c558566
...
...
@@ -94,7 +94,7 @@ class Uploader:
def
is_authenticated
(
self
):
return
self
.
_username
is
not
None
and
self
.
_password
is
not
None
def
upload
(
self
,
url
:
str
)
->
bool
:
def
upload
(
self
,
url
)
:
session
=
self
.
make_session
()
try
:
...
...
@@ -180,7 +180,7 @@ class Uploader:
return
data
def
_upload
(
self
,
session
,
url
)
->
bool
:
def
_upload
(
self
,
session
,
url
):
try
:
self
.
_do_upload
(
session
,
url
)
except
HTTPError
as
e
:
...
...
tests/conftest.py
View file @
3c558566
import
httpretty
import
os
import
pytest
import
shutil
...
...
@@ -62,3 +63,12 @@ def git_mock(mocker):
mocker
.
patch
(
"poetry.vcs.git.Git.checkout"
,
new
=
lambda
*
_
:
None
)
p
=
mocker
.
patch
(
"poetry.vcs.git.Git.rev_parse"
)
p
.
return_value
=
"9cf87a285a2d3fbb0b9fa621997b3acc3631ed24"
@pytest.fixture
def
http
():
httpretty
.
enable
()
yield
httpretty
httpretty
.
disable
()
tests/console/commands/test_publish.py
View file @
3c558566
import
httpretty
from
cleo.testers
import
ApplicationTester
@httpretty.activate
def
test_publish_returns_non_zero_code_for_upload_errors
(
app
,
app_tester
):
httpretty
.
register_uri
(
httpretty
.
POST
,
"https://upload.pypi.org/legacy/"
,
status
=
400
,
body
=
"Bad Request"
,
def
test_publish_returns_non_zero_code_for_upload_errors
(
app
,
app_tester
,
http
):
http
.
register_uri
(
http
.
POST
,
"https://upload.pypi.org/legacy/"
,
status
=
400
,
body
=
"Bad Request"
)
exit_code
=
app_tester
.
run
(
...
...
tests/masonry/publishing/test_uploader.py
View file @
3c558566
import
httpretty
import
pytest
import
shutil
...
...
@@ -31,11 +30,8 @@ def project(name):
return
Path
(
__file__
)
.
parent
/
"fixtures"
/
name
@httpretty.activate
def
test_uploader_properly_handles_400_errors
():
httpretty
.
register_uri
(
httpretty
.
POST
,
"https://foo.com"
,
status
=
400
,
body
=
"Bad request"
)
def
test_uploader_properly_handles_400_errors
(
http
):
http
.
register_uri
(
http
.
POST
,
"https://foo.com"
,
status
=
400
,
body
=
"Bad request"
)
uploader
=
Uploader
(
Poetry
.
create
(
project
(
"complete"
)),
NullIO
())
with
pytest
.
raises
(
UploadError
)
as
e
:
...
...
@@ -44,11 +40,8 @@ def test_uploader_properly_handles_400_errors():
assert
"HTTP Error 400: Bad Request"
==
str
(
e
.
value
)
@httpretty.activate
def
test_uploader_properly_handles_403_errors
():
httpretty
.
register_uri
(
httpretty
.
POST
,
"https://foo.com"
,
status
=
403
,
body
=
"Unauthorized"
)
def
test_uploader_properly_handles_403_errors
(
http
):
http
.
register_uri
(
http
.
POST
,
"https://foo.com"
,
status
=
403
,
body
=
"Unauthorized"
)
uploader
=
Uploader
(
Poetry
.
create
(
project
(
"complete"
)),
NullIO
())
with
pytest
.
raises
(
UploadError
)
as
e
:
...
...
@@ -57,18 +50,14 @@ def test_uploader_properly_handles_403_errors():
assert
"HTTP Error 403: Forbidden"
==
str
(
e
.
value
)
@httpretty.activate
def
test_uploader_registers_for_appropriate_400_errors
(
mocker
):
def
test_uploader_registers_for_appropriate_400_errors
(
mocker
,
http
):
register
=
mocker
.
patch
(
"poetry.masonry.publishing.uploader.Uploader._register"
)
httpretty
.
register_uri
(
httpretty
.
POST
,
"https://foo.com"
,
status
=
400
,
body
=
"No package was ever registered"
,
http
.
register_uri
(
http
.
POST
,
"https://foo.com"
,
status
=
400
,
body
=
"No package was ever registered"
)
uploader
=
Uploader
(
Poetry
.
create
(
project
(
"complete"
)),
NullIO
())
with
pytest
.
raises
(
UploadError
):
uploader
.
upload
(
"https://foo.com"
)
register
.
assert_called_once
()
assert
1
==
register
.
call_count
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