Verified Commit 3aaada54 authored by Huste, Tobias (FWCC) - 111645's avatar Huste, Tobias (FWCC) - 111645
Browse files

improve tests

parent e1351b9c
Pipeline #842 passed with stage
in 1 minute and 47 seconds
# -*- 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')
......@@ -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()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment