Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref: Update shared + Add missing fields for plan representation #1068

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

RulaKhaled
Copy link
Contributor

@RulaKhaled RulaKhaled commented Dec 20, 2024

Purpose/Motivation

What is the feature? Why is this being done?
Still need the update version of shared after merging this PR: codecov/gazebo#3602 to pass the tests

What does this PR do?

Include a brief description of the changes in this PR. Bullet points are your friend.

Notes to Reviewer

Anything to note to the team? Any tips on how to review, or where to start?

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

Copy link
Contributor

github-actions bot commented Dec 20, 2024

This PR includes changes to shared. Please review them here: codecov/shared@1c4ca00...abc6b36

Copy link

codecov bot commented Dec 20, 2024

Codecov Report

Attention: Patch coverage is 96.29630% with 1 line in your changes missing coverage. Please review.

Project coverage is 96.02%. Comparing base (9958e78) to head (c23e09d).

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...i/types/plan_representation/plan_representation.py 95.83% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1068   +/-   ##
=======================================
  Coverage   96.02%   96.02%           
=======================================
  Files         828      828           
  Lines       19441    19458   +17     
=======================================
+ Hits        18668    18685   +17     
  Misses        773      773           
Flag Coverage Δ
unit 92.30% <96.29%> (+<0.01%) ⬆️
unit-latest-uploader 92.30% <96.29%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@codecov-staging
Copy link

codecov-staging bot commented Dec 20, 2024

Codecov Report

Attention: Patch coverage is 96.29630% with 1 line in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...i/types/plan_representation/plan_representation.py 95.83% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@codecov-qa
Copy link

codecov-qa bot commented Dec 20, 2024

❌ 3 Tests Failed:

Tests completed Failed Passed Skipped
2670 3 2667 6
View the top 3 failed tests by shortest run time
graphql_api/tests/test_owner.py::TestOwnerType::test_fetch_available_plans_is_pro_plan
Stack Traces | 0.404s run time
self = <graphql_api.tests.test_owner.TestOwnerType testMethod=test_fetch_available_plans_is_pro_plan>

    def test_fetch_available_plans_is_pro_plan(self):
        current_org = OwnerFactory(
            username="random-plan-user",
            service="github",
            plan=PlanName.CODECOV_PRO_MONTHLY_LEGACY.value,
        )
    
        query = """{
            owner(username: "%s") {
                availablePlans {
                    isProPlan
                }
            }
        }
        """ % (current_org.username)
        data = self.gql_request(query, owner=current_org)
>       assert data["owner"]["availablePlans"][0]["isProPlan"] is True
E       assert False is True

graphql_api/tests/test_owner.py:1145: AssertionError
graphql_api/tests/test_owner.py::TestOwnerType::test_fetch_available_plans_is_trial_plan
Stack Traces | 0.429s run time
self = <graphql_api.tests.test_owner.TestOwnerType testMethod=test_fetch_available_plans_is_trial_plan>

    def test_fetch_available_plans_is_trial_plan(self):
        current_org = OwnerFactory(
            username="random-plan-user",
            service="github",
            plan=PlanName.TRIAL_PLAN_NAME.value,
        )
    
        query = """{
            owner(username: "%s") {
                availablePlans {
                    isTrialPlan
                }
            }
        }
        """ % (current_org.username)
        data = self.gql_request(query, owner=current_org)
>       assert data["owner"]["availablePlans"][0]["isTrialPlan"] is True
E       TypeError: 'NoneType' object is not subscriptable

graphql_api/tests/test_owner.py:1127: TypeError
graphql_api/tests/test_owner.py::TestOwnerType::test_fetch_available_plans_is_enterprise_plan
Stack Traces | 0.435s run time
self = <graphql_api.tests.test_owner.TestOwnerType testMethod=test_fetch_available_plans_is_enterprise_plan>

    def test_fetch_available_plans_is_enterprise_plan(self):
        current_org = OwnerFactory(
            username="random-plan-user",
            service="github",
            plan=PlanName.FREE_PLAN_NAME.value,
        )
    
        query = """{
            owner(username: "%s") {
                availablePlans {
                    value
                    isEnterprisePlan
                    isProPlan
                    isTeamPlan
                    isSentryPlan
                    isTrialPlan
                    isFreePlan
                }
            }
        }
        """ % (current_org.username)
        data = self.gql_request(query, owner=current_org)
>       assert data["owner"]["availablePlans"][0]["isEnterprisePlan"] is False
E       TypeError: 'NoneType' object is not subscriptable

graphql_api/tests/test_owner.py:1104: TypeError

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

Copy link
Contributor

github-actions bot commented Dec 20, 2024

✅ All tests successful. No failed tests were found.

📣 Thoughts on this report? Let Codecov know! | Powered by Codecov

Copy link

codecov-public-qa bot commented Dec 20, 2024

❌ 3 Tests Failed:

Tests completed Failed Passed Skipped
2670 3 2667 6
View the top 3 failed tests by shortest run time
graphql_api/tests/test_owner.py::TestOwnerType::test_fetch_available_plans_is_pro_plan
Stack Traces | 0.404s run time
self = <graphql_api.tests.test_owner.TestOwnerType testMethod=test_fetch_available_plans_is_pro_plan>

    def test_fetch_available_plans_is_pro_plan(self):
        current_org = OwnerFactory(
            username="random-plan-user",
            service="github",
            plan=PlanName.CODECOV_PRO_MONTHLY_LEGACY.value,
        )
    
        query = """{
            owner(username: "%s") {
                availablePlans {
                    isProPlan
                }
            }
        }
        """ % (current_org.username)
        data = self.gql_request(query, owner=current_org)
>       assert data["owner"]["availablePlans"][0]["isProPlan"] is True
E       assert False is True

graphql_api/tests/test_owner.py:1145: AssertionError
graphql_api/tests/test_owner.py::TestOwnerType::test_fetch_available_plans_is_trial_plan
Stack Traces | 0.429s run time
self = <graphql_api.tests.test_owner.TestOwnerType testMethod=test_fetch_available_plans_is_trial_plan>

    def test_fetch_available_plans_is_trial_plan(self):
        current_org = OwnerFactory(
            username="random-plan-user",
            service="github",
            plan=PlanName.TRIAL_PLAN_NAME.value,
        )
    
        query = """{
            owner(username: "%s") {
                availablePlans {
                    isTrialPlan
                }
            }
        }
        """ % (current_org.username)
        data = self.gql_request(query, owner=current_org)
>       assert data["owner"]["availablePlans"][0]["isTrialPlan"] is True
E       TypeError: 'NoneType' object is not subscriptable

graphql_api/tests/test_owner.py:1127: TypeError
graphql_api/tests/test_owner.py::TestOwnerType::test_fetch_available_plans_is_enterprise_plan
Stack Traces | 0.435s run time
self = <graphql_api.tests.test_owner.TestOwnerType testMethod=test_fetch_available_plans_is_enterprise_plan>

    def test_fetch_available_plans_is_enterprise_plan(self):
        current_org = OwnerFactory(
            username="random-plan-user",
            service="github",
            plan=PlanName.FREE_PLAN_NAME.value,
        )
    
        query = """{
            owner(username: "%s") {
                availablePlans {
                    value
                    isEnterprisePlan
                    isProPlan
                    isTeamPlan
                    isSentryPlan
                    isTrialPlan
                    isFreePlan
                }
            }
        }
        """ % (current_org.username)
        data = self.gql_request(query, owner=current_org)
>       assert data["owner"]["availablePlans"][0]["isEnterprisePlan"] is False
E       TypeError: 'NoneType' object is not subscriptable

graphql_api/tests/test_owner.py:1104: TypeError

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

@@ -14,27 +14,27 @@

@plan_representation_bindable.field("marketingName")
def resolve_marketing_name(plan_data: PlanData, info) -> str:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we update the PlanData type somewhere to reflect this? Can't remember if that is included in shared

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yes! shared changes included this, we added convet_to_DTO fn to the type

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right but that's just a return type of that function right? The PlanData type still reflects the explicit properties of the dataclass iirc

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember if we actually created an interface for convert_to_DTO

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, because Python typing isn't as strict as TS we won't have any runtime errors i think, but this is creating some additional cognitive burden / magic to unwind these types and see where the additional properties are coming from

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm yah it's a bit confusing because we're kinda calculating it on the fly within the class and actually returning a dict type after all, we could enhance this at some point to make the typing clearer, but it's not gonna effect things atm

@RulaKhaled RulaKhaled marked this pull request as ready for review December 20, 2024 20:20
@RulaKhaled RulaKhaled requested a review from a team as a code owner December 20, 2024 20:20
@ajay-sentry
Copy link
Contributor

Tested this locally by pulling branch, confirming bug I was seeing previously no longer exists. Will merge this on Monday

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants