Skip to content

Commit

Permalink
chore: use more specific fixture for cases of not supporting expiration
Browse files Browse the repository at this point in the history
  • Loading branch information
angela-tran committed Apr 1, 2024
1 parent f39d909 commit b9caeed
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions tests/pytest/enrollment/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,12 @@ def test_get_group_funding_sources_funding_source_already_enrolled(

@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_no_expiry(
def test_index_eligible_post_valid_form_success_does_not_support_expiration_customer_already_enrolled_no_expiry(
mocker,
client,
card_tokenize_form_data,
mocked_analytics_module,
model_EligibilityType,
model_EligibilityType_does_not_support_expiration,
mocked_funding_source,
mocked_group_funding_source_no_expiry,
):
Expand All @@ -233,13 +233,20 @@ def test_index_eligible_post_valid_form_customer_already_enrolled_no_expiry(
assert response.status_code == 200
assert response.template_name == TEMPLATE_SUCCESS
mocked_analytics_module.returned_success.assert_called_once()
assert model_EligibilityType.group_id in mocked_analytics_module.returned_success.call_args.args
assert (
model_EligibilityType_does_not_support_expiration.group_id in mocked_analytics_module.returned_success.call_args.args
)


@pytest.mark.django_db
@pytest.mark.usefixtures("mocked_session_agency", "mocked_session_verifier", "mocked_session_eligibility")
def test_index_eligible_post_valid_form_success_no_expiry(
mocker, client, card_tokenize_form_data, mocked_analytics_module, model_EligibilityType, mocked_funding_source
def test_index_eligible_post_valid_form_success_does_not_support_expiration_no_expiry(
mocker,
client,
card_tokenize_form_data,
mocked_analytics_module,
model_EligibilityType_does_not_support_expiration,
mocked_funding_source,
):
mock_client_cls = mocker.patch("benefits.enrollment.views.Client")
mock_client = mock_client_cls.return_value
Expand All @@ -249,12 +256,14 @@ def test_index_eligible_post_valid_form_success_no_expiry(
response = client.post(path, card_tokenize_form_data)

mock_client.link_concession_group_funding_source.assert_called_once_with(
funding_source_id=mocked_funding_source.id, group_id=model_EligibilityType.group_id
funding_source_id=mocked_funding_source.id, group_id=model_EligibilityType_does_not_support_expiration.group_id
)
assert response.status_code == 200
assert response.template_name == TEMPLATE_SUCCESS
mocked_analytics_module.returned_success.assert_called_once()
assert model_EligibilityType.group_id in mocked_analytics_module.returned_success.call_args.args
assert (
model_EligibilityType_does_not_support_expiration.group_id in mocked_analytics_module.returned_success.call_args.args
)


def test_calculate_expiry():
Expand Down Expand Up @@ -565,7 +574,7 @@ def test_index_eligible_post_valid_form_success_does_not_support_expiration_has_
client,
card_tokenize_form_data,
mocked_analytics_module,
model_EligibilityType,
model_EligibilityType_does_not_support_expiration,
mocked_funding_source,
mocked_group_funding_source_with_expiry,
):
Expand All @@ -584,13 +593,15 @@ def test_index_eligible_post_valid_form_success_does_not_support_expiration_has_
#
# mock_client.link_concession_group_funding_source.assert_called_once_with(
# funding_source_id=mocked_funding_source.id,
# group_id=model_EligibilityType.group_id,
# group_id=model_EligibilityType_does_not_support_expiration.group_id,
# expiry_date=None,
# )
# assert response.status_code == 200
# assert response.template_name == TEMPLATE_SUCCESS
# mocked_analytics_module.returned_success.assert_called_once()
# assert model_EligibilityType.group_id in mocked_analytics_module.returned_success.call_args.args
# assert (
# model_EligibilityType_does_not_support_expiration.group_id in mocked_analytics_module.returned_success.call_args.args
# )


@pytest.mark.django_db
Expand Down

0 comments on commit b9caeed

Please sign in to comment.