13
13
14
14
from billing .helpers import mock_all_plans_and_tiers
15
15
from billing .views import StripeWebhookHandler
16
+ from codecov_auth .models import Plan
16
17
17
18
from ..constants import StripeHTTPHeaders
18
19
@@ -721,7 +722,7 @@ def test_customer_subscription_created_early_returns_if_unverified_payment(
721
722
"object" : {
722
723
"id" : "sub_123" ,
723
724
"customer" : "cus_123" ,
724
- "plan" : {"id" : "plan_H6P16wij3lUuxg " },
725
+ "plan" : {"id" : "plan_pro_yearly " },
725
726
"metadata" : {"obo_organization" : self .owner .ownerid },
726
727
"quantity" : 20 ,
727
728
}
@@ -776,7 +777,7 @@ def test_customer_subscription_created_does_nothing_if_plan_not_paid_user_plan(
776
777
"object" : {
777
778
"id" : "FOEKDCDEQ" ,
778
779
"customer" : "sdo050493" ,
779
- "plan" : {"id" : "? " },
780
+ "plan" : {"id" : "plan_free " },
780
781
"metadata" : {"obo_organization" : self .owner .ownerid },
781
782
"quantity" : 20 ,
782
783
}
@@ -809,7 +810,7 @@ def test_customer_subscription_created_sets_plan_info(
809
810
"object" : {
810
811
"id" : stripe_subscription_id ,
811
812
"customer" : stripe_customer_id ,
812
- "plan" : {"id" : "plan_H6P16wij3lUuxg " },
813
+ "plan" : {"id" : "plan_pro_yearly " },
813
814
"metadata" : {"obo_organization" : self .owner .ownerid },
814
815
"quantity" : quantity ,
815
816
"status" : "active" ,
@@ -849,7 +850,7 @@ def test_customer_subscription_created_can_trigger_trial_expiration(
849
850
"object" : {
850
851
"id" : stripe_subscription_id ,
851
852
"customer" : stripe_customer_id ,
852
- "plan" : {"id" : "plan_H6P16wij3lUuxg " },
853
+ "plan" : {"id" : "plan_pro_yearly " },
853
854
"metadata" : {"obo_organization" : self .owner .ownerid },
854
855
"quantity" : quantity ,
855
856
"default_payment_method" : "blabla" ,
@@ -882,7 +883,7 @@ def test_customer_subscription_updated_does_not_change_subscription_if_not_paid_
882
883
"object" : {
883
884
"id" : self .owner .stripe_subscription_id ,
884
885
"customer" : self .owner .stripe_customer_id ,
885
- "plan" : {"id" : "? " },
886
+ "plan" : {"id" : "plan_free " },
886
887
"metadata" : {"obo_organization" : self .owner .ownerid },
887
888
"quantity" : 20 ,
888
889
"status" : "active" ,
@@ -929,7 +930,7 @@ def test_customer_subscription_updated_does_not_change_subscription_if_there_is_
929
930
"object" : {
930
931
"id" : self .owner .stripe_subscription_id ,
931
932
"customer" : self .owner .stripe_customer_id ,
932
- "plan" : {"id" : "plan_H6P16wij3lUuxg " },
933
+ "plan" : {"id" : "plan_pro_yearly " },
933
934
"metadata" : {"obo_organization" : self .owner .ownerid },
934
935
"quantity" : 20 ,
935
936
"status" : "active" ,
@@ -985,7 +986,7 @@ def test_customer_subscription_updated_sets_free_and_deactivates_all_repos_if_in
985
986
"id" : self .owner .stripe_subscription_id ,
986
987
"customer" : self .owner .stripe_customer_id ,
987
988
"plan" : {
988
- "id" : "plan_H6P16wij3lUuxg " ,
989
+ "id" : "plan_pro_yearly " ,
989
990
},
990
991
"metadata" : {"obo_organization" : self .owner .ownerid },
991
992
"quantity" : 20 ,
@@ -1088,7 +1089,7 @@ def test_customer_subscription_updated_sets_free_and_deactivates_all_repos_if_in
1088
1089
"id" : self .owner .stripe_subscription_id ,
1089
1090
"customer" : self .owner .stripe_customer_id ,
1090
1091
"plan" : {
1091
- "id" : "plan_H6P16wij3lUuxg " ,
1092
+ "id" : "plan_pro_yearly " ,
1092
1093
},
1093
1094
"metadata" : {"obo_organization" : self .owner .ownerid },
1094
1095
"quantity" : 20 ,
@@ -1149,7 +1150,7 @@ def test_customer_subscription_updated_sets_fields_on_success(
1149
1150
"object" : {
1150
1151
"id" : self .owner .stripe_subscription_id ,
1151
1152
"customer" : self .owner .stripe_customer_id ,
1152
- "plan" : {"id" : "plan_H6P16wij3lUuxg " },
1153
+ "plan" : {"id" : "plan_pro_yearly " },
1153
1154
"metadata" : {"obo_organization" : self .owner .ownerid },
1154
1155
"quantity" : quantity ,
1155
1156
"status" : "active" ,
@@ -1200,7 +1201,7 @@ def test_customer_subscription_updated_sets_fields_on_success_multiple_owner(
1200
1201
"object" : {
1201
1202
"id" : self .owner .stripe_subscription_id ,
1202
1203
"customer" : self .owner .stripe_customer_id ,
1203
- "plan" : {"id" : "plan_H6P16wij3lUuxg " },
1204
+ "plan" : {"id" : "plan_pro_yearly " },
1204
1205
"metadata" : {"obo_organization" : self .owner .ownerid },
1205
1206
"quantity" : quantity ,
1206
1207
"status" : "active" ,
@@ -1238,7 +1239,7 @@ def test_customer_subscription_updated_logs_error_if_no_matching_owners(
1238
1239
"object" : {
1239
1240
"id" : "sub_notexist" ,
1240
1241
"customer" : "cus_notexist" ,
1241
- "plan" : {"id" : "plan_H6P16wij3lUuxg " },
1242
+ "plan" : {"id" : "plan_pro_yearly " },
1242
1243
"metadata" : {"obo_organization" : 1 },
1243
1244
"quantity" : 8 ,
1244
1245
"status" : "active" ,
@@ -1254,7 +1255,7 @@ def test_customer_subscription_updated_logs_error_if_no_matching_owners(
1254
1255
extra = {
1255
1256
"stripe_subscription_id" : "sub_notexist" ,
1256
1257
"stripe_customer_id" : "cus_notexist" ,
1257
- "plan_id" : "plan_H6P16wij3lUuxg " ,
1258
+ "plan_id" : "plan_pro_yearly " ,
1258
1259
},
1259
1260
)
1260
1261
@@ -1267,7 +1268,7 @@ def test_subscription_schedule_released_updates_owner_with_existing_subscription
1267
1268
self .owner .save ()
1268
1269
1269
1270
self .new_params = {
1270
- "new_plan" : "plan_H6P3KZXwmAbqPS " ,
1271
+ "new_plan" : "plan_pro_yearly " ,
1271
1272
"new_quantity" : 7 ,
1272
1273
"subscription_id" : "sub_123" ,
1273
1274
}
@@ -1288,7 +1289,8 @@ def test_subscription_schedule_released_updates_owner_with_existing_subscription
1288
1289
)
1289
1290
1290
1291
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
1292
1294
assert self .owner .plan_user_count == self .new_params ["new_quantity" ]
1293
1295
1294
1296
@patch ("services.billing.stripe.Subscription.retrieve" )
@@ -1304,7 +1306,7 @@ def test_subscription_schedule_released_updates_multiple_owners_with_existing_su
1304
1306
self .other_owner .save ()
1305
1307
1306
1308
self .new_params = {
1307
- "new_plan" : "plan_H6P3KZXwmAbqPS " ,
1309
+ "new_plan" : "plan_pro_yearly " ,
1308
1310
"new_quantity" : 7 ,
1309
1311
"subscription_id" : "sub_123" ,
1310
1312
}
@@ -1326,12 +1328,11 @@ def test_subscription_schedule_released_updates_multiple_owners_with_existing_su
1326
1328
1327
1329
self .owner .refresh_from_db ()
1328
1330
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
1330
1334
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
1335
1336
assert self .other_owner .plan_user_count == self .new_params ["new_quantity" ]
1336
1337
1337
1338
@patch ("logging.Logger.error" )
@@ -1342,7 +1343,7 @@ def test_subscription_schedule_released_logs_error_if_owner_does_not_exist(
1342
1343
log_error_mock ,
1343
1344
):
1344
1345
self .new_params = {
1345
- "new_plan" : "plan_H6P3KZXwmAbqPS " ,
1346
+ "new_plan" : "plan_pro_yearly " ,
1346
1347
"new_quantity" : 7 ,
1347
1348
"subscription_id" : "sub_notexist" ,
1348
1349
}
@@ -1367,7 +1368,7 @@ def test_subscription_schedule_released_logs_error_if_owner_does_not_exist(
1367
1368
extra = {
1368
1369
"stripe_subscription_id" : "sub_notexist" ,
1369
1370
"stripe_customer_id" : "cus_123" ,
1370
- "plan_id" : "plan_H6P3KZXwmAbqPS " ,
1371
+ "plan_id" : "plan_pro_yearly " ,
1371
1372
},
1372
1373
)
1373
1374
@@ -1383,7 +1384,7 @@ def test_subscription_schedule_created_logs_a_new_schedule(
1383
1384
self .owner .save ()
1384
1385
1385
1386
self .params = {
1386
- "new_plan" : "plan_H6P3KZXwmAbqPS " ,
1387
+ "new_plan" : "plan_pro_yearly " ,
1387
1388
"new_quantity" : 7 ,
1388
1389
"subscription_id" : subscription_id ,
1389
1390
}
@@ -1410,7 +1411,7 @@ def test_subscription_schedule_updated_logs_changes_to_schedule(
1410
1411
original_plan = "users-pr-inappy"
1411
1412
original_quantity = 10
1412
1413
subscription_id = "sub_1K8xfkGlVGuVgOrkxvroyZdH"
1413
- new_plan = "plan_H6P3KZXwmAbqPS "
1414
+ new_plan = "plan_pro_yearly "
1414
1415
new_quantity = 7
1415
1416
self .owner .plan = original_plan
1416
1417
self .owner .plan_user_count = original_quantity
0 commit comments