1111from shared .django_apps .core .tests .factories import OwnerFactory , RepositoryFactory
1212from shared .plan .constants import PlanName
1313
14+ from billing .helpers import mock_all_plans_and_tiers
15+
1416from ..constants import StripeHTTPHeaders
1517
1618
@@ -70,16 +72,19 @@ def __getitem__(self, key):
7072
7173class StripeWebhookHandlerTests (APITestCase ):
7274 def setUp (self ):
75+ mock_all_plans_and_tiers ()
7376 self .owner = OwnerFactory (
74- stripe_customer_id = "cus_123" , stripe_subscription_id = "sub_123"
77+ stripe_customer_id = "cus_123" ,
78+ stripe_subscription_id = "sub_123" ,
7579 )
7680
7781 # Creates a second owner that shares billing details with self.owner.
7882 # This is used to test the case where owners are manually set to share a
7983 # subscription in Stripe.
8084 def add_second_owner (self ):
8185 self .other_owner = OwnerFactory (
82- stripe_customer_id = "cus_123" , stripe_subscription_id = "sub_123"
86+ stripe_customer_id = "cus_123" ,
87+ stripe_subscription_id = "sub_123" ,
8388 )
8489
8590 def _send_event (self , payload , errorSig = None ):
@@ -467,7 +472,7 @@ def test_invoice_payment_failed_sends_email_to_admins_no_card(
467472 mocked_send_email .assert_has_calls (expected_calls )
468473
469474 def test_customer_subscription_deleted_sets_plan_to_free (self ):
470- self .owner .plan = "users-inappy"
475+ self .owner .plan = PlanName . CODECOV_PRO_YEARLY . value
471476 self .owner .plan_user_count = 20
472477 self .owner .save ()
473478
@@ -492,10 +497,10 @@ def test_customer_subscription_deleted_sets_plan_to_free(self):
492497
493498 def test_customer_subscription_deleted_sets_plan_to_free_mutliple_owner (self ):
494499 self .add_second_owner ()
495- self .owner .plan = "users-inappy"
500+ self .owner .plan = PlanName . CODECOV_PRO_YEARLY . value
496501 self .owner .plan_user_count = 20
497502 self .owner .save ()
498- self .other_owner .plan = "users-inappy"
503+ self .other_owner .plan = PlanName . CODECOV_PRO_YEARLY . value
499504 self .other_owner .plan_user_count = 20
500505 self .other_owner .save ()
501506
@@ -540,7 +545,7 @@ def test_customer_subscription_deleted_deactivates_all_repos(self):
540545 "object" : {
541546 "id" : self .owner .stripe_subscription_id ,
542547 "customer" : self .owner .stripe_customer_id ,
543- "plan" : {"name" : "users-inappm" },
548+ "plan" : {"name" : PlanName . CODECOV_PRO_MONTHLY . value },
544549 }
545550 },
546551 }
@@ -577,7 +582,7 @@ def test_customer_subscription_deleted_deactivates_all_repos_multiple_owner(self
577582 "object" : {
578583 "id" : self .owner .stripe_subscription_id ,
579584 "customer" : self .owner .stripe_customer_id ,
580- "plan" : {"name" : "users-inappm" },
585+ "plan" : {"name" : PlanName . CODECOV_PRO_MONTHLY . value },
581586 }
582587 },
583588 }
@@ -598,7 +603,7 @@ def test_customer_subscription_deleted_deactivates_all_repos_multiple_owner(self
598603
599604 @patch ("logging.Logger.info" )
600605 def test_customer_subscription_deleted_no_customer (self , log_info_mock ):
601- self .owner .plan = "users-inappy"
606+ self .owner .plan = PlanName . CODECOV_PRO_MONTHLY . value
602607 self .owner .plan_user_count = 20
603608 self .owner .save ()
604609
@@ -688,7 +693,7 @@ def test_customer_subscription_created_sets_plan_info(self):
688693
689694 stripe_subscription_id = "FOEKDCDEQ"
690695 stripe_customer_id = "sdo050493"
691- plan_name = "users-pr-inappy"
696+ plan_name = PlanName . CODECOV_PRO_YEARLY . value
692697 quantity = 20
693698
694699 self ._send_event (
0 commit comments