Files
shanxia2.0/backend/tests/test_crm_contract_reedit_to_draft.py
T
2026-08-06 09:58:20 +08:00

25 lines
762 B
Python

import pytest
from app.crud.crm.contract import (
CONTRACT_EDITABLE_STATUSES,
assert_contract_editable_for_update,
)
def test_editable_statuses():
assert CONTRACT_EDITABLE_STATUSES == frozenset({"draft", "approving", "approved"})
assert "executing" not in CONTRACT_EDITABLE_STATUSES
assert "finished" not in CONTRACT_EDITABLE_STATUSES
assert "invalid" not in CONTRACT_EDITABLE_STATUSES
def test_assert_allows_editable():
for s in ("draft", "approving", "approved", None, ""):
assert_contract_editable_for_update(s)
def test_assert_rejects_non_editable():
for s in ("executing", "finished", "invalid"):
with pytest.raises(ValueError, match="才能修改"):
assert_contract_editable_for_update(s)