Complete coverage

This commit is contained in:
Adrian Chaves 2026-07-30 16:15:15 +02:00
parent 9dd3401acc
commit 12e2a11566
2 changed files with 22 additions and 2 deletions

View File

@ -1396,9 +1396,10 @@ class TestFeedMode:
async def test_create_existing(self, caplog: pytest.LogCaptureFixture) -> None:
path = self._path(b"old content")
with caplog.at_level(logging.ERROR):
crawler = await self._crawl(path, "create")
crawler = await self._crawl(path, "create", item_count=3)
assert path.read_bytes() == b"old content"
assert "because it already exists" in caplog.text
# Reported once, not once per item.
assert caplog.text.count("because it already exists") == 1
assert crawler.stats
stats = crawler.stats.get_stats()
assert stats.get("feedexport/conflicts/FileFeedStorage") == 1

View File

@ -523,6 +523,25 @@ class TestS3FeedStorage:
with pytest.raises(FileExistsError):
await maybe_deferred_to_future(stored)
@coroutine_test
async def test_store_create_error(self) -> None:
from botocore.exceptions import ClientError # noqa: PLC0415
storage = S3FeedStorage(
"s3://mybucket/export.csv",
"access_key",
"secret_key",
feed_options={"mode": "create"},
)
storage.s3_client = mock.MagicMock()
storage.s3_client.put_object.side_effect = ClientError(
{"Error": {"Code": "AccessDenied"}}, "PutObject"
)
stored = storage.store(BytesIO(b"test file"))
assert stored is not None
with pytest.raises(ClientError):
await maybe_deferred_to_future(stored)
class TestGCSFeedStorage:
def test_parse_settings(self):