Skip to content

Commit

Permalink
Add test for url not ready
Browse files Browse the repository at this point in the history
  • Loading branch information
glujan committed Jan 2, 2025
1 parent d85a3e0 commit 20341d7
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,17 @@ def test_invalid_status_code(self, _file_path, logger, respx_mock):
logger.error.assert_called_once()
self.assertIn("Invalid download for", logger.error.call_args.args[0])

@mock.patch("drpg.sync.logger")
@mock.patch("drpg.DrpgSync._file_path", return_value=PathMock())
@respx.mock(base_url=DrpgApi.API_URL, using="httpx")
def test_url_preparing(self, _file_path, logger, respx_mock):
respx_mock.get("order_products/123/prepare?siteId=10&index=0&getChecksums=1").respond(
200, json=DownloadUrlResponseFixture.preparing()
)
drpg.DrpgSync(dummy_config)._prepare_download_url(self.product, self.item)
self.assertEqual(logger.debug.call_count, 2)
self.assertIn("Waiting for download link", logger.debug.call_args.args[0])

@mock.patch("drpg.sync.logger")
@mock.patch("drpg.DrpgSync._file_path", return_value=PathMock())
def test_dry_run(self, file_path, logger):
Expand All @@ -303,10 +314,11 @@ def test_processes_each_item(self, products, need_download, *_):
products_count = 3
products.side_effect = [
(self.dummy_product(f"Rule Book {i}", files_count) for i in range(products_count)),
(self.dummy_product(f"Adventure {i}", files_count) for i in range(products_count)),
iter(()),
]
self.sync.sync()
self.assertEqual(need_download.call_count, files_count * products_count)
self.assertEqual(need_download.call_count, files_count * products_count * 2)

def dummy_product(self, name, files_count):
return types.Product(
Expand Down

0 comments on commit 20341d7

Please sign in to comment.