2323from enterprise_access .apps .core .tests .factories import UserFactory
2424from enterprise_access .apps .customer_billing .constants import CheckoutIntentState
2525from enterprise_access .apps .customer_billing .models import CheckoutIntent
26+ from enterprise_access .apps .customer_billing .tests .factories import StripeEventSummaryFactory
2627from enterprise_access .apps .provisioning .models import (
2728 GetCreateCustomerStep ,
2829 GetCreateEnterpriseAdminUsersStep ,
@@ -159,7 +160,7 @@ class TestProvisioningAuth(APITest):
159160 """
160161 def setUp (self ):
161162 super ().setUp ()
162- self ._create_checkout_intent ()
163+ self .checkout_intent = self . _create_checkout_intent ()
163164
164165 def tearDown (self ):
165166 super ().tearDown ()
@@ -252,6 +253,8 @@ def test_provisioning_create_allowed_for_provisioning_admins(
252253 mock_create_agreement .return_value = DEFAULT_AGREEMENT_RECORD
253254 mock_create_renewal .return_value = EXPECTED_SUBSCRIPTION_PLAN_RENEWAL_RESPONSE
254255
256+ StripeEventSummaryFactory .create (checkout_intent = self .checkout_intent )
257+
255258 request_payload = {** DEFAULT_REQUEST_PAYLOAD }
256259 request_payload ['pending_admins' ] = [
257260 {
@@ -287,7 +290,7 @@ def setUp(self):
287290 'context' : ALL_ACCESS_CONTEXT ,
288291 },
289292 ])
290- self ._create_checkout_intent ()
293+ self .checkout_intent = self . _create_checkout_intent ()
291294
292295 def _create_checkout_intent (self ):
293296 """Helper to create a checkout intent for testing."""
@@ -349,6 +352,7 @@ def test_get_or_create_customer_and_admins_created(
349352 mock_client .get_enterprise_catalogs .return_value = [DEFAULT_CATALOG_RECORD ]
350353 mock_create_agreement .return_value = DEFAULT_AGREEMENT_RECORD
351354 mock_create_renewal .return_value = EXPECTED_SUBSCRIPTION_PLAN_RENEWAL_RESPONSE
355+ StripeEventSummaryFactory .create (checkout_intent = self .checkout_intent )
352356
353357 request_payload = {** DEFAULT_REQUEST_PAYLOAD }
354358 request_payload ['pending_admins' ] = [
@@ -469,6 +473,7 @@ def test_customer_fetched_admins_fetched_or_created(
469473 mock_license_client = mock_license_manager_client .return_value
470474 mock_license_client .get_customer_agreement .return_value = DEFAULT_AGREEMENT_RECORD
471475 mock_license_client .create_subscription_plan_renewal .return_value = EXPECTED_SUBSCRIPTION_PLAN_RENEWAL_RESPONSE
476+ StripeEventSummaryFactory .create (checkout_intent = self .checkout_intent )
472477
473478 request_payload = {** DEFAULT_REQUEST_PAYLOAD }
474479 request_payload ['pending_admins' ] = [
@@ -567,6 +572,8 @@ def test_catalog_fetched_or_created(
567572 mock_create_agreement .return_value = DEFAULT_AGREEMENT_RECORD
568573 mock_create_renewal .return_value = EXPECTED_SUBSCRIPTION_PLAN_RENEWAL_RESPONSE
569574
575+ StripeEventSummaryFactory .create (checkout_intent = self .checkout_intent )
576+
570577 request_payload = {** DEFAULT_REQUEST_PAYLOAD }
571578 response = self .client .post (PROVISIONING_CREATE_ENDPOINT , data = request_payload )
572579
@@ -623,6 +630,8 @@ def test_catalog_created_with_generated_title_and_inferred_query_id(
623630 mock_create_agreement .return_value = DEFAULT_AGREEMENT_RECORD
624631 mock_create_renewal .return_value = EXPECTED_SUBSCRIPTION_PLAN_RENEWAL_RESPONSE
625632
633+ StripeEventSummaryFactory .create (checkout_intent = self .checkout_intent )
634+
626635 # Create request payload WITHOUT enterprise_catalog section
627636 request_payload = {** DEFAULT_REQUEST_PAYLOAD }
628637 request_payload .pop ('enterprise_catalog' )
@@ -690,6 +699,8 @@ def test_customer_agreement_fetched_or_created(
690699
691700 mock_license_client .create_subscription_plan_renewal .return_value = EXPECTED_SUBSCRIPTION_PLAN_RENEWAL_RESPONSE
692701
702+ StripeEventSummaryFactory .create (checkout_intent = self .checkout_intent )
703+
693704 request_payload = {** DEFAULT_REQUEST_PAYLOAD }
694705 if test_data ['created_agreement' ]:
695706 request_payload ['customer_agreement' ] = {
@@ -748,6 +759,8 @@ def test_new_subscription_plan_created(
748759 mock_license_client .create_subscription_plan .side_effect = [trial_plan_record , first_paid_plan_record ]
749760 mock_license_client .create_subscription_plan_renewal .return_value = EXPECTED_SUBSCRIPTION_PLAN_RENEWAL_RESPONSE
750761
762+ StripeEventSummaryFactory .create (checkout_intent = self .checkout_intent )
763+
751764 # Make the provisioning request
752765 response = self .client .post (PROVISIONING_CREATE_ENDPOINT , data = DEFAULT_REQUEST_PAYLOAD )
753766 self .assertEqual (response .status_code , status .HTTP_201_CREATED )
@@ -855,6 +868,8 @@ def test_legacy_single_plan_request_transformation(
855868 legacy_request_payload .pop ('first_paid_subscription_plan' )
856869 legacy_request_payload ['subscription_plan' ] = legacy_request_payload .pop ('trial_subscription_plan' )
857870
871+ StripeEventSummaryFactory .create (checkout_intent = self .checkout_intent )
872+
858873 # Make the provisioning request.
859874 response = self .client .post (PROVISIONING_CREATE_ENDPOINT , data = legacy_request_payload )
860875
@@ -953,6 +968,7 @@ def test_checkout_intent_synchronized_on_success(
953968 Test that a fulfillable checkout intent is linked to workflow and marked as FULFILLED on success.
954969 """
955970 checkout_intent = self ._create_checkout_intent (state = intent_state )
971+ StripeEventSummaryFactory .create (checkout_intent = checkout_intent )
956972 self .assertEqual (checkout_intent .state , intent_state )
957973 self .assertIsNone (checkout_intent .workflow )
958974
@@ -1097,6 +1113,7 @@ def test_checkout_intent_different_slug_ignored(self, mock_lms_api_client, mock_
10971113 """
10981114 # The checkout intent we expect to be updated.
10991115 main_checkout_intent = self ._create_checkout_intent (state = CheckoutIntentState .PAID )
1116+ StripeEventSummaryFactory .create (checkout_intent = main_checkout_intent )
11001117
11011118 # Create a checkout intent with different enterprise slug. Later, test that this is NOT modified.
11021119 different_slug = 'different-enterprise-slug'
@@ -1105,6 +1122,7 @@ def test_checkout_intent_different_slug_ignored(self, mock_lms_api_client, mock_
11051122 state = CheckoutIntentState .PAID ,
11061123 enterprise_slug = different_slug ,
11071124 )
1125+ StripeEventSummaryFactory .create (checkout_intent = different_checkout_intent )
11081126
11091127 # Setup mocks for successful provisioning
11101128 mock_lms_client = mock_lms_api_client .return_value
0 commit comments