Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: move EligibilityType fields to EnrollmentFlow #2299

Merged
merged 5 commits into from
Aug 16, 2024

Conversation

lalver1
Copy link
Member

@lalver1 lalver1 commented Aug 13, 2024

Closes #2283

  • Fields from EligibilityType are moved to EnrollmentFlow
  • Migrate the data from EligibilityType.name to EnrollmentFlow.name in the migration file
  • The label field is used as the Admin display field for EnrollmentFlow instances
  • TransitAgency.eligibility_types field (and all related calculated fields) are removed
  • EligibilityType model is removed
  • session.eligibility_types is removed
  • session.eligible (get bool) used to indicate if the user was found eligible for their selected flow, updated through session.update(eligible=bool) like other session data
  • EligibilityType read-only fields are moved to the new model
  • Analytics events that currently include eligibility_types properties (event/user) now use enrollment_flows.eligibility_name for the eligibility_types property values
  • Update tests

Testing locally

  1. Checkout the main branch
  2. Make sure that your local_fixtures.json (or whatever fixture you are using) has an EnrollmentFlow that has a foreign key reference to an EligibilityType.
  3. Run bin/reset_db.sh (now your local DB mirrors the structure of the dev environment)
  4. Checkout this PR's branch
  5. Run bin/init.sh (running this PR's migration on top of existing DB structure)

@lalver1 lalver1 self-assigned this Aug 13, 2024
@github-actions github-actions bot added migrations [auto] Review for potential model changes/needed data migrations updates back-end Django views, sessions, middleware, models, migrations etc. deployment-dev [auto] Changes that will trigger a deploy if merged to dev labels Aug 13, 2024
@lalver1 lalver1 force-pushed the refactor/eligibilitytype-enrollmentflow branch 7 times, most recently from 8115035 to 0ec024b Compare August 15, 2024 16:44
Copy link
Member

@thekaveman thekaveman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, few cleanups needed to keep the analytics consistent for now.

benefits/core/models.py Show resolved Hide resolved
benefits/core/models.py Show resolved Hide resolved
benefits/core/session.py Outdated Show resolved Hide resolved
benefits/eligibility/views.py Outdated Show resolved Hide resolved
benefits/eligibility/views.py Outdated Show resolved Hide resolved
benefits/enrollment/views.py Outdated Show resolved Hide resolved
@thekaveman
Copy link
Member

benefits/core/migrations/local_fixtures.json needs to be updated to combine the data from the old core.eligibilitytype fixtures into the core.enrollmentflow fixtures. That's (part of the reason) why the Cypress tests are failing.

@lalver1 lalver1 force-pushed the refactor/eligibilitytype-enrollmentflow branch 3 times, most recently from 681176c to ab62c92 Compare August 16, 2024 15:03
@lalver1
Copy link
Member Author

lalver1 commented Aug 16, 2024

These are the only tests that are still failing (they're in enrollment/test_views)

and I'm having a hard time getting them to work. The current state of the PR has the original code (to use as a reference) so these tests still use mocked_session_eligibility and model_EligibilityType, which don't exist anymore, but a simple change of these to mocked_session_eligibility and model_EnrollmentFlow doesn't fix the failing tests so I think a more thorough refactor is needed for these 3 tests 🤔 Or, the views actually have errors but this doesn't seem to be the case since the code in the views only had minor changes and I don't get any errors when running through an enrollment flow locally.

@lalver1 lalver1 force-pushed the refactor/eligibilitytype-enrollmentflow branch from ab62c92 to 021ab15 Compare August 16, 2024 18:01
Copy link

github-actions bot commented Aug 16, 2024

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  benefits/core
  admin.py
  analytics.py
  context_processors.py
  models.py
  session.py
  benefits/eligibility
  analytics.py
  verify.py
  views.py 40
  benefits/enrollment
  views.py
  benefits/oauth
  middleware.py
Project Total  

This report was generated by python-coverage-comment-action

Copy link

@lalver1 lalver1 marked this pull request as ready for review August 16, 2024 18:08
@lalver1 lalver1 requested a review from a team as a code owner August 16, 2024 18:08
@thekaveman
Copy link
Member

thekaveman commented Aug 16, 2024

image

-180 for the PR, nice 👍


UPDATE:

-182 👍

image

Copy link
Member

@thekaveman thekaveman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright so this is looking great logic-wise! Congrats on getting the tests to pass 🎉

My comments are all stylistic / syntactic in nature, but things we can clean up now since we're doing this refactor.

Nearly there 💪

tests/pytest/core/test_models.py Outdated Show resolved Hide resolved
tests/pytest/core/test_models.py Outdated Show resolved Hide resolved
benefits/core/session.py Outdated Show resolved Hide resolved
benefits/eligibility/analytics.py Outdated Show resolved Hide resolved
benefits/eligibility/verify.py Outdated Show resolved Hide resolved
benefits/eligibility/views.py Outdated Show resolved Hide resolved
benefits/enrollment/views.py Show resolved Hide resolved
benefits/enrollment/views.py Show resolved Hide resolved
tests/pytest/core/test_session.py Outdated Show resolved Hide resolved
tests/pytest/core/test_session.py Outdated Show resolved Hide resolved
@thekaveman thekaveman added this to the Admin tool: agency users milestone Aug 16, 2024
@lalver1 lalver1 force-pushed the refactor/eligibilitytype-enrollmentflow branch from 021ab15 to e807f90 Compare August 16, 2024 20:55
@lalver1 lalver1 force-pushed the refactor/eligibilitytype-enrollmentflow branch from e807f90 to 903f76f Compare August 16, 2024 20:58
Copy link
Member

@thekaveman thekaveman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Champion 🌟 🥇 🏆

@lalver1 lalver1 merged commit 92b827c into main Aug 16, 2024
17 checks passed
@lalver1 lalver1 deleted the refactor/eligibilitytype-enrollmentflow branch August 16, 2024 21:18
@lalver1
Copy link
Member Author

lalver1 commented Aug 16, 2024

Thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
back-end Django views, sessions, middleware, models, migrations etc. deployment-dev [auto] Changes that will trigger a deploy if merged to dev migrations [auto] Review for potential model changes/needed data migrations updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Model refactor: move EligibilityType fields to EnrollmentFlow
2 participants