diff --git a/requirements-test.txt b/requirements-test.txt index b44d36c..d9ea615 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,2 +1,3 @@ pytest +pytest-mock swh.core[http] >= 0.0.61 diff --git a/swh/loader/svn/tests/test_task.py b/swh/loader/svn/tests/test_task.py index 7429b48..c2430f9 100644 --- a/swh/loader/svn/tests/test_task.py +++ b/swh/loader/svn/tests/test_task.py @@ -1,51 +1,50 @@ # Copyright (C) 2019 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information -from unittest.mock import patch - -@patch('swh.loader.svn.loader.SvnLoader.load') -def test_svn_loader( - mock_loader, swh_app, celery_session_worker, swh_config): +def test_svn_loader(mocker, swh_app, celery_session_worker, swh_config): + mock_loader = mocker.patch('swh.loader.svn.loader.SvnLoader.load') mock_loader.return_value = {'status': 'eventful'} res = swh_app.send_task( 'swh.loader.svn.tasks.LoadSvnRepository', (), dict(url='some-technical-url', origin_url='origin-url')) assert res res.wait() assert res.successful() assert res.result == {'status': 'eventful'} -@patch('swh.loader.svn.loader.SvnLoaderFromDumpArchive.load') def test_svn_loader_from_dump( - mock_loader, swh_app, celery_session_worker, swh_config): + mocker, swh_app, celery_session_worker, swh_config): + mock_loader = mocker.patch( + 'swh.loader.svn.loader.SvnLoaderFromDumpArchive.load') mock_loader.return_value = {'status': 'eventful'} res = swh_app.send_task( 'swh.loader.svn.tasks.MountAndLoadSvnRepository', (), dict(url='some-url', archive_path='some-path')) assert res res.wait() assert res.successful() assert res.result == {'status': 'eventful'} -@patch('swh.loader.svn.loader.SvnLoaderFromRemoteDump.load') def test_svn_loader_from_remote_dump( - mock_loader, swh_app, celery_session_worker, swh_config): + mocker, swh_app, celery_session_worker, swh_config): + mock_loader = mocker.patch( + 'swh.loader.svn.loader.SvnLoaderFromRemoteDump.load') mock_loader.return_value = {'status': 'eventful'} res = swh_app.send_task( 'swh.loader.svn.tasks.DumpMountAndLoadSvnRepository', (), dict(url='some-remote-dump-url', origin_url='origin-url')) assert res res.wait() assert res.successful() assert res.result == {'status': 'eventful'}