Skip to content

Commit

Permalink
feat(models): add Supported Methods choice field to EnrollmentFlow, t…
Browse files Browse the repository at this point in the history
…ests, migrations
  • Loading branch information
machikoyasuda committed Sep 18, 2024
1 parent feb06d2 commit 57ab7ac
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
22 changes: 22 additions & 0 deletions benefits/core/migrations/0027_enrollmentflow_supported_methods.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 5.1 on 2024-09-18 19:17

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("core", "0026_enrollmentevent"),
]

operations = [
migrations.AddField(
model_name="enrollmentflow",
name="supported_methods",
field=models.TextField(
choices=[("digital", "digital"), ("in_person", "in_person")],
default="",
help_text="If the flow is supported by digital, in-person, or both",
),
),
]
19 changes: 14 additions & 5 deletions benefits/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ def __str__(self) -> str:
return self.client_name


class EnrollmentMethods:
DIGITAL = "digital"
IN_PERSON = "in_person"


class EnrollmentFlow(models.Model):
"""Represents a user journey through the Benefits app for a single eligibility type."""

Expand Down Expand Up @@ -216,6 +221,15 @@ class EnrollmentFlow(models.Model):
enrollment_success_template = models.TextField(
default="enrollment/success.html", help_text="Template for a successful enrollment associated with the enrollment flow"
)
supported_methods = models.TextField(
choices={
EnrollmentMethods.DIGITAL: EnrollmentMethods.DIGITAL,
EnrollmentMethods.IN_PERSON: EnrollmentMethods.IN_PERSON,
f"{EnrollmentMethods.DIGITAL}, {EnrollmentMethods.IN_PERSON}": f"{EnrollmentMethods.DIGITAL} and {EnrollmentMethods.IN_PERSON}", # noqa: E501
},
default=EnrollmentMethods.DIGITAL,
help_text="If the flow is supported by digital enrollment, in-person enrollment, or both",
)

class Meta:
ordering = ["display_order"]
Expand Down Expand Up @@ -426,11 +440,6 @@ def for_user(user: User):
return None


class EnrollmentMethods:
DIGITAL = "digital"
IN_PERSON = "in_person"


class EnrollmentEvent(models.Model):
"""A record of a successful enrollment."""

Expand Down
7 changes: 7 additions & 0 deletions tests/pytest/core/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,13 @@ def test_EnrollmentFlow_enrollment_success_template():
assert new_flow.enrollment_success_template == "enrollment/success.html"


@pytest.mark.django_db
def test_EnrollmentFlow_supported_methods():
new_flow = EnrollmentFlow.objects.create()

assert new_flow.supported_methods == "digital"


class SampleFormClass:
"""A class for testing EligibilityVerificationForm references."""

Expand Down

0 comments on commit 57ab7ac

Please sign in to comment.