From eae13a5b08b67733c8692739380b8c4f1d0bcfb4 Mon Sep 17 00:00:00 2001 From: Angela Tran Date: Thu, 28 Mar 2024 19:42:16 +0000 Subject: [PATCH] test: add coverage for function that checks for existing enrollment --- tests/pytest/enrollment/test_views.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/pytest/enrollment/test_views.py b/tests/pytest/enrollment/test_views.py index b04d8e66c4..2f80e77886 100644 --- a/tests/pytest/enrollment/test_views.py +++ b/tests/pytest/enrollment/test_views.py @@ -20,6 +20,7 @@ TEMPLATE_REENROLLMENT_ERROR, TEMPLATE_SUCCESS, TEMPLATE_RETRY, + _get_group_funding_source, _calculate_expiry, _is_expired, _is_within_reenrollment_window, @@ -186,6 +187,30 @@ def test_index_eligible_post_valid_form_failure(mocker, client, card_tokenize_fo client.post(path, card_tokenize_form_data) +@pytest.mark.django_db +@pytest.mark.usefixtures("model_EligibilityType") +def test_get_group_funding_sources_funding_source_not_enrolled_yet(mocker, mocked_funding_source): + mock_client = mocker.Mock() + mock_client.get_concession_group_linked_funding_sources.return_value = [] + + group_funding_sources = _get_group_funding_source(mock_client, "group123", mocked_funding_source.id) + + assert group_funding_sources is None + + +@pytest.mark.django_db +@pytest.mark.usefixtures("model_EligibilityType") +def test_get_group_funding_sources_funding_source_already_enrolled( + mocker, mocked_funding_source, mocked_group_funding_source_no_expiration +): + mock_client = mocker.Mock() + mock_client.get_concession_group_linked_funding_sources.return_value = [mocked_group_funding_source_no_expiration] + + group_funding_sources = _get_group_funding_source(mock_client, "group123", mocked_funding_source.id) + + assert group_funding_sources == mocked_group_funding_source_no_expiration + + @pytest.mark.django_db @pytest.mark.usefixtures("mocked_session_agency", "mocked_session_verifier", "mocked_session_eligibility") def test_index_eligible_post_valid_form_customer_already_enrolled(