Skip to content

Commit 64e38e7

Browse files
authored
query errors during async process (#783)
1 parent cb88548 commit 64e38e7

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

graphql_api/actions/owner.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ def get_owner(service, username):
1919
raise MissingService()
2020

2121
long_service = get_long_service_name(service)
22-
return Owner.objects.filter(username=username, service=long_service).first()
22+
return (
23+
Owner.objects.filter(username=username, service=long_service)
24+
.prefetch_related("account")
25+
.first()
26+
)
2327

2428

2529
def get_owner_login_sessions(current_user):

graphql_api/tests/test_plan.py

+32
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from django.test import TransactionTestCase
66
from django.utils import timezone
77
from freezegun import freeze_time
8+
from shared.django_apps.codecov_auth.tests.factories import AccountFactory
89
from shared.license import LicenseInformation
910
from shared.utils.test_utils import mock_config_helper
1011

@@ -83,6 +84,37 @@ def test_owner_plan_data_when_trialing(self):
8384
"planUserCount": 123,
8485
}
8586

87+
def test_owner_plan_data_with_account(self):
88+
self.current_org.account = AccountFactory(
89+
plan=PlanName.CODECOV_PRO_YEARLY.value,
90+
plan_seat_count=25,
91+
)
92+
self.current_org.save()
93+
query = """{
94+
owner(username: "%s") {
95+
plan {
96+
marketingName
97+
planName
98+
value
99+
tierName
100+
billingRate
101+
baseUnitPrice
102+
planUserCount
103+
}
104+
}
105+
}
106+
""" % (self.current_org.username)
107+
data = self.gql_request(query, owner=self.current_org)
108+
assert data["owner"]["plan"] == {
109+
"marketingName": "Pro",
110+
"planName": "users-pr-inappy",
111+
"value": "users-pr-inappy",
112+
"tierName": "pro",
113+
"billingRate": "annually",
114+
"baseUnitPrice": 10,
115+
"planUserCount": 25,
116+
}
117+
86118
def test_owner_plan_data_has_seats_left(self):
87119
current_org = OwnerFactory(
88120
username="random-plan-user",

0 commit comments

Comments
 (0)