Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
RODARE
invenio-uploadbyurl
Commits
3aaada54
Verified
Commit
3aaada54
authored
Oct 17, 2017
by
Huste, Tobias (FWCC) - 111645
Browse files
improve tests
parent
e1351b9c
Pipeline
#842
passed with stage
in 1 minute and 47 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
tests/test_tasks.py
0 → 100644
View file @
3aaada54
# -*- coding: utf-8 -*-
#
# This file is part of RODARE.
# Copyright (C) 2017 HZDR.
#
# RODARE is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# RODARE is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with RODARE; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307, USA.
"""Task tests."""
from
__future__
import
absolute_import
,
print_function
import
mock
import
pytest
from
celery.exceptions
import
OperationalError
,
Retry
from
invenio_uploadbyurl.tasks
import
download_files
@
mock
.
patch
(
'invenio_uploadbyurl.tasks.create_objectversion_from_url'
)
def
test_download_files
(
mock_createov
,
bucket
):
"""Test download files celery task."""
mock_createov
.
side_effect
=
OperationalError
()
with
pytest
.
raises
(
OperationalError
):
download_files
.
delay
(
bucket
.
id
,
'https://test.de/download.png'
)
tests/test_views.py
View file @
3aaada54
...
...
@@ -76,6 +76,10 @@ def test_post_api(client, bucket, user):
assert
resp
.
status_code
==
202
assert
str
(
bucket
.
id
)
in
_redisstore
.
keys
()
# test request without given key
url
=
url_for
(
'invenio_uploadbyurl.uploadbyurl_api'
,
bucket_id
=
bucket
.
id
,
url
=
"https://www.hzdr.de/db/PicOri?pOid=52010"
)
resp
=
client
.
post
(
url
)
assert
resp
.
status_code
==
202
assert
str
(
bucket
.
id
)
in
_redisstore
.
keys
()
...
...
Write
Preview
Supports
Markdown
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