diff --git a/requirements-test.txt b/requirements-test.txt index e8e0b30..1b87a41 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,3 +1,4 @@ pytest +pytest-mock swh.core[http] >= 0.0.61 swh.scheduler[testing] diff --git a/swh/loader/mercurial/tests/test_tasks.py b/swh/loader/mercurial/tests/test_tasks.py index e130c42..6e050d7 100644 --- a/swh/loader/mercurial/tests/test_tasks.py +++ b/swh/loader/mercurial/tests/test_tasks.py @@ -1,40 +1,40 @@ -# Copyright (C) 2018 The Software Heritage developers +# Copyright (C) 2018-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.mercurial.loader.HgBundle20Loader.load') -def test_loader(mock_loader, swh_app, celery_session_worker): +def test_loader(mocker, swh_app, celery_session_worker): + mock_loader = mocker.patch( + 'swh.loader.mercurial.loader.HgBundle20Loader.load') mock_loader.return_value = {'status': 'eventful'} res = swh_app.send_task( 'swh.loader.mercurial.tasks.LoadMercurial', (), dict(url='origin_url', directory='/some/repo', visit_date='now')) assert res res.wait() assert res.successful() assert res.result == {'status': 'eventful'} mock_loader.assert_called_once_with() -@patch('swh.loader.mercurial.loader.HgArchiveBundle20Loader.load') -def test_archive_loader(mock_loader, swh_app, celery_session_worker): +def test_archive_loader(mocker, swh_app, celery_session_worker): + mock_loader = mocker.patch( + 'swh.loader.mercurial.loader.HgArchiveBundle20Loader.load') mock_loader.return_value = {'status': 'uneventful'} res = swh_app.send_task( 'swh.loader.mercurial.tasks.LoadArchiveMercurial', (), dict(url='another_url', archive_path='/some/tar.tgz', visit_date='now')) assert res res.wait() assert res.successful() assert res.result == {'status': 'uneventful'} mock_loader.assert_called_once_with()