Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 846f1e70 authored by LETORT Sebastien's avatar LETORT Sebastien
Browse files

[test]minor corrections.

parent cb5fa480
No related branches found
No related tags found
2 merge requests!4Client api,!3Better coverage
#! /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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment