diff --git a/benefits/core/models/enrollment.py b/benefits/core/models/enrollment.py index 0ebef30b0b..d99ab5a132 100644 --- a/benefits/core/models/enrollment.py +++ b/benefits/core/models/enrollment.py @@ -8,7 +8,6 @@ from multiselectfield import MultiSelectField from benefits.core import context as core_context -from benefits.eligibility import context as eligibility_context from benefits.enrollment import context as enrollment_context from benefits.in_person import context as in_person_context @@ -213,11 +212,6 @@ def selection_label_template(self): else: return f"{prefix}--{self.system_name}.html" - @property - def eligibility_unverified_context(self): - ctx = eligibility_context.eligibility_unverified.get(self.system_name) - return ctx.dict() if ctx else {} - @property def uses_claims_verification(self): """True if this flow verifies via the Identity Gateway and has a scope and claim. False otherwise.""" diff --git a/benefits/eligibility/context/__init__.py b/benefits/eligibility/context/__init__.py deleted file mode 100644 index 2c2e974b74..0000000000 --- a/benefits/eligibility/context/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .flow import eligibility_unverified - -__all__ = ["eligibility_unverified"] diff --git a/benefits/eligibility/context/flow.py b/benefits/eligibility/context/flow.py deleted file mode 100644 index 2896ad152c..0000000000 --- a/benefits/eligibility/context/flow.py +++ /dev/null @@ -1,35 +0,0 @@ -from dataclasses import asdict, dataclass - -from benefits.core.context import SystemName, formatted_gettext_lazy as _ - - -@dataclass -class EligibilityUnverified: - headline_text: str - body_text: str - button_text: str - - def dict(self): - return asdict(self) - - -class AgencyCardEligibilityUnverified(EligibilityUnverified): - def __init__(self, agency_card): - super().__init__( - headline_text=_("Your card information may not have been entered correctly."), - body_text=_( - "The number and last name must be entered exactly as they appear on your {agency_card}. " - "Please check your card and try again, or contact your transit agency for help.", - agency_card=agency_card, - ), - button_text=_("Try again"), - ) - - -eligibility_unverified = { - SystemName.AGENCY_CARD.value: AgencyCardEligibilityUnverified(agency_card=_("CST Agency Card")), - SystemName.COURTESY_CARD.value: AgencyCardEligibilityUnverified(agency_card=_("MST Courtesy Card")), - SystemName.REDUCED_FARE_MOBILITY_ID.value: AgencyCardEligibilityUnverified( - agency_card=_("SBMTD Reduced Fare Mobility ID card") - ), -} diff --git a/benefits/eligibility/views.py b/benefits/eligibility/views.py index eb1b9cd1d7..ef2b9e0dd5 100644 --- a/benefits/eligibility/views.py +++ b/benefits/eligibility/views.py @@ -307,6 +307,29 @@ def form_invalid(self, form): return self.get(self.request) +@dataclass +class EligibilityUnverified: + headline_text: str + body_text: str + button_text: str + + def dict(self): + return asdict(self) + + +class AgencyCardEligibilityUnverified(EligibilityUnverified): + def __init__(self, agency_card): + super().__init__( + headline_text=_("Your card information may not have been entered correctly."), + body_text=_( + "The number and last name must be entered exactly as they appear on your {agency_card}. " + "Please check your card and try again, or contact your transit agency for help.", + agency_card=agency_card, + ), + button_text=_("Try again"), + ) + + class UnverifiedView(AgencySessionRequiredMixin, FlowSessionRequiredMixin, TemplateView): """CBV for the unverified eligibility page.""" @@ -314,7 +337,17 @@ class UnverifiedView(AgencySessionRequiredMixin, FlowSessionRequiredMixin, Templ def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - context.update(self.flow.eligibility_unverified_context) + + eligibility_unverified = { + SystemName.AGENCY_CARD.value: AgencyCardEligibilityUnverified(agency_card=_("CST Agency Card")), + SystemName.COURTESY_CARD.value: AgencyCardEligibilityUnverified(agency_card=_("MST Courtesy Card")), + SystemName.REDUCED_FARE_MOBILITY_ID.value: AgencyCardEligibilityUnverified( + agency_card=_("SBMTD Reduced Fare Mobility ID card") + ), + } + + context_object = eligibility_unverified.get(self.flow.system_name) + context.update(context_object.dict() if context_object else {}) return context def get(self, request, *args, **kwargs): diff --git a/benefits/locale/en/LC_MESSAGES/django.po b/benefits/locale/en/LC_MESSAGES/django.po index d1cf83939a..492eab8661 100644 --- a/benefits/locale/en/LC_MESSAGES/django.po +++ b/benefits/locale/en/LC_MESSAGES/django.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Report-Msgid-Bugs-To: https://github.com/cal-itp/benefits/issues \n" -"POT-Creation-Date: 2026-02-09 16:30-0800\n" +"POT-Creation-Date: 2026-02-09 16:49-0800\n" "Language: English\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -428,28 +428,6 @@ msgid "" "target=\"_blank\" rel=\"noopener noreferrer\">SBMTD Fares & Passes." msgstr "" -msgid "Your card information may not have been entered correctly." -msgstr "" - -#, python-brace-format -msgid "" -"The number and last name must be entered exactly as they appear on your " -"{agency_card}. Please check your card and try again, or contact your transit " -"agency for help." -msgstr "" - -msgid "Try again" -msgstr "" - -msgid "CST Agency Card" -msgstr "" - -msgid "MST Courtesy Card" -msgstr "" - -msgid "SBMTD Reduced Fare Mobility ID card" -msgstr "" - msgid "Choose this benefit" msgstr "" @@ -795,6 +773,28 @@ msgstr "" msgid "You selected a Veteran transit benefit." msgstr "" +msgid "Your card information may not have been entered correctly." +msgstr "" + +#, python-brace-format +msgid "" +"The number and last name must be entered exactly as they appear on your " +"{agency_card}. Please check your card and try again, or contact your transit " +"agency for help." +msgstr "" + +msgid "Try again" +msgstr "" + +msgid "CST Agency Card" +msgstr "" + +msgid "MST Courtesy Card" +msgstr "" + +msgid "SBMTD Reduced Fare Mobility ID card" +msgstr "" + msgid "Your eligibility is confirmed! You’re almost there." msgstr "" diff --git a/benefits/locale/es/LC_MESSAGES/django.po b/benefits/locale/es/LC_MESSAGES/django.po index 87e1ab1485..b3942d4667 100644 --- a/benefits/locale/es/LC_MESSAGES/django.po +++ b/benefits/locale/es/LC_MESSAGES/django.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Report-Msgid-Bugs-To: https://github.com/cal-itp/benefits/issues \n" -"POT-Creation-Date: 2026-02-09 16:30-0800\n" +"POT-Creation-Date: 2026-02-09 16:49-0800\n" "Language: Español\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -588,33 +588,6 @@ msgstr "" "fares-passes/\" target=\"_blank\" rel=\"noopener noreferrer\">SBMTD Fares & " "Passes." -msgid "Your card information may not have been entered correctly." -msgstr "" -"Es posible que la información de su tarjeta no se haya ingresado " -"correctamente." - -#, python-brace-format -msgid "" -"The number and last name must be entered exactly as they appear on your " -"{agency_card}. Please check your card and try again, or contact your transit " -"agency for help." -msgstr "" -"El número y el apellido deben ingresarse exactamente como aparecen en su " -"{agency_card}. Verifique su tarjeta e inténtelo de nuevo, o contacte a su " -"agencia de tránsito para obtener ayuda." - -msgid "Try again" -msgstr "Inténtelo de nuevo" - -msgid "CST Agency Card" -msgstr "tarjeta de agencia de CST" - -msgid "MST Courtesy Card" -msgstr "tarjeta de cortesía de MST" - -msgid "SBMTD Reduced Fare Mobility ID card" -msgstr "tarjeta Reduced Fare Mobility ID de SBMTD" - msgid "Choose this benefit" msgstr "Elegir este beneficio" @@ -1022,6 +995,33 @@ msgstr "Descripción de beneficios para veteranos" msgid "You selected a Veteran transit benefit." msgstr "Ha seleccionado un beneficio de tránsito para veteranos." +msgid "Your card information may not have been entered correctly." +msgstr "" +"Es posible que la información de su tarjeta no se haya ingresado " +"correctamente." + +#, python-brace-format +msgid "" +"The number and last name must be entered exactly as they appear on your " +"{agency_card}. Please check your card and try again, or contact your transit " +"agency for help." +msgstr "" +"El número y el apellido deben ingresarse exactamente como aparecen en su " +"{agency_card}. Verifique su tarjeta e inténtelo de nuevo, o contacte a su " +"agencia de tránsito para obtener ayuda." + +msgid "Try again" +msgstr "Inténtelo de nuevo" + +msgid "CST Agency Card" +msgstr "tarjeta de agencia de CST" + +msgid "MST Courtesy Card" +msgstr "tarjeta de cortesía de MST" + +msgid "SBMTD Reduced Fare Mobility ID card" +msgstr "tarjeta Reduced Fare Mobility ID de SBMTD" + msgid "Your eligibility is confirmed! You’re almost there." msgstr "¡Su elegibilidad está confirmada! Ya falta poco." diff --git a/tests/pytest/eligibility/context/__init__.py b/tests/pytest/eligibility/context/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/pytest/eligibility/context/test_flow.py b/tests/pytest/eligibility/context/test_flow.py deleted file mode 100644 index cc7a9f39ac..0000000000 --- a/tests/pytest/eligibility/context/test_flow.py +++ /dev/null @@ -1,29 +0,0 @@ -import pytest - -from benefits.core import context as core_context -from benefits.eligibility import context as eligibility_context -from benefits.eligibility.context.flow import EligibilityUnverified - - -@pytest.mark.parametrize( - "system_name", - [ - core_context.SystemName.AGENCY_CARD, - core_context.SystemName.COURTESY_CARD, - core_context.SystemName.REDUCED_FARE_MOBILITY_ID, - ], -) -def test_eligibility_unverified(system_name): - assert eligibility_context.eligibility_unverified[system_name.value] - - -def test_EligibilityUnverified_dict(): - context_object = EligibilityUnverified( - headline_text="This is a headline", - body_text="This is the body text", - button_text="Button", - ) - - context_dict = context_object.dict() - - assert isinstance(context_dict, dict) diff --git a/tests/pytest/eligibility/test_views.py b/tests/pytest/eligibility/test_views.py index 0845ca6f8e..3c03e06eb1 100644 --- a/tests/pytest/eligibility/test_views.py +++ b/tests/pytest/eligibility/test_views.py @@ -248,31 +248,26 @@ def test_form_valid_verified(self, mocker, view, form_data, mocked_session_updat @pytest.mark.django_db class TestUnverifiedView: @pytest.fixture - def view(self, app_request, mocked_eligibility_request_session): + def view(self, app_request, model_EnrollmentFlow): v = views.UnverifiedView() v.setup(app_request) + + model_EnrollmentFlow.system_name = SystemName.AGENCY_CARD + v.flow = model_EnrollmentFlow return v def test_view(self, view): assert view.template_name == "eligibility/unverified.html" - def test_get_context_data__dispatched(self, view, app_request, model_EnrollmentFlow): - view.dispatch(app_request) - - ctx = view.get_context_data() - - for key, value in model_EnrollmentFlow.eligibility_unverified_context.items(): - assert ctx[key] == value + def test_get_context_data(self, view): + context = view.get_context_data() - def test_get_context_data__not_dispatched(self, view, model_EnrollmentFlow): - with pytest.raises(AttributeError, match="object has no attribute 'flow'"): - view.get_context_data() + assert "headline_text" in context + assert "body_text" in context + assert "button_text" in context def test_get(self, mocker, view, app_request, mocked_analytics_module): - # spy on the call to get() but call dispatch() like a real request - spy = mocker.spy(view, "get") - response = view.dispatch(app_request) + response = view.get(app_request) - spy.assert_called_once() assert response.status_code == 200 mocked_analytics_module.returned_fail.assert_called_once()