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 4 commits 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

codecov-staging bot commented Jan 16, 2025

❌ 18 Tests Failed:

Tests completed Failed Passed Skipped
1782 18 1764 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_data2-True]
Stack Traces | 0.024s run time
self = <test_notification_service.TestNotificationService object at 0x7f1acef26c40>
repo_data = {'owner__integration_id': 12341234, 'owner__service': 'github_enterprise', 'using_integration': True}
outcome = True
dbsession = <sqlalchemy.orm.session.Session object at 0x7f1ab7faf2f0>

    @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 0x7f1abd009f30>
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_data0-True]
Stack Traces | 0.025s run time
self = <test_notification_service.TestNotificationService object at 0x7f1acee0de50>
repo_data = {'owner__integration_id': 12341234, 'owner__service': 'github', 'using_integration': True}
outcome = True
dbsession = <sqlalchemy.orm.session.Session object at 0x7f1abc009a90>

    @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 0x7f1abe356ad0>
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.025s run time
self = <test_notification_service.TestNotificationService object at 0x7f1acee431d0>
repo_data = {'owner__integration_id': None, 'owner__service': 'github', 'using_integration': False}
outcome = False
dbsession = <sqlalchemy.orm.session.Session object at 0x7f1abd6374d0>

    @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 0x7f1abd00b5c0>
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
1782 18 1764 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_data2-True]
Stack Traces | 0.024s run time
self = <test_notification_service.TestNotificationService object at 0x7f1acef26c40>
repo_data = {'owner__integration_id': 12341234, 'owner__service': 'github_enterprise', 'using_integration': True}
outcome = True
dbsession = <sqlalchemy.orm.session.Session object at 0x7f1ab7faf2f0>

    @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 0x7f1abd009f30>
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_data0-True]
Stack Traces | 0.025s run time
self = <test_notification_service.TestNotificationService object at 0x7f1acee0de50>
repo_data = {'owner__integration_id': 12341234, 'owner__service': 'github', 'using_integration': True}
outcome = True
dbsession = <sqlalchemy.orm.session.Session object at 0x7f1abc009a90>

    @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 0x7f1abe356ad0>
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.025s run time
self = <test_notification_service.TestNotificationService object at 0x7f1acee431d0>
repo_data = {'owner__integration_id': None, 'owner__service': 'github', 'using_integration': False}
outcome = False
dbsession = <sqlalchemy.orm.session.Session object at 0x7f1abd6374d0>

    @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 0x7f1abd00b5c0>
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

codecov-public-qa bot commented Jan 16, 2025

❌ 18 Tests Failed:

Tests completed Failed Passed Skipped
1782 18 1764 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_data2-True]
Stack Traces | 0.024s run time
self = <test_notification_service.TestNotificationService object at 0x7f1acef26c40>
repo_data = {'owner__integration_id': 12341234, 'owner__service': 'github_enterprise', 'using_integration': True}
outcome = True
dbsession = <sqlalchemy.orm.session.Session object at 0x7f1ab7faf2f0>

    @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 0x7f1abd009f30>
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_data0-True]
Stack Traces | 0.025s run time
self = <test_notification_service.TestNotificationService object at 0x7f1acee0de50>
repo_data = {'owner__integration_id': 12341234, 'owner__service': 'github', 'using_integration': True}
outcome = True
dbsession = <sqlalchemy.orm.session.Session object at 0x7f1abc009a90>

    @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 0x7f1abe356ad0>
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.025s run time
self = <test_notification_service.TestNotificationService object at 0x7f1acee431d0>
repo_data = {'owner__integration_id': None, 'owner__service': 'github', 'using_integration': False}
outcome = False
dbsession = <sqlalchemy.orm.session.Session object at 0x7f1abd6374d0>

    @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 0x7f1abd00b5c0>
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

github-actions bot commented Jan 16, 2025

❌ 18 Tests Failed:

Tests completed Failed Passed Skipped
1786 18 1764 4
View the top 3 failed tests by shortest run time
test_should_use_checks_notifier_deprecated_flow[repo_data2-True]
Stack Traces | 0.024s run time
self = &lt;test_notification_service.TestNotificationService object at 0x7f1acef26c40&gt;
repo_data = {'owner__integration_id': 12341234, 'owner__service': 'github_enterprise', 'using_integration': True}
outcome = True
dbsession = &lt;sqlalchemy.orm.session.Session object at 0x7f1ab7faf2f0&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 0x7f1abd009f30&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_data0-True]
Stack Traces | 0.025s run time
self = &lt;test_notification_service.TestNotificationService object at 0x7f1acee0de50&gt;
repo_data = {'owner__integration_id': 12341234, 'owner__service': 'github', 'using_integration': True}
outcome = True
dbsession = &lt;sqlalchemy.orm.session.Session object at 0x7f1abc009a90&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 0x7f1abe356ad0&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.025s run time
self = &lt;test_notification_service.TestNotificationService object at 0x7f1acee431d0&gt;
repo_data = {'owner__integration_id': None, 'owner__service': 'github', 'using_integration': False}
outcome = False
dbsession = &lt;sqlalchemy.orm.session.Session object at 0x7f1abd6374d0&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 0x7f1abd00b5c0&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.50%. Comparing base (72f2512) to head (a272a6a).
Report is 1 commits behind head on main.

Current head a272a6a differs from pull request most recent head 7216f13

Please upload reports for the commit 7216f13 to get more accurate results.

❌ 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.76%   97.50%   -0.27%     
==========================================
  Files         451      451              
  Lines       36798    36810      +12     
==========================================
- Hits        35974    35890      -84     
- Misses        824      920      +96     
Flag Coverage Δ
integration 41.76% <40.00%> (-0.72%) ⬇️
unit 90.10% <60.00%> (-0.12%) ⬇️

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