"""Unit tests for merit label derivation from draft JSON (notification body).

Run: cd be0 && python -m unittest tests.test_user_notifications_merit -v
"""

from __future__ import annotations

import unittest


class MeritCategoryFromDraftTests(unittest.TestCase):
    def test_poster_without_review_is_trung_binh(self) -> None:
        from src.initiative_db.user_notifications import merit_category_label_from_draft_payload

        payload = {
            "tabs": {
                "application": {
                    "initiativeClassification": "research",
                    "researchEvidenceKind": "poster-without-review",
                }
            }
        }
        self.assertEqual(merit_category_label_from_draft_payload(payload), "Trung bình")

    def test_international_remains_xuat_sac(self) -> None:
        from src.initiative_db.user_notifications import merit_category_label_from_draft_payload

        payload = {
            "tabs": {
                "application": {
                    "initiativeClassification": "research",
                    "researchEvidenceKind": "international",
                }
            }
        }
        self.assertEqual(merit_category_label_from_draft_payload(payload), "Xuất sắc")

    def test_textbook_book_is_xuat_sac(self) -> None:
        from src.initiative_db.user_notifications import merit_category_label_from_draft_payload

        payload = {
            "tabs": {
                "application": {
                    "initiativeClassification": "textbook",
                    "textbookEvidenceKind": "book",
                }
            }
        }
        self.assertEqual(merit_category_label_from_draft_payload(payload), "Xuất sắc")

    def test_poster_with_review_still_kha_bucket(self) -> None:
        from src.initiative_db.user_notifications import merit_category_label_from_draft_payload

        payload = {
            "tabs": {
                "application": {
                    "initiativeClassification": "research",
                    "researchEvidenceKind": "poster",
                }
            }
        }
        self.assertEqual(merit_category_label_from_draft_payload(payload), "Khá")


if __name__ == "__main__":
    unittest.main()
