codecov / codecov-api

Code for the API of Codecov
Other
216 stars 30 forks source link

fix: Safely access schedule metadata to avoid error #837

Closed spalmurray-codecov closed 3 weeks ago

spalmurray-codecov commented 3 weeks ago

Updates last instance of unsafely accessing a schedule/subscription's metadata. This was causing errors when the expected metadata doesn't exist.

Resolves https://codecov.sentry.io/issues/5332174795

codecov-staging[bot] commented 3 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

:white_check_mark: All tests successful. No failed tests found.

:loudspeaker: Thoughts on this report? Let us know!

codecov-qa[bot] commented 3 weeks ago

:x: 1 Tests Failed:

Tests completed Failed Passed Skipped
2306 1 2305 6
View the top 1 failed tests by shortest run time > > ``` > billing.tests.test_views.StripeWebhookHandlerTests test_customer_subscription_deleted_deactivates_all_repos_multiple_owner > ``` > >
Stack Traces | 0.032s run time > > > > > ``` > > self = <billing.tests.test_views.StripeWebhookHandlerTests testMethod=test_customer_subscription_deleted_deactivates_all_repos_multiple_owner> > > > > def test_customer_subscription_deleted_deactivates_all_repos_multiple_owner(self): > > self.add_second_owner() > > RepositoryFactory(author=self.owner, activated=True, active=True) > > RepositoryFactory(author=self.owner, activated=True, active=True) > > RepositoryFactory(author=self.owner, activated=True, active=True) > > RepositoryFactory(author=self.other_owner, activated=True, active=True) > > RepositoryFactory(author=self.other_owner, activated=True, active=True) > > RepositoryFactory(author=self.other_owner, activated=True, active=True) > > > > > assert ( > > self.owner.repository_set.filter(activated=True, active=True).count() == 3 > > ) > > E assert 2 == 3 > > E + where 2 = <bound method QuerySet.count of <RepositoryQuerySet [<Repository: Repo<Owner<github/tonyapope>/until>>, <Repository: Repo<Owner<github/tonyapope>/now>>]>>() > > E + where <bound method QuerySet.count of <RepositoryQuerySet [<Repository: Repo<Owner<github/tonyapope>/until>>, <Repository: Repo<Owner<github/tonyapope>/now>>]>> = <RepositoryQuerySet [<Repository: Repo<Owner<github/tonyapope>/until>>, <Repository: Repo<Owner<github/tonyapope>/now>>]>.count > > E + where <RepositoryQuerySet [<Repository: Repo<Owner<github/tonyapope>/until>>, <Repository: Repo<Owner<github/tonyapope>/now>>]> = <bound method QuerySet.filter of <django.db.models.fields.related_descriptors.create_reverse_many_to_one_manager.<locals>.RelatedManager object at 0x7fb1619803b0>>(activated=True, active=True) > > E + where <bound method QuerySet.filter of <django.db.models.fields.related_descriptors.create_reverse_many_to_one_manager.<locals>.RelatedManager object at 0x7fb1619803b0>> = <django.db.models.fields.related_descriptors.create_reverse_many_to_one_manager.<locals>.RelatedManager object at 0x7fb1619803b0>.filter > > E + where <django.db.models.fields.related_descriptors.create_reverse_many_to_one_manager.<locals>.RelatedManager object at 0x7fb1619803b0> = <Owner: Owner<github/tonyapope>>.repository_set > > E + where <Owner: Owner<github/tonyapope>> = <billing.tests.test_views.StripeWebhookHandlerTests testMethod=test_customer_subscription_deleted_deactivates_all_repos_multiple_owner>.owner > > > > billing/tests/test_views.py:273: AssertionError > > ``` > >

To view individual test run time comparison to the main branch, go to the Test Analytics Dashboard

codecov-public-qa[bot] commented 3 weeks ago

Test Failures Detected: Due to failing tests, we cannot provide coverage reports at this time.

:x: Failed Test Results:

Completed 2312 tests with 1 failed, 2305 passed and 6 skipped.

View the full list of failed tests ## pytest - **Class name:** billing.tests.test_views.StripeWebhookHandlerTests
**Test name:** test_customer_subscription_deleted_deactivates_all_repos_multiple_owner

self = <billing.tests.test_views.StripeWebhookHandlerTests testMethod=test_customer_subscription_deleted_deactivates_all_repos_multiple_owner>

def test_customer_subscription_deleted_deactivates_all_repos_multiple_owner(self):
self.add_second_owner()
RepositoryFactory(author=self.owner, activated=True, active=True)
RepositoryFactory(author=self.owner, activated=True, active=True)
RepositoryFactory(author=self.owner, activated=True, active=True)
RepositoryFactory(author=self.other_owner, activated=True, active=True)
RepositoryFactory(author=self.other_owner, activated=True, active=True)
RepositoryFactory(author=self.other_owner, activated=True, active=True)

> assert (
self.owner.repository_set.filter(activated=True, active=True).count() == 3
)
E assert 2 == 3
E + where 2 = <bound method QuerySet.count of <RepositoryQuerySet [<Repository: Repo<Owner<github/tonyapope>/until>>, <Repository: Repo<Owner<github/tonyapope>/now>>]>>()
E + where <bound method QuerySet.count of <RepositoryQuerySet [<Repository: Repo<Owner<github/tonyapope>/until>>, <Repository: Repo<Owner<github/tonyapope>/now>>]>> = <RepositoryQuerySet [<Repository: Repo<Owner<github/tonyapope>/until>>, <Repository: Repo<Owner<github/tonyapope>/now>>]>.count
E + where <RepositoryQuerySet [<Repository: Repo<Owner<github/tonyapope>/until>>, <Repository: Repo<Owner<github/tonyapope>/now>>]> = <bound method QuerySet.filter of <django.db.models.fields.related_descriptors.create_reverse_many_to_one_manager.<locals>.RelatedManager object at 0x7fb1619803b0>>(activated=True, active=True)
E + where <bound method QuerySet.filter of <django.db.models.fields.related_descriptors.create_reverse_many_to_one_manager.<locals>.RelatedManager object at 0x7fb1619803b0>> = <django.db.models.fields.related_descriptors.create_reverse_many_to_one_manager.<locals>.RelatedManager object at 0x7fb1619803b0>.filter
E + where <django.db.models.fields.related_descriptors.create_reverse_many_to_one_manager.<locals>.RelatedManager object at 0x7fb1619803b0> = <Owner: Owner<github/tonyapope>>.repository_set
E + where <Owner: Owner<github/tonyapope>> = <billing.tests.test_views.StripeWebhookHandlerTests testMethod=test_customer_subscription_deleted_deactivates_all_repos_multiple_owner>.owner

billing/tests/test_views.py:273: AssertionError
codecov[bot] commented 3 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 96.24%. Comparing base (a21d1c0) to head (78a2f21). Report is 1 commits behind head on main.

:white_check_mark: All tests successful. No failed tests found.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #837 +/- ## =========================================== Coverage 96.24000 96.24000 =========================================== Files 812 812 Lines 18602 18602 =========================================== Hits 17904 17904 Misses 698 698 ``` | [Flag](https://app.codecov.io/gh/codecov/codecov-api/pull/837/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=codecov) | Coverage Δ | | |---|---|---| | [unit](https://app.codecov.io/gh/codecov/codecov-api/pull/837/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=codecov) | `92.48% <ø> (ø)` | | | [unit-latest-uploader](https://app.codecov.io/gh/codecov/codecov-api/pull/837/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=codecov) | `92.48% <ø> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=codecov#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.