From e84a357821e64c2bed497b862e0004094fdf3116 Mon Sep 17 00:00:00 2001 From: Kharec Date: Mon, 16 Feb 2026 12:34:15 +0100 Subject: [PATCH] test: assert operation processed/failed/skipped results --- tests/test_operations.py | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/tests/test_operations.py b/tests/test_operations.py index 54b8c24..77e7142 100644 --- a/tests/test_operations.py +++ b/tests/test_operations.py @@ -2,7 +2,7 @@ import time import pytest -from skywipe.operations import Operation, BookmarkStrategy +from skywipe.operations import Operation, BookmarkStrategy, OperationFetchError class FakeClient: @@ -60,10 +60,42 @@ def test_operation_run_batches_filters_and_sleeps(monkeypatch): total = operation.run() - assert total == 2 + assert total.processed == 2 + assert total.failed == 1 + assert total.skipped == 1 assert slept == [1] +def test_operation_run_raises_on_fetch_error(monkeypatch): + class FetchErrorStrategy: + def fetch(self, context, cursor=None): + raise RuntimeError("api down") + + def extract_items(self, response): + return [] + + def process_item(self, item, context): + return None + + def get_cursor(self, response): + return None + + operation = Operation( + "Testing", + strategy_type="feed", + client=FakeClient(), + config_data={"batch_size": 2, "delay": 0}, + ) + operation.strategy = FetchErrorStrategy() + + with pytest.raises(OperationFetchError, match="Failed to fetch items") as exc: + operation.run() + + assert exc.value.result.processed == 0 + assert exc.value.result.failed == 0 + assert exc.value.result.skipped == 0 + + def test_bookmark_strategy_extracts_uri_from_shapes(): strategy = BookmarkStrategy()