Skip to content

Commit

Permalink
query errors during async process (#783)
Browse files Browse the repository at this point in the history
  • Loading branch information
nora-codecov authored Aug 29, 2024
1 parent cb88548 commit 64e38e7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
6 changes: 5 additions & 1 deletion graphql_api/actions/owner.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ def get_owner(service, username):
raise MissingService()

long_service = get_long_service_name(service)
return Owner.objects.filter(username=username, service=long_service).first()
return (
Owner.objects.filter(username=username, service=long_service)
.prefetch_related("account")
.first()
)


def get_owner_login_sessions(current_user):
Expand Down
32 changes: 32 additions & 0 deletions graphql_api/tests/test_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django.test import TransactionTestCase
from django.utils import timezone
from freezegun import freeze_time
from shared.django_apps.codecov_auth.tests.factories import AccountFactory
from shared.license import LicenseInformation
from shared.utils.test_utils import mock_config_helper

Expand Down Expand Up @@ -83,6 +84,37 @@ def test_owner_plan_data_when_trialing(self):
"planUserCount": 123,
}

def test_owner_plan_data_with_account(self):
self.current_org.account = AccountFactory(
plan=PlanName.CODECOV_PRO_YEARLY.value,
plan_seat_count=25,
)
self.current_org.save()
query = """{
owner(username: "%s") {
plan {
marketingName
planName
value
tierName
billingRate
baseUnitPrice
planUserCount
}
}
}
""" % (self.current_org.username)
data = self.gql_request(query, owner=self.current_org)
assert data["owner"]["plan"] == {
"marketingName": "Pro",
"planName": "users-pr-inappy",
"value": "users-pr-inappy",
"tierName": "pro",
"billingRate": "annually",
"baseUnitPrice": 10,
"planUserCount": 25,
}

def test_owner_plan_data_has_seats_left(self):
current_org = OwnerFactory(
username="random-plan-user",
Expand Down

0 comments on commit 64e38e7

Please sign in to comment.