1
- from shared .billing import BillingPlan , is_enterprise_cloud_plan
1
+ import pytest
2
+ from django .test import override_settings
3
+
4
+ from shared .billing import BillingPlan , is_enterprise_cloud_plan , is_pr_billing_plan
5
+ from shared .django_apps .codecov_auth .tests .factories import OwnerFactory
6
+
7
+
8
+ @pytest .fixture
9
+ def dbsession (db ):
10
+ return db
11
+
12
+
13
+ @override_settings (IS_ENTERPRISE = False )
14
+ def test_pr_author_plan_check (dbsession , mock_configuration ):
15
+ owner = OwnerFactory (service = "github" , plan = "users-pr-inappm" )
16
+ if dbsession is not None :
17
+ dbsession .add (owner )
18
+ dbsession .flush ()
19
+ assert is_pr_billing_plan (owner .plan )
20
+
21
+
22
+ @override_settings (IS_ENTERPRISE = True )
23
+ def test_pr_author_enterprise_plan_check (dbsession , mock_configuration ):
24
+ owner = OwnerFactory (service = "github" )
25
+ if dbsession is not None :
26
+ dbsession .add (owner )
27
+ dbsession .flush ()
28
+
29
+ encrypted_license = "wxWEJyYgIcFpi6nBSyKQZQeaQ9Eqpo3SXyUomAqQOzOFjdYB3A8fFM1rm+kOt2ehy9w95AzrQqrqfxi9HJIb2zLOMOB9tSy52OykVCzFtKPBNsXU/y5pQKOfV7iI3w9CHFh3tDwSwgjg8UsMXwQPOhrpvl2GdHpwEhFdaM2O3vY7iElFgZfk5D9E7qEnp+WysQwHKxDeKLI7jWCnBCBJLDjBJRSz0H7AfU55RQDqtTrnR+rsLDHOzJ80/VxwVYhb"
30
+ mock_configuration .params ["setup" ]["enterprise_license" ] = encrypted_license
31
+ mock_configuration .params ["setup" ]["codecov_dashboard_url" ] = (
32
+ "https://codecov.mysite.com"
33
+ )
34
+
35
+ assert is_pr_billing_plan (owner .plan )
36
+
37
+
38
+ @override_settings (IS_ENTERPRISE = False )
39
+ def test_plan_not_pr_author (dbsession , mock_configuration ):
40
+ owner = OwnerFactory (service = "github" , plan = BillingPlan .users_monthly .value )
41
+ if dbsession is not None :
42
+ dbsession .add (owner )
43
+ dbsession .flush ()
44
+
45
+ assert not is_pr_billing_plan (owner .plan )
46
+
47
+
48
+ @override_settings (IS_ENTERPRISE = True )
49
+ def test_pr_author_enterprise_plan_check_non_pr_plan (dbsession , mock_configuration ):
50
+ owner = OwnerFactory (service = "github" )
51
+ if dbsession is not None :
52
+ dbsession .add (owner )
53
+ dbsession .flush ()
54
+
55
+ encrypted_license = "0dRbhbzp8TVFQp7P4e2ES9lSfyQlTo8J7LQ"
56
+ mock_configuration .params ["setup" ]["enterprise_license" ] = encrypted_license
57
+ mock_configuration .params ["setup" ]["codecov_dashboard_url" ] = (
58
+ "https://codeov.mysite.com"
59
+ )
60
+
61
+ assert not is_pr_billing_plan (owner .plan )
2
62
3
63
4
64
def test_billing_enums ():
@@ -10,6 +70,8 @@ def test_billing_enums():
10
70
assert BillingPlan .pr_yearly .db_name == "users-pr-inappy"
11
71
assert BillingPlan .enterprise_cloud_yearly .db_name == "users-enterprisey"
12
72
assert BillingPlan .enterprise_cloud_monthly .db_name == "users-enterprisem"
73
+ assert BillingPlan .team_monthly .db_name == "users-teamm"
74
+ assert BillingPlan .team_yearly .db_name == "users-teamy"
13
75
14
76
15
77
def test_get_from_string ():
@@ -26,6 +88,8 @@ def test_get_from_string():
26
88
BillingPlan .from_str ("users-enterprisem" )
27
89
== BillingPlan .enterprise_cloud_monthly
28
90
)
91
+ assert BillingPlan .from_str ("users-teamm" ) == BillingPlan .team_monthly
92
+ assert BillingPlan .from_str ("users-teamy" ) == BillingPlan .team_yearly
29
93
30
94
31
95
def test_is_enterprise_cloud_plan ():
0 commit comments