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

[WIP] Milestone 3 Plan Migration #1007

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ajay-sentry
Copy link
Contributor

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.

@codecov-staging
Copy link

❌ 18 Tests Failed:

Tests completed Failed Passed Skipped
1779 18 1761 4
View the top 3 failed tests by shortest run time
services/notification/tests/unit/test_notification_service.py::TestNotificationService::test_should_use_checks_notifier_deprecated_flow[repo_data0-True]
Stack Traces | 0.027s run time
self = <test_notification_service.TestNotificationService object at 0x7f1c744451d0>
repo_data = {'owner__integration_id': 12341234, 'owner__service': 'github', 'using_integration': True}
outcome = True
dbsession = <sqlalchemy.orm.session.Session object at 0x7f1c6015b4d0>

    @pytest.mark.parametrize(
        "repo_data,outcome",
        [
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="github",
                ),
                True,
            ),
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="gitlab",
                ),
                False,
            ),
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="github_enterprise",
                ),
                True,
            ),
            (
                dict(
                    using_integration=False,
                    owner__integration_id=None,
                    owner__service="github",
                ),
                False,
            ),
        ],
    )
    def test_should_use_checks_notifier_deprecated_flow(
        self, repo_data, outcome, dbsession
    ):
        repository = RepositoryFactory.create(**repo_data)
        current_yaml = {"github_checks": True}
        assert repository.owner.github_app_installations == []
        service = NotificationService(repository, current_yaml, None)
>       assert (
            service._should_use_checks_notifier(status_type=StatusType.PROJECT.value)
            == outcome
        )

.../tests/unit/test_notification_service.py:113: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <services.notification.NotificationService object at 0x7f1c6276bd90>
status_type = 'project'

    def _should_use_checks_notifier(self, status_type: StatusType) -> bool:
        checks_yaml_field = read_yaml_field(self.current_yaml, ("github_checks",))
        if checks_yaml_field is False:
            return False
    
        owner: Owner = self.repository.owner
        if owner.service not in ["github", "github_enterprise"]:
            return False
    
        if (
            owner.plan
>           in Plan.objects.filter(tier=TierName.TEAM.value).values_list(
                "name", flat=True
            )
            and status_type != StatusType.PATCH.value
        ):
E       NameError: name 'Plan' is not defined

services/notification/__init__.py:91: NameError
services/notification/tests/unit/test_notification_service.py::TestNotificationService::test_should_use_checks_notifier_deprecated_flow[repo_data2-True]
Stack Traces | 0.027s run time
self = <test_notification_service.TestNotificationService object at 0x7f1c7400a190>
repo_data = {'owner__integration_id': 12341234, 'owner__service': 'github_enterprise', 'using_integration': True}
outcome = True
dbsession = <sqlalchemy.orm.session.Session object at 0x7f1c60158140>

    @pytest.mark.parametrize(
        "repo_data,outcome",
        [
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="github",
                ),
                True,
            ),
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="gitlab",
                ),
                False,
            ),
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="github_enterprise",
                ),
                True,
            ),
            (
                dict(
                    using_integration=False,
                    owner__integration_id=None,
                    owner__service="github",
                ),
                False,
            ),
        ],
    )
    def test_should_use_checks_notifier_deprecated_flow(
        self, repo_data, outcome, dbsession
    ):
        repository = RepositoryFactory.create(**repo_data)
        current_yaml = {"github_checks": True}
        assert repository.owner.github_app_installations == []
        service = NotificationService(repository, current_yaml, None)
>       assert (
            service._should_use_checks_notifier(status_type=StatusType.PROJECT.value)
            == outcome
        )

.../tests/unit/test_notification_service.py:113: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <services.notification.NotificationService object at 0x7f1c62fc0050>
status_type = 'project'

    def _should_use_checks_notifier(self, status_type: StatusType) -> bool:
        checks_yaml_field = read_yaml_field(self.current_yaml, ("github_checks",))
        if checks_yaml_field is False:
            return False
    
        owner: Owner = self.repository.owner
        if owner.service not in ["github", "github_enterprise"]:
            return False
    
        if (
            owner.plan
>           in Plan.objects.filter(tier=TierName.TEAM.value).values_list(
                "name", flat=True
            )
            and status_type != StatusType.PATCH.value
        ):
E       NameError: name 'Plan' is not defined

services/notification/__init__.py:91: NameError
services/notification/tests/unit/test_notification_service.py::TestNotificationService::test_should_use_checks_notifier_deprecated_flow[repo_data3-False]
Stack Traces | 0.028s run time
self = <test_notification_service.TestNotificationService object at 0x7f1c7444ef90>
repo_data = {'owner__integration_id': None, 'owner__service': 'github', 'using_integration': False}
outcome = False
dbsession = <sqlalchemy.orm.session.Session object at 0x7f1c6015b6b0>

    @pytest.mark.parametrize(
        "repo_data,outcome",
        [
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="github",
                ),
                True,
            ),
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="gitlab",
                ),
                False,
            ),
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="github_enterprise",
                ),
                True,
            ),
            (
                dict(
                    using_integration=False,
                    owner__integration_id=None,
                    owner__service="github",
                ),
                False,
            ),
        ],
    )
    def test_should_use_checks_notifier_deprecated_flow(
        self, repo_data, outcome, dbsession
    ):
        repository = RepositoryFactory.create(**repo_data)
        current_yaml = {"github_checks": True}
        assert repository.owner.github_app_installations == []
        service = NotificationService(repository, current_yaml, None)
>       assert (
            service._should_use_checks_notifier(status_type=StatusType.PROJECT.value)
            == outcome
        )

.../tests/unit/test_notification_service.py:113: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <services.notification.NotificationService object at 0x7f1c62fc1350>
status_type = 'project'

    def _should_use_checks_notifier(self, status_type: StatusType) -> bool:
        checks_yaml_field = read_yaml_field(self.current_yaml, ("github_checks",))
        if checks_yaml_field is False:
            return False
    
        owner: Owner = self.repository.owner
        if owner.service not in ["github", "github_enterprise"]:
            return False
    
        if (
            owner.plan
>           in Plan.objects.filter(tier=TierName.TEAM.value).values_list(
                "name", flat=True
            )
            and status_type != StatusType.PATCH.value
        ):
E       NameError: name 'Plan' is not defined

services/notification/__init__.py:91: NameError

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

@codecov-qa
Copy link

codecov-qa bot commented Jan 16, 2025

❌ 18 Tests Failed:

Tests completed Failed Passed Skipped
1779 18 1761 4
View the top 3 failed tests by shortest run time
services/notification/tests/unit/test_notification_service.py::TestNotificationService::test_should_use_checks_notifier_deprecated_flow[repo_data0-True]
Stack Traces | 0.027s run time
self = <test_notification_service.TestNotificationService object at 0x7f1c744451d0>
repo_data = {'owner__integration_id': 12341234, 'owner__service': 'github', 'using_integration': True}
outcome = True
dbsession = <sqlalchemy.orm.session.Session object at 0x7f1c6015b4d0>

    @pytest.mark.parametrize(
        "repo_data,outcome",
        [
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="github",
                ),
                True,
            ),
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="gitlab",
                ),
                False,
            ),
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="github_enterprise",
                ),
                True,
            ),
            (
                dict(
                    using_integration=False,
                    owner__integration_id=None,
                    owner__service="github",
                ),
                False,
            ),
        ],
    )
    def test_should_use_checks_notifier_deprecated_flow(
        self, repo_data, outcome, dbsession
    ):
        repository = RepositoryFactory.create(**repo_data)
        current_yaml = {"github_checks": True}
        assert repository.owner.github_app_installations == []
        service = NotificationService(repository, current_yaml, None)
>       assert (
            service._should_use_checks_notifier(status_type=StatusType.PROJECT.value)
            == outcome
        )

.../tests/unit/test_notification_service.py:113: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <services.notification.NotificationService object at 0x7f1c6276bd90>
status_type = 'project'

    def _should_use_checks_notifier(self, status_type: StatusType) -> bool:
        checks_yaml_field = read_yaml_field(self.current_yaml, ("github_checks",))
        if checks_yaml_field is False:
            return False
    
        owner: Owner = self.repository.owner
        if owner.service not in ["github", "github_enterprise"]:
            return False
    
        if (
            owner.plan
>           in Plan.objects.filter(tier=TierName.TEAM.value).values_list(
                "name", flat=True
            )
            and status_type != StatusType.PATCH.value
        ):
E       NameError: name 'Plan' is not defined

services/notification/__init__.py:91: NameError
services/notification/tests/unit/test_notification_service.py::TestNotificationService::test_should_use_checks_notifier_deprecated_flow[repo_data2-True]
Stack Traces | 0.027s run time
self = <test_notification_service.TestNotificationService object at 0x7f1c7400a190>
repo_data = {'owner__integration_id': 12341234, 'owner__service': 'github_enterprise', 'using_integration': True}
outcome = True
dbsession = <sqlalchemy.orm.session.Session object at 0x7f1c60158140>

    @pytest.mark.parametrize(
        "repo_data,outcome",
        [
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="github",
                ),
                True,
            ),
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="gitlab",
                ),
                False,
            ),
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="github_enterprise",
                ),
                True,
            ),
            (
                dict(
                    using_integration=False,
                    owner__integration_id=None,
                    owner__service="github",
                ),
                False,
            ),
        ],
    )
    def test_should_use_checks_notifier_deprecated_flow(
        self, repo_data, outcome, dbsession
    ):
        repository = RepositoryFactory.create(**repo_data)
        current_yaml = {"github_checks": True}
        assert repository.owner.github_app_installations == []
        service = NotificationService(repository, current_yaml, None)
>       assert (
            service._should_use_checks_notifier(status_type=StatusType.PROJECT.value)
            == outcome
        )

.../tests/unit/test_notification_service.py:113: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <services.notification.NotificationService object at 0x7f1c62fc0050>
status_type = 'project'

    def _should_use_checks_notifier(self, status_type: StatusType) -> bool:
        checks_yaml_field = read_yaml_field(self.current_yaml, ("github_checks",))
        if checks_yaml_field is False:
            return False
    
        owner: Owner = self.repository.owner
        if owner.service not in ["github", "github_enterprise"]:
            return False
    
        if (
            owner.plan
>           in Plan.objects.filter(tier=TierName.TEAM.value).values_list(
                "name", flat=True
            )
            and status_type != StatusType.PATCH.value
        ):
E       NameError: name 'Plan' is not defined

services/notification/__init__.py:91: NameError
services/notification/tests/unit/test_notification_service.py::TestNotificationService::test_should_use_checks_notifier_deprecated_flow[repo_data3-False]
Stack Traces | 0.028s run time
self = <test_notification_service.TestNotificationService object at 0x7f1c7444ef90>
repo_data = {'owner__integration_id': None, 'owner__service': 'github', 'using_integration': False}
outcome = False
dbsession = <sqlalchemy.orm.session.Session object at 0x7f1c6015b6b0>

    @pytest.mark.parametrize(
        "repo_data,outcome",
        [
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="github",
                ),
                True,
            ),
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="gitlab",
                ),
                False,
            ),
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="github_enterprise",
                ),
                True,
            ),
            (
                dict(
                    using_integration=False,
                    owner__integration_id=None,
                    owner__service="github",
                ),
                False,
            ),
        ],
    )
    def test_should_use_checks_notifier_deprecated_flow(
        self, repo_data, outcome, dbsession
    ):
        repository = RepositoryFactory.create(**repo_data)
        current_yaml = {"github_checks": True}
        assert repository.owner.github_app_installations == []
        service = NotificationService(repository, current_yaml, None)
>       assert (
            service._should_use_checks_notifier(status_type=StatusType.PROJECT.value)
            == outcome
        )

.../tests/unit/test_notification_service.py:113: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <services.notification.NotificationService object at 0x7f1c62fc1350>
status_type = 'project'

    def _should_use_checks_notifier(self, status_type: StatusType) -> bool:
        checks_yaml_field = read_yaml_field(self.current_yaml, ("github_checks",))
        if checks_yaml_field is False:
            return False
    
        owner: Owner = self.repository.owner
        if owner.service not in ["github", "github_enterprise"]:
            return False
    
        if (
            owner.plan
>           in Plan.objects.filter(tier=TierName.TEAM.value).values_list(
                "name", flat=True
            )
            and status_type != StatusType.PATCH.value
        ):
E       NameError: name 'Plan' is not defined

services/notification/__init__.py:91: NameError

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

Copy link

❌ 18 Tests Failed:

Tests completed Failed Passed Skipped
1779 18 1761 4
View the top 3 failed tests by shortest run time
services/notification/tests/unit/test_notification_service.py::TestNotificationService::test_should_use_checks_notifier_deprecated_flow[repo_data0-True]
Stack Traces | 0.027s run time
self = <test_notification_service.TestNotificationService object at 0x7f1c744451d0>
repo_data = {'owner__integration_id': 12341234, 'owner__service': 'github', 'using_integration': True}
outcome = True
dbsession = <sqlalchemy.orm.session.Session object at 0x7f1c6015b4d0>

    @pytest.mark.parametrize(
        "repo_data,outcome",
        [
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="github",
                ),
                True,
            ),
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="gitlab",
                ),
                False,
            ),
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="github_enterprise",
                ),
                True,
            ),
            (
                dict(
                    using_integration=False,
                    owner__integration_id=None,
                    owner__service="github",
                ),
                False,
            ),
        ],
    )
    def test_should_use_checks_notifier_deprecated_flow(
        self, repo_data, outcome, dbsession
    ):
        repository = RepositoryFactory.create(**repo_data)
        current_yaml = {"github_checks": True}
        assert repository.owner.github_app_installations == []
        service = NotificationService(repository, current_yaml, None)
>       assert (
            service._should_use_checks_notifier(status_type=StatusType.PROJECT.value)
            == outcome
        )

.../tests/unit/test_notification_service.py:113: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <services.notification.NotificationService object at 0x7f1c6276bd90>
status_type = 'project'

    def _should_use_checks_notifier(self, status_type: StatusType) -> bool:
        checks_yaml_field = read_yaml_field(self.current_yaml, ("github_checks",))
        if checks_yaml_field is False:
            return False
    
        owner: Owner = self.repository.owner
        if owner.service not in ["github", "github_enterprise"]:
            return False
    
        if (
            owner.plan
>           in Plan.objects.filter(tier=TierName.TEAM.value).values_list(
                "name", flat=True
            )
            and status_type != StatusType.PATCH.value
        ):
E       NameError: name 'Plan' is not defined

services/notification/__init__.py:91: NameError
services/notification/tests/unit/test_notification_service.py::TestNotificationService::test_should_use_checks_notifier_deprecated_flow[repo_data2-True]
Stack Traces | 0.027s run time
self = <test_notification_service.TestNotificationService object at 0x7f1c7400a190>
repo_data = {'owner__integration_id': 12341234, 'owner__service': 'github_enterprise', 'using_integration': True}
outcome = True
dbsession = <sqlalchemy.orm.session.Session object at 0x7f1c60158140>

    @pytest.mark.parametrize(
        "repo_data,outcome",
        [
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="github",
                ),
                True,
            ),
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="gitlab",
                ),
                False,
            ),
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="github_enterprise",
                ),
                True,
            ),
            (
                dict(
                    using_integration=False,
                    owner__integration_id=None,
                    owner__service="github",
                ),
                False,
            ),
        ],
    )
    def test_should_use_checks_notifier_deprecated_flow(
        self, repo_data, outcome, dbsession
    ):
        repository = RepositoryFactory.create(**repo_data)
        current_yaml = {"github_checks": True}
        assert repository.owner.github_app_installations == []
        service = NotificationService(repository, current_yaml, None)
>       assert (
            service._should_use_checks_notifier(status_type=StatusType.PROJECT.value)
            == outcome
        )

.../tests/unit/test_notification_service.py:113: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <services.notification.NotificationService object at 0x7f1c62fc0050>
status_type = 'project'

    def _should_use_checks_notifier(self, status_type: StatusType) -> bool:
        checks_yaml_field = read_yaml_field(self.current_yaml, ("github_checks",))
        if checks_yaml_field is False:
            return False
    
        owner: Owner = self.repository.owner
        if owner.service not in ["github", "github_enterprise"]:
            return False
    
        if (
            owner.plan
>           in Plan.objects.filter(tier=TierName.TEAM.value).values_list(
                "name", flat=True
            )
            and status_type != StatusType.PATCH.value
        ):
E       NameError: name 'Plan' is not defined

services/notification/__init__.py:91: NameError
services/notification/tests/unit/test_notification_service.py::TestNotificationService::test_should_use_checks_notifier_deprecated_flow[repo_data3-False]
Stack Traces | 0.028s run time
self = <test_notification_service.TestNotificationService object at 0x7f1c7444ef90>
repo_data = {'owner__integration_id': None, 'owner__service': 'github', 'using_integration': False}
outcome = False
dbsession = <sqlalchemy.orm.session.Session object at 0x7f1c6015b6b0>

    @pytest.mark.parametrize(
        "repo_data,outcome",
        [
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="github",
                ),
                True,
            ),
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="gitlab",
                ),
                False,
            ),
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="github_enterprise",
                ),
                True,
            ),
            (
                dict(
                    using_integration=False,
                    owner__integration_id=None,
                    owner__service="github",
                ),
                False,
            ),
        ],
    )
    def test_should_use_checks_notifier_deprecated_flow(
        self, repo_data, outcome, dbsession
    ):
        repository = RepositoryFactory.create(**repo_data)
        current_yaml = {"github_checks": True}
        assert repository.owner.github_app_installations == []
        service = NotificationService(repository, current_yaml, None)
>       assert (
            service._should_use_checks_notifier(status_type=StatusType.PROJECT.value)
            == outcome
        )

.../tests/unit/test_notification_service.py:113: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <services.notification.NotificationService object at 0x7f1c62fc1350>
status_type = 'project'

    def _should_use_checks_notifier(self, status_type: StatusType) -> bool:
        checks_yaml_field = read_yaml_field(self.current_yaml, ("github_checks",))
        if checks_yaml_field is False:
            return False
    
        owner: Owner = self.repository.owner
        if owner.service not in ["github", "github_enterprise"]:
            return False
    
        if (
            owner.plan
>           in Plan.objects.filter(tier=TierName.TEAM.value).values_list(
                "name", flat=True
            )
            and status_type != StatusType.PATCH.value
        ):
E       NameError: name 'Plan' is not defined

services/notification/__init__.py:91: NameError

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

Copy link

❌ 18 Tests Failed:

Tests completed Failed Passed Skipped
1783 18 1761 4
View the top 3 failed tests by shortest run time
test_should_use_checks_notifier_deprecated_flow[repo_data0-True]
Stack Traces | 0.027s run time
self = &lt;test_notification_service.TestNotificationService object at 0x7f1c744451d0&gt;
repo_data = {'owner__integration_id': 12341234, 'owner__service': 'github', 'using_integration': True}
outcome = True
dbsession = &lt;sqlalchemy.orm.session.Session object at 0x7f1c6015b4d0&gt;

    @pytest.mark.parametrize(
        "repo_data,outcome",
        [
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="github",
                ),
                True,
            ),
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="gitlab",
                ),
                False,
            ),
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="github_enterprise",
                ),
                True,
            ),
            (
                dict(
                    using_integration=False,
                    owner__integration_id=None,
                    owner__service="github",
                ),
                False,
            ),
        ],
    )
    def test_should_use_checks_notifier_deprecated_flow(
        self, repo_data, outcome, dbsession
    ):
        repository = RepositoryFactory.create(**repo_data)
        current_yaml = {"github_checks": True}
        assert repository.owner.github_app_installations == []
        service = NotificationService(repository, current_yaml, None)
&gt;       assert (
            service._should_use_checks_notifier(status_type=StatusType.PROJECT.value)
            == outcome
        )

services/notification/tests/unit/test_notification_service.py:113: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = &lt;services.notification.NotificationService object at 0x7f1c6276bd90&gt;
status_type = 'project'

    def _should_use_checks_notifier(self, status_type: StatusType) -&gt; bool:
        checks_yaml_field = read_yaml_field(self.current_yaml, ("github_checks",))
        if checks_yaml_field is False:
            return False
    
        owner: Owner = self.repository.owner
        if owner.service not in ["github", "github_enterprise"]:
            return False
    
        if (
            owner.plan
&gt;           in Plan.objects.filter(tier=TierName.TEAM.value).values_list(
                "name", flat=True
            )
            and status_type != StatusType.PATCH.value
        ):
E       NameError: name 'Plan' is not defined

services/notification/__init__.py:91: NameError
test_should_use_checks_notifier_deprecated_flow[repo_data2-True]
Stack Traces | 0.027s run time
self = &lt;test_notification_service.TestNotificationService object at 0x7f1c7400a190&gt;
repo_data = {'owner__integration_id': 12341234, 'owner__service': 'github_enterprise', 'using_integration': True}
outcome = True
dbsession = &lt;sqlalchemy.orm.session.Session object at 0x7f1c60158140&gt;

    @pytest.mark.parametrize(
        "repo_data,outcome",
        [
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="github",
                ),
                True,
            ),
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="gitlab",
                ),
                False,
            ),
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="github_enterprise",
                ),
                True,
            ),
            (
                dict(
                    using_integration=False,
                    owner__integration_id=None,
                    owner__service="github",
                ),
                False,
            ),
        ],
    )
    def test_should_use_checks_notifier_deprecated_flow(
        self, repo_data, outcome, dbsession
    ):
        repository = RepositoryFactory.create(**repo_data)
        current_yaml = {"github_checks": True}
        assert repository.owner.github_app_installations == []
        service = NotificationService(repository, current_yaml, None)
&gt;       assert (
            service._should_use_checks_notifier(status_type=StatusType.PROJECT.value)
            == outcome
        )

services/notification/tests/unit/test_notification_service.py:113: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = &lt;services.notification.NotificationService object at 0x7f1c62fc0050&gt;
status_type = 'project'

    def _should_use_checks_notifier(self, status_type: StatusType) -&gt; bool:
        checks_yaml_field = read_yaml_field(self.current_yaml, ("github_checks",))
        if checks_yaml_field is False:
            return False
    
        owner: Owner = self.repository.owner
        if owner.service not in ["github", "github_enterprise"]:
            return False
    
        if (
            owner.plan
&gt;           in Plan.objects.filter(tier=TierName.TEAM.value).values_list(
                "name", flat=True
            )
            and status_type != StatusType.PATCH.value
        ):
E       NameError: name 'Plan' is not defined

services/notification/__init__.py:91: NameError
test_should_use_checks_notifier_deprecated_flow[repo_data3-False]
Stack Traces | 0.028s run time
self = &lt;test_notification_service.TestNotificationService object at 0x7f1c7444ef90&gt;
repo_data = {'owner__integration_id': None, 'owner__service': 'github', 'using_integration': False}
outcome = False
dbsession = &lt;sqlalchemy.orm.session.Session object at 0x7f1c6015b6b0&gt;

    @pytest.mark.parametrize(
        "repo_data,outcome",
        [
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="github",
                ),
                True,
            ),
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="gitlab",
                ),
                False,
            ),
            (
                dict(
                    using_integration=True,
                    owner__integration_id=12341234,
                    owner__service="github_enterprise",
                ),
                True,
            ),
            (
                dict(
                    using_integration=False,
                    owner__integration_id=None,
                    owner__service="github",
                ),
                False,
            ),
        ],
    )
    def test_should_use_checks_notifier_deprecated_flow(
        self, repo_data, outcome, dbsession
    ):
        repository = RepositoryFactory.create(**repo_data)
        current_yaml = {"github_checks": True}
        assert repository.owner.github_app_installations == []
        service = NotificationService(repository, current_yaml, None)
&gt;       assert (
            service._should_use_checks_notifier(status_type=StatusType.PROJECT.value)
            == outcome
        )

services/notification/tests/unit/test_notification_service.py:113: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = &lt;services.notification.NotificationService object at 0x7f1c62fc1350&gt;
status_type = 'project'

    def _should_use_checks_notifier(self, status_type: StatusType) -&gt; bool:
        checks_yaml_field = read_yaml_field(self.current_yaml, ("github_checks",))
        if checks_yaml_field is False:
            return False
    
        owner: Owner = self.repository.owner
        if owner.service not in ["github", "github_enterprise"]:
            return False
    
        if (
            owner.plan
&gt;           in Plan.objects.filter(tier=TierName.TEAM.value).values_list(
                "name", flat=True
            )
            and status_type != StatusType.PATCH.value
        ):
E       NameError: name 'Plan' is not defined

services/notification/__init__.py:91: NameError

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

Copy link

codecov bot commented Jan 16, 2025

Codecov Report

Attention: Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 97.48%. Comparing base (2c7bd18) to head (1be033f).

❌ We are unable to process any of the uploaded JUnit XML files. Please ensure your files are in the right format.

Files with missing lines Patch % Lines
services/notification/__init__.py 60.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1007      +/-   ##
==========================================
- Coverage   97.74%   97.48%   -0.26%     
==========================================
  Files         451      451              
  Lines       36670    36668       -2     
==========================================
- Hits        35843    35747      -96     
- Misses        827      921      +94     
Flag Coverage Δ
integration 41.85% <40.00%> (-0.73%) ⬇️
unit 90.07% <60.00%> (-0.13%) ⬇️

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.

⚠️ Impact Analysis from Codecov is deprecated and will be sunset on Jan 31 2025. See more

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.

1 participant