"""Tests for review workflow: status transitions and validation."""
import pytest

from api.v1.ppt.endpoints.review import VALID_TRANSITIONS, VALID_STATUSES


class TestStatusTransitions:
    def test_valid_statuses(self):
        assert VALID_STATUSES == {"draft", "in_review", "approved"}

    def test_draft_can_go_to_in_review(self):
        assert "in_review" in VALID_TRANSITIONS["draft"]

    def test_draft_cannot_go_to_approved_directly(self):
        assert "approved" not in VALID_TRANSITIONS["draft"]

    def test_in_review_can_go_to_approved(self):
        assert "approved" in VALID_TRANSITIONS["in_review"]

    def test_in_review_can_go_back_to_draft(self):
        assert "draft" in VALID_TRANSITIONS["in_review"]

    def test_approved_can_go_back_to_draft(self):
        assert "draft" in VALID_TRANSITIONS["approved"]

    def test_approved_cannot_go_to_in_review(self):
        assert "in_review" not in VALID_TRANSITIONS["approved"]

    def test_all_statuses_have_transition_rules(self):
        for status in VALID_STATUSES:
            assert status in VALID_TRANSITIONS

    def test_no_self_transitions(self):
        for status, targets in VALID_TRANSITIONS.items():
            assert status not in targets, f"{status} should not transition to itself"
