Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
python_client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
GitLab upgrade completed. Current version is 17.11.4.
Show more breadcrumbs
allgo
API-Clients
python_client
Commits
846f1e70
Commit
846f1e70
authored
5 years ago
by
LETORT Sebastien
Browse files
Options
Downloads
Patches
Plain Diff
[test]minor corrections.
parent
cb5fa480
No related branches found
No related tags found
2 merge requests
!4
Client api
,
!3
Better coverage
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_allgo.py
+15
-6
15 additions, 6 deletions
tests/test_allgo.py
with
15 additions
and
6 deletions
tests/test_allgo.py
+
15
−
6
View file @
846f1e70
#! /usr/bin/env python3
"""
Unit tests for Allgo module.
Notes:
cf https://docs.pytest.org/en/latest/contents.html
tmp_path is a pytest fixture.
"""
# standard lib
import
errno
import
os
...
...
@@ -31,7 +37,6 @@ class TestStatusError:
{
'
error
'
:
self
.
REF_MSG
}
return
m
@pytest.mark.dbg
def
test_msg
(
self
,
response
):
err
=
StatusError
(
42
,
response
)
assert
self
.
REF_MSG
==
err
.
msg
...
...
@@ -223,7 +228,7 @@ def test_create_job__param_error(mock_post, client):
@pytest.mark.success
@patch
(
'
allgo.requests.post
'
)
def
test_create_job
(
mock_post
,
client
):
def
test_create_job
__response
(
mock_post
,
client
):
# -- mock
job_id
=
33
job_url
=
"
http://job_url
"
...
...
@@ -397,12 +402,13 @@ def __mock_file(mock_get):
@pytest.mark.success
@patch
(
'
allgo.requests.get
'
)
def
test_download_file__default
(
mock_get
,
client
):
"""
The method returns the filepath where the file has been written.
"""
"""
The method returns the filepath where the file has been written,
outdir is the localdir by default.
"""
# -- mock
file_content
=
__mock_file
(
mock_get
)
# -- tests
filename
=
tempfile
.
mktemp
(
dir
=
''
)
filename
=
'
wanted_file
'
file_url
=
"
https://whatever.fr/
"
+
filename
filepath
=
client
.
download_file
(
file_url
)
...
...
@@ -440,7 +446,10 @@ def test_download_file__outdir(mock_get, client, tmp_path):
@pytest.mark.success
@patch
(
'
allgo.requests.get
'
)
def
test_download_file__force
(
mock_get
,
client
):
"""
The method returns the filepath where the file has been written.
"""
"""
If the output file already exists,
the force param, False by default result in an OSError,
if force is set to True, no error should be raised.
"""
# -- mock
file_content
=
__mock_file
(
mock_get
)
...
...
@@ -453,7 +462,7 @@ def test_download_file__force(mock_get, client):
# default is to raise an exception if the file exists.
# ~ with pytest.raises(FileExistsError): # python3
with
pytest
.
raises
(
OSError
)
as
err_info
:
filepath
=
client
.
download_file
(
file_url
)
# default is force=False
filepath
=
client
.
download_file
(
file_url
,
force
=
False
)
# default
err
=
err_info
.
value
assert
errno
.
EEXIST
==
err
.
errno
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment