chore: finalize delivery cleanup

This commit is contained in:
yangqianqian
2026-06-30 18:41:16 +08:00
parent df1856d793
commit 341f3d2b0d
25 changed files with 48 additions and 1054 deletions

View File

@@ -18,6 +18,9 @@ class _Query:
def all(self):
return self._rows
def count(self):
return len(self._rows)
class _Db:
def __init__(self, text_rows, image_rows):
@@ -32,26 +35,44 @@ class _Task:
image_count = 3
def test_submit_review_requires_each_strategy_to_select_full_image_count():
db = _Db(
text_rows=[("A",), ("B",), ("C",)],
image_rows=[("A", 1), ("A", 2), ("A", 3), ("B", 4), ("C", 5), ("C", 6), ("C", 7)],
)
def test_submit_review_requires_at_least_one_text_and_one_image():
db = _Db(text_rows=[], image_rows=[])
with pytest.raises(CloverHTTPException) as exc:
task_actions._validate_strategy_selection(db, _Task())
assert "图片未选满B(1/3)" in exc.value.biz_message
assert "请至少选择 1 条文案" in exc.value.biz_message
assert "请至少选择 1 张图片" in exc.value.biz_message
def test_submit_review_passes_when_all_strategies_have_text_and_full_images():
def test_submit_review_requires_at_least_one_image():
db = _Db(text_rows=[("A",)], image_rows=[])
with pytest.raises(CloverHTTPException) as exc:
task_actions._validate_strategy_selection(db, _Task())
assert exc.value.biz_message == "请至少选择 1 张图片"
def test_submit_review_requires_at_least_one_text():
db = _Db(text_rows=[], image_rows=[("A", 1)])
with pytest.raises(CloverHTTPException) as exc:
task_actions._validate_strategy_selection(db, _Task())
assert exc.value.biz_message == "请至少选择 1 条文案"
def test_submit_review_passes_with_one_text_and_one_image():
db = _Db(text_rows=[("B",)], image_rows=[("C", 7)])
task_actions._validate_strategy_selection(db, _Task())
def test_submit_review_does_not_require_all_strategies_or_full_image_count():
db = _Db(
text_rows=[("A",), ("B",), ("C",)],
image_rows=[
("A", 1), ("A", 2), ("A", 3),
("B", 4), ("B", 5), ("B", 6),
("C", 7), ("C", 8), ("C", 9),
],
text_rows=[("A",)],
image_rows=[("B", 4)],
)
task_actions._validate_strategy_selection(db, _Task())