Skip to content

Commit 6dda1ac

Browse files
committed
feat: add IndexView and GatewayUrlView to enrollment_switchio
IndexView currently handles the bare minimum to render the index page for the enrollment_switchio app. GatewayUrlView is a placeholder for the future implementation of the Switchio tokenization gateway registration.
1 parent ac6ce03 commit 6dda1ac

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

benefits/enrollment_switchio/views.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from django.http import JsonResponse
2+
from django.views.generic import TemplateView, View
3+
4+
from benefits.core import models
5+
from benefits.core.mixins import EligibleSessionRequiredMixin
6+
7+
8+
class IndexView(EligibleSessionRequiredMixin, TemplateView):
9+
"""View for the enrollment landing page."""
10+
11+
template_name = "enrollment_switchio/index--switchio.html"
12+
13+
def get_context_data(self, **kwargs):
14+
context = super().get_context_data(**kwargs)
15+
context.update(
16+
{
17+
"headline": "Your eligibility is confirmed! You’re almost there.",
18+
"next_step": "The next step is to enroll the contactless card you will use to tap to ride for a reduced fare.",
19+
"partner_post_link": ", to enter your contactless card details.",
20+
"alert_include": "",
21+
"transit_processor": {"name": "Switchio", "website": "https://switchio.com/transport/"},
22+
"cta_button": "tokenize_card",
23+
"enrollment_method": models.EnrollmentMethods.DIGITAL,
24+
}
25+
)
26+
return context
27+
28+
29+
class GatewayUrlView(EligibleSessionRequiredMixin, View):
30+
"""View for the tokenization gateway registration"""
31+
32+
def get(self, request, *args, **kwargs):
33+
data = {"gateway_url": "https://server/gateway/uuid"}
34+
return JsonResponse(data)

tests/pytest/enrollment_switchio/__init__.py

Whitespace-only changes.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import json
2+
import pytest
3+
4+
from benefits.enrollment_switchio.views import GatewayUrlView, IndexView
5+
6+
7+
class TestIndexView:
8+
@pytest.fixture
9+
def view(self, app_request):
10+
"""Fixture to create an instance of IndexView."""
11+
v = IndexView()
12+
v.setup(app_request)
13+
14+
return v
15+
16+
@pytest.mark.django_db
17+
def test_get_context_data(self, mocker, view, model_EnrollmentFlow):
18+
mocker.patch("benefits.core.session.flow", return_value=model_EnrollmentFlow)
19+
context = view.get_context_data()
20+
21+
assert "cta_button" in context
22+
assert "enrollment_method" in context
23+
assert "headline" in context
24+
assert "next_step" in context
25+
assert "partner_post_link" in context
26+
assert "alert_include" in context
27+
assert "transit_processor" in context
28+
29+
30+
class TestGatewayUrlView:
31+
@pytest.mark.django_db
32+
@pytest.mark.usefixtures("mocked_session_eligible")
33+
def test_get_gateway_url(self, app_request):
34+
35+
response = GatewayUrlView.as_view()(app_request)
36+
37+
assert response.status_code == 200
38+
assert json.loads(response.content) == {"gateway_url": "https://server/gateway/uuid"}

0 commit comments

Comments
 (0)