test_publish.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. from __future__ import annotations
  2. def test_change_set_state_machine_separates_canonical_and_projection_completion():
  3. from app.core.knowledge.publish import ChangeSetStateMachine
  4. machine = ChangeSetStateMachine()
  5. state = "pending"
  6. for target in (
  7. "diffed",
  8. "building",
  9. "validating",
  10. "canonical_active",
  11. "projecting",
  12. "complete",
  13. ):
  14. state = machine.transition(state, target)
  15. assert state == "complete"
  16. def test_change_set_cannot_activate_when_impact_was_truncated():
  17. import pytest
  18. from app.core.knowledge.publish import ChangeSetStateMachine
  19. machine = ChangeSetStateMachine()
  20. with pytest.raises(ValueError, match="truncated"):
  21. machine.transition("validating", "canonical_active", impact_truncated=True)
  22. def test_change_set_rejects_invalid_transition():
  23. import pytest
  24. from app.core.knowledge.publish import ChangeSetStateMachine
  25. with pytest.raises(ValueError, match="invalid knowledge change-set transition"):
  26. ChangeSetStateMachine().transition("pending", "complete")