diff options
| author | Cody Logan <cody@lokken.dev> | 2023-11-17 16:50:26 -0800 |
|---|---|---|
| committer | Cody Logan <cody@lokken.dev> | 2023-11-17 16:50:26 -0800 |
| commit | bc07a8fb109d8daabd1430883914013726abe7b0 (patch) | |
| tree | eb9ef0844b3c3d1092b77997de7836c98d97200f /tests/test_dl.py | |
| parent | 682b7b24b84c9d8614cf898a06f67681db222deb (diff) | |
| download | wikiget-bc07a8fb109d8daabd1430883914013726abe7b0.tar.gz wikiget-bc07a8fb109d8daabd1430883914013726abe7b0.zip | |
Refactor batch download tests
Diffstat (limited to 'tests/test_dl.py')
| -rw-r--r-- | tests/test_dl.py | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/tests/test_dl.py b/tests/test_dl.py index 1099ced..7117e50 100644 --- a/tests/test_dl.py +++ b/tests/test_dl.py @@ -160,15 +160,15 @@ class TestProcessDownload: assert exit_code == 1 +@patch("wikiget.dl.read_batch_file") class TestBatchDownload: """Define tests related to wikiget.dl.batch_download.""" @patch("wikiget.dl.download") - @patch("wikiget.dl.read_batch_file") def test_batch_download( self, - mock_read_batch_file: MagicMock, mock_download: MagicMock, + mock_read_batch_file: MagicMock, caplog: pytest.LogCaptureFixture, ) -> None: """Test that no errors are returned for a successful batch download. @@ -197,12 +197,11 @@ class TestBatchDownload: @patch("wikiget.dl.connect_to_site") @patch("wikiget.dl.prep_download") - @patch("wikiget.dl.read_batch_file") def test_batch_download_reuse_site( self, - mock_read_batch_file: MagicMock, mock_prep_download: MagicMock, mock_connect_to_site: MagicMock, + mock_read_batch_file: MagicMock, caplog: pytest.LogCaptureFixture, ) -> None: """Test that an existing site object is reused.""" @@ -235,7 +234,6 @@ class TestBatchDownload: "Reusing the existing connection to commons.wikimedia.org", ) - @patch("wikiget.dl.read_batch_file") def test_batch_download_os_error( self, mock_read_batch_file: MagicMock, caplog: pytest.LogCaptureFixture ) -> None: @@ -252,11 +250,10 @@ class TestBatchDownload: ] @patch("wikiget.dl.prep_download") - @patch("wikiget.dl.read_batch_file") def test_batch_download_parse_error( self, - mock_read_batch_file: MagicMock, mock_prep_download: MagicMock, + mock_read_batch_file: MagicMock, caplog: pytest.LogCaptureFixture, ) -> None: """Test that a warning log message is created if ParseError is raised. @@ -278,11 +275,10 @@ class TestBatchDownload: assert errors == 1 @patch("wikiget.dl.prep_download") - @patch("wikiget.dl.read_batch_file") def test_batch_download_file_exists_error( self, - mock_read_batch_file: MagicMock, mock_prep_download: MagicMock, + mock_read_batch_file: MagicMock, caplog: pytest.LogCaptureFixture, ) -> None: """Test that a warning log message is created if the download file exists.""" @@ -300,11 +296,10 @@ class TestBatchDownload: assert errors == 1 @patch("wikiget.dl.prep_download") - @patch("wikiget.dl.read_batch_file") def test_batch_download_other_error( self, - mock_read_batch_file: MagicMock, mock_prep_download: MagicMock, + mock_read_batch_file: MagicMock, caplog: pytest.LogCaptureFixture, ) -> None: """Test that a warning log message is created if there are problems downloading. |
