Ejemplo n.º 1
0
    def setUp(self):
        self.user = self.create_user(email="*****@*****.**", is_active=True)
        self.user2 = self.create_user(email="*****@*****.**", is_active=True)
        self.organization = self.create_organization(owner=self.user)
        self.team = self.create_team(organization=self.organization)

        self.project = self.create_project(name="Test", teams=[self.team])
        OrganizationMemberTeam.objects.create(
            organizationmember=OrganizationMember.objects.get(
                user=self.user, organization=self.organization),
            team=self.team,
        )
        self.create_member(user=self.user2,
                           organization=self.organization,
                           teams=[self.team])
        ProjectOwnership.objects.create(
            project_id=self.project.id,
            schema=dump_schema([
                grammar.Rule(Matcher("path", "*.py"),
                             [Owner("team", self.team.slug)]),
                grammar.Rule(Matcher("path", "*.jx"),
                             [Owner("user", self.user2.email)]),
                grammar.Rule(
                    Matcher("path", "*.cbl"),
                    [
                        Owner("user", self.user.email),
                        Owner("user", self.user2.email)
                    ],
                ),
            ]),
            fallthrough=True,
        )
Ejemplo n.º 2
0
    def setUp(self):
        self.user2 = self.create_user(email="*****@*****.**", is_active=True)
        self.user3 = self.create_user(email="*****@*****.**", is_active=True)

        self.team2 = self.create_team(organization=self.organization,
                                      members=[self.user, self.user2])
        self.project.add_team(self.team2)

        ProjectOwnership.objects.create(
            project_id=self.project.id,
            schema=dump_schema([
                grammar.Rule(Matcher("path", "*.py"),
                             [Owner("team", self.team2.slug)]),
                grammar.Rule(Matcher("path", "*.jsx"),
                             [Owner("user", self.user.email)]),
                grammar.Rule(Matcher("path", "*.jx"),
                             [Owner("user", self.user3.email)]),
                grammar.Rule(
                    Matcher("path", "*.cbl"),
                    [
                        Owner("user", user.email)
                        for user in User.objects.filter(
                            id__in=self.project.member_set.values_list(
                                "user", flat=True))
                    ],
                ),
                grammar.Rule(Matcher("path", "*.lol"), []),
            ]),
            fallthrough=True,
        )
Ejemplo n.º 3
0
    def test_notify_users_with_owners(self):
        user = self.create_user(email="*****@*****.**", is_active=True)
        user2 = self.create_user(email="*****@*****.**", is_active=True)

        organization = self.create_organization(owner=user)
        team = self.create_team(organization=organization)
        project = self.create_project(name="Test", teams=[team])
        OrganizationMemberTeam.objects.create(
            organizationmember=OrganizationMember.objects.get(user=user, organization=organization),
            team=team,
        )
        self.create_member(user=user2, organization=organization, teams=[team])
        self.group = self.create_group(
            first_seen=timezone.now(),
            last_seen=timezone.now(),
            project=project,
            message="hello  world",
            logger="root",
        )
        ProjectOwnership.objects.create(
            project_id=project.id,
            schema=dump_schema(
                [
                    grammar.Rule(Matcher("path", "*.py"), [Owner("team", team.slug)]),
                    grammar.Rule(Matcher("path", "*.jx"), [Owner("user", user2.email)]),
                    grammar.Rule(
                        Matcher("path", "*.cbl"),
                        [Owner("user", user.email), Owner("user", user2.email)],
                    ),
                ]
            ),
            fallthrough=True,
        )

        event_all_users = self.store_event(
            data=self.make_event_data("foo.cbl"), project_id=project.id
        )
        self.assert_notify(event_all_users, [user.email, user2.email])

        event_team = self.store_event(data=self.make_event_data("foo.py"), project_id=project.id)
        self.assert_notify(event_team, [user.email, user2.email])

        event_single_user = self.store_event(
            data=self.make_event_data("foo.jx"), project_id=project.id
        )
        self.assert_notify(event_single_user, [user2.email])

        # Make sure that disabling mail alerts works as expected
        NotificationSetting.objects.update_settings(
            ExternalProviders.EMAIL,
            NotificationSettingTypes.ISSUE_ALERTS,
            NotificationSettingOptionValues.NEVER,
            user=user2,
            project=project,
        )
        event_all_users = self.store_event(
            data=self.make_event_data("foo.cbl"), project_id=project.id
        )
        self.assert_notify(event_all_users, [user.email])
Ejemplo n.º 4
0
 def setUp(self):
     self.user2 = self.create_user(email="*****@*****.**", is_active=True)
     self.create_member(user=self.user2, organization=self.organization, teams=[self.team])
     ProjectOwnership.objects.create(
         project_id=self.project.id,
         schema=dump_schema(
             [
                 grammar.Rule(Matcher("path", "*.py"), [Owner("team", self.team.slug)]),
                 grammar.Rule(Matcher("path", "*.jx"), [Owner("user", self.user2.email)]),
                 grammar.Rule(
                     Matcher("path", "*.cbl"),
                     [Owner("user", self.user.email), Owner("user", self.user2.email)],
                 ),
             ]
         ),
         fallthrough=True,
     )
Ejemplo n.º 5
0
    def setUp(self):
        self.user = self.create_user(email="*****@*****.**", is_active=True)
        self.user2 = self.create_user(email="*****@*****.**", is_active=True)
        self.user3 = self.create_user(email="*****@*****.**", is_active=True)

        self.organization = self.create_organization(owner=self.user)
        self.team = self.create_team(organization=self.organization,
                                     members=[self.user2, self.user3])
        self.team2 = self.create_team(organization=self.organization,
                                      members=[self.user])
        self.project = self.create_project(name="Test",
                                           teams=[self.team, self.team2])
        self.group = self.create_group(
            first_seen=timezone.now(),
            last_seen=timezone.now(),
            project=self.project,
            message="hello  world",
            logger="root",
        )
        ProjectOwnership.objects.create(
            project_id=self.project.id,
            schema=dump_schema([
                grammar.Rule(Matcher("path", "*.py"),
                             [Owner("team", self.team.slug)]),
                grammar.Rule(Matcher("path", "*.jx"),
                             [Owner("user", self.user2.email)]),
                grammar.Rule(
                    Matcher("path", "*.cbl"),
                    [
                        Owner("user", self.user.email),
                        Owner("user", self.user2.email),
                        Owner("user", self.user3.email),
                    ],
                ),
            ]),
            fallthrough=True,
        )