Drops the dead AI_ANALYZED status (a prior data migration already converted existing rows; the choice was never removed from the model) and the unreachable ACKNOWLEDGED status (is_recipient was hardcoded False so the acknowledge button never rendered). Changes: - AppreciationStatus: DRAFT, ACTIVATED, SENT only. SENT is terminal. - VALID_APPRECIATION_TRANSITIONS: DRAFT→ACTIVATED→SENT, SENT terminal. - Removed the model.acknowledge() method. - DRF viewset acknowledge action: returns 410 Gone (deprecated). - UI appreciation_acknowledge view: redirects with deprecation message. - Removed URL routes: appreciation_acknowledge, appreciation_send_dept_reminder. - appreciation_send_dept_reminder status check no longer references ACKNOWLEDGED. - appreciation_list stats + status filter + badge: dropped ai_analyzed/acknowledged. - appreciation_detail status badge + sent banner: dropped acknowledged references. - Migration 0010_drop_acknowledged_status: AlterField on status choices. AI analysis still runs on activation and is stored in ai_analysis JSON; it just no longer has its own status. Badges and leaderboard fire at SENT. 6 tests lock in the new lifecycle and removed URLs.
46 lines
1.9 KiB
Python
46 lines
1.9 KiB
Python
"""Tests for the appreciation 3-state lifecycle realignment."""
|
|
import pytest
|
|
from django.test import TestCase
|
|
from django.urls import reverse, NoReverseMatch
|
|
|
|
from apps.appreciation.models import AppreciationStatus, VALID_APPRECIATION_TRANSITIONS
|
|
|
|
|
|
class TestAppreciationThreeStateLifecycle(TestCase):
|
|
"""Appreciation has exactly 3 statuses: DRAFT, ACTIVATED, SENT."""
|
|
|
|
def test_only_three_statuses_exist(self):
|
|
choices = [value for value, _ in AppreciationStatus.choices]
|
|
assert set(choices) == {"draft", "activated", "sent"}, \
|
|
f"Expected exactly 3 statuses, got: {choices}"
|
|
|
|
def test_no_ai_analyzed_or_acknowledged(self):
|
|
assert not hasattr(AppreciationStatus, "AI_ANALYZED"), \
|
|
"AI_ANALYZED should be removed"
|
|
assert not hasattr(AppreciationStatus, "ACKNOWLEDGED"), \
|
|
"ACKNOWLEDGED should be removed"
|
|
|
|
def test_sent_is_terminal(self):
|
|
"""SENT has no outgoing transitions."""
|
|
assert VALID_APPRECIATION_TRANSITIONS.get(AppreciationStatus.SENT) == set(), \
|
|
"SENT should be terminal"
|
|
|
|
def test_activated_can_go_to_sent(self):
|
|
"""ACTIVATED transitions directly to SENT (no AI_ANALYZED intermediate)."""
|
|
assert AppreciationStatus.SENT in \
|
|
VALID_APPRECIATION_TRANSITIONS[AppreciationStatus.ACTIVATED]
|
|
|
|
|
|
class TestAppreciationRemovedUrls(TestCase):
|
|
"""The acknowledge and send-dept-reminder URL routes are gone."""
|
|
|
|
def test_acknowledge_url_does_not_resolve(self):
|
|
with pytest.raises(NoReverseMatch):
|
|
reverse("appreciation:appreciation_acknowledge",
|
|
kwargs={"pk": "00000000-0000-0000-0000-000000000000"})
|
|
|
|
def test_send_dept_reminder_url_does_not_resolve(self):
|
|
with pytest.raises(NoReverseMatch):
|
|
reverse("appreciation:appreciation_send_dept_reminder",
|
|
kwargs={"pk": "00000000-0000-0000-0000-000000000000"})
|