1313
1414from billing .helpers import mock_all_plans_and_tiers
1515from billing .views import StripeWebhookHandler
16+ from codecov_auth .models import Plan
1617
1718from ..constants import StripeHTTPHeaders
1819
@@ -721,7 +722,7 @@ def test_customer_subscription_created_early_returns_if_unverified_payment(
721722 "object" : {
722723 "id" : "sub_123" ,
723724 "customer" : "cus_123" ,
724- "plan" : {"id" : "plan_H6P16wij3lUuxg " },
725+ "plan" : {"id" : "plan_pro_yearly " },
725726 "metadata" : {"obo_organization" : self .owner .ownerid },
726727 "quantity" : 20 ,
727728 }
@@ -776,7 +777,7 @@ def test_customer_subscription_created_does_nothing_if_plan_not_paid_user_plan(
776777 "object" : {
777778 "id" : "FOEKDCDEQ" ,
778779 "customer" : "sdo050493" ,
779- "plan" : {"id" : "? " },
780+ "plan" : {"id" : "plan_free " },
780781 "metadata" : {"obo_organization" : self .owner .ownerid },
781782 "quantity" : 20 ,
782783 }
@@ -809,7 +810,7 @@ def test_customer_subscription_created_sets_plan_info(
809810 "object" : {
810811 "id" : stripe_subscription_id ,
811812 "customer" : stripe_customer_id ,
812- "plan" : {"id" : "plan_H6P16wij3lUuxg " },
813+ "plan" : {"id" : "plan_pro_yearly " },
813814 "metadata" : {"obo_organization" : self .owner .ownerid },
814815 "quantity" : quantity ,
815816 "status" : "active" ,
@@ -849,7 +850,7 @@ def test_customer_subscription_created_can_trigger_trial_expiration(
849850 "object" : {
850851 "id" : stripe_subscription_id ,
851852 "customer" : stripe_customer_id ,
852- "plan" : {"id" : "plan_H6P16wij3lUuxg " },
853+ "plan" : {"id" : "plan_pro_yearly " },
853854 "metadata" : {"obo_organization" : self .owner .ownerid },
854855 "quantity" : quantity ,
855856 "default_payment_method" : "blabla" ,
@@ -882,7 +883,7 @@ def test_customer_subscription_updated_does_not_change_subscription_if_not_paid_
882883 "object" : {
883884 "id" : self .owner .stripe_subscription_id ,
884885 "customer" : self .owner .stripe_customer_id ,
885- "plan" : {"id" : "? " },
886+ "plan" : {"id" : "plan_free " },
886887 "metadata" : {"obo_organization" : self .owner .ownerid },
887888 "quantity" : 20 ,
888889 "status" : "active" ,
@@ -929,7 +930,7 @@ def test_customer_subscription_updated_does_not_change_subscription_if_there_is_
929930 "object" : {
930931 "id" : self .owner .stripe_subscription_id ,
931932 "customer" : self .owner .stripe_customer_id ,
932- "plan" : {"id" : "plan_H6P16wij3lUuxg " },
933+ "plan" : {"id" : "plan_pro_yearly " },
933934 "metadata" : {"obo_organization" : self .owner .ownerid },
934935 "quantity" : 20 ,
935936 "status" : "active" ,
@@ -985,7 +986,7 @@ def test_customer_subscription_updated_sets_free_and_deactivates_all_repos_if_in
985986 "id" : self .owner .stripe_subscription_id ,
986987 "customer" : self .owner .stripe_customer_id ,
987988 "plan" : {
988- "id" : "plan_H6P16wij3lUuxg " ,
989+ "id" : "plan_pro_yearly " ,
989990 },
990991 "metadata" : {"obo_organization" : self .owner .ownerid },
991992 "quantity" : 20 ,
@@ -1088,7 +1089,7 @@ def test_customer_subscription_updated_sets_free_and_deactivates_all_repos_if_in
10881089 "id" : self .owner .stripe_subscription_id ,
10891090 "customer" : self .owner .stripe_customer_id ,
10901091 "plan" : {
1091- "id" : "plan_H6P16wij3lUuxg " ,
1092+ "id" : "plan_pro_yearly " ,
10921093 },
10931094 "metadata" : {"obo_organization" : self .owner .ownerid },
10941095 "quantity" : 20 ,
@@ -1149,7 +1150,7 @@ def test_customer_subscription_updated_sets_fields_on_success(
11491150 "object" : {
11501151 "id" : self .owner .stripe_subscription_id ,
11511152 "customer" : self .owner .stripe_customer_id ,
1152- "plan" : {"id" : "plan_H6P16wij3lUuxg " },
1153+ "plan" : {"id" : "plan_pro_yearly " },
11531154 "metadata" : {"obo_organization" : self .owner .ownerid },
11541155 "quantity" : quantity ,
11551156 "status" : "active" ,
@@ -1200,7 +1201,7 @@ def test_customer_subscription_updated_sets_fields_on_success_multiple_owner(
12001201 "object" : {
12011202 "id" : self .owner .stripe_subscription_id ,
12021203 "customer" : self .owner .stripe_customer_id ,
1203- "plan" : {"id" : "plan_H6P16wij3lUuxg " },
1204+ "plan" : {"id" : "plan_pro_yearly " },
12041205 "metadata" : {"obo_organization" : self .owner .ownerid },
12051206 "quantity" : quantity ,
12061207 "status" : "active" ,
@@ -1238,7 +1239,7 @@ def test_customer_subscription_updated_logs_error_if_no_matching_owners(
12381239 "object" : {
12391240 "id" : "sub_notexist" ,
12401241 "customer" : "cus_notexist" ,
1241- "plan" : {"id" : "plan_H6P16wij3lUuxg " },
1242+ "plan" : {"id" : "plan_pro_yearly " },
12421243 "metadata" : {"obo_organization" : 1 },
12431244 "quantity" : 8 ,
12441245 "status" : "active" ,
@@ -1254,7 +1255,7 @@ def test_customer_subscription_updated_logs_error_if_no_matching_owners(
12541255 extra = {
12551256 "stripe_subscription_id" : "sub_notexist" ,
12561257 "stripe_customer_id" : "cus_notexist" ,
1257- "plan_id" : "plan_H6P16wij3lUuxg " ,
1258+ "plan_id" : "plan_pro_yearly " ,
12581259 },
12591260 )
12601261
@@ -1267,7 +1268,7 @@ def test_subscription_schedule_released_updates_owner_with_existing_subscription
12671268 self .owner .save ()
12681269
12691270 self .new_params = {
1270- "new_plan" : "plan_H6P3KZXwmAbqPS " ,
1271+ "new_plan" : "plan_pro_yearly " ,
12711272 "new_quantity" : 7 ,
12721273 "subscription_id" : "sub_123" ,
12731274 }
@@ -1288,7 +1289,8 @@ def test_subscription_schedule_released_updates_owner_with_existing_subscription
12881289 )
12891290
12901291 self .owner .refresh_from_db ()
1291- assert self .owner .plan == settings .STRIPE_PLAN_VALS [self .new_params ["new_plan" ]]
1292+ plan = Plan .objects .get (stripe_id = self .new_params ["new_plan" ])
1293+ assert self .owner .plan == plan .name
12921294 assert self .owner .plan_user_count == self .new_params ["new_quantity" ]
12931295
12941296 @patch ("services.billing.stripe.Subscription.retrieve" )
@@ -1304,7 +1306,7 @@ def test_subscription_schedule_released_updates_multiple_owners_with_existing_su
13041306 self .other_owner .save ()
13051307
13061308 self .new_params = {
1307- "new_plan" : "plan_H6P3KZXwmAbqPS " ,
1309+ "new_plan" : "plan_pro_yearly " ,
13081310 "new_quantity" : 7 ,
13091311 "subscription_id" : "sub_123" ,
13101312 }
@@ -1326,12 +1328,11 @@ def test_subscription_schedule_released_updates_multiple_owners_with_existing_su
13261328
13271329 self .owner .refresh_from_db ()
13281330 self .other_owner .refresh_from_db ()
1329- assert self .owner .plan == settings .STRIPE_PLAN_VALS [self .new_params ["new_plan" ]]
1331+
1332+ plan = Plan .objects .get (stripe_id = self .new_params ["new_plan" ])
1333+ assert self .owner .plan == plan .name
13301334 assert self .owner .plan_user_count == self .new_params ["new_quantity" ]
1331- assert (
1332- self .other_owner .plan
1333- == settings .STRIPE_PLAN_VALS [self .new_params ["new_plan" ]]
1334- )
1335+ assert self .other_owner .plan == plan .name
13351336 assert self .other_owner .plan_user_count == self .new_params ["new_quantity" ]
13361337
13371338 @patch ("logging.Logger.error" )
@@ -1342,7 +1343,7 @@ def test_subscription_schedule_released_logs_error_if_owner_does_not_exist(
13421343 log_error_mock ,
13431344 ):
13441345 self .new_params = {
1345- "new_plan" : "plan_H6P3KZXwmAbqPS " ,
1346+ "new_plan" : "plan_pro_yearly " ,
13461347 "new_quantity" : 7 ,
13471348 "subscription_id" : "sub_notexist" ,
13481349 }
@@ -1367,7 +1368,7 @@ def test_subscription_schedule_released_logs_error_if_owner_does_not_exist(
13671368 extra = {
13681369 "stripe_subscription_id" : "sub_notexist" ,
13691370 "stripe_customer_id" : "cus_123" ,
1370- "plan_id" : "plan_H6P3KZXwmAbqPS " ,
1371+ "plan_id" : "plan_pro_yearly " ,
13711372 },
13721373 )
13731374
@@ -1383,7 +1384,7 @@ def test_subscription_schedule_created_logs_a_new_schedule(
13831384 self .owner .save ()
13841385
13851386 self .params = {
1386- "new_plan" : "plan_H6P3KZXwmAbqPS " ,
1387+ "new_plan" : "plan_pro_yearly " ,
13871388 "new_quantity" : 7 ,
13881389 "subscription_id" : subscription_id ,
13891390 }
@@ -1410,7 +1411,7 @@ def test_subscription_schedule_updated_logs_changes_to_schedule(
14101411 original_plan = "users-pr-inappy"
14111412 original_quantity = 10
14121413 subscription_id = "sub_1K8xfkGlVGuVgOrkxvroyZdH"
1413- new_plan = "plan_H6P3KZXwmAbqPS "
1414+ new_plan = "plan_pro_yearly "
14141415 new_quantity = 7
14151416 self .owner .plan = original_plan
14161417 self .owner .plan_user_count = original_quantity
0 commit comments