예제 #1
0
    def test_convert_actors_to_user_set(self):
        user1 = self.create_user()
        user2 = self.create_user()
        user3 = self.create_user()
        user4 = self.create_user()

        team1 = self.create_team()
        team2 = self.create_team()

        self.create_member(user=user1,
                           organization=self.organization,
                           teams=[team1])
        self.create_member(user=user2,
                           organization=self.organization,
                           teams=[team2])
        self.create_member(user=user3,
                           organization=self.organization,
                           teams=[team1, team2])
        self.create_member(user=user4,
                           organization=self.organization,
                           teams=[])

        team1_events = set([
            self.create_event(self.project.id),
            self.create_event(self.project.id),
            self.create_event(self.project.id),
            self.create_event(self.project.id),
        ])
        team2_events = set([
            self.create_event(self.project.id),
            self.create_event(self.project.id),
            self.create_event(self.project.id),
            self.create_event(self.project.id),
        ])
        user4_events = set([
            self.create_event(self.project.id),
            self.create_event(self.project.id)
        ])
        events_by_actor = {
            Actor(team1.id, Team): team1_events,
            Actor(team2.id, Team): team2_events,
            Actor(user3.id, User): team1_events.union(team2_events),
            Actor(user4.id, User): user4_events,
        }
        user_by_events = {
            user1.id: team1_events,
            user2.id: team2_events,
            user3.id: team1_events.union(team2_events),
            user4.id: user4_events,
        }
        assert convert_actors_to_users(events_by_actor,
                                       user_by_events.keys()) == user_by_events
예제 #2
0
    def test_convert_actors_to_user_set(self):
        user1 = self.create_user()
        user2 = self.create_user()
        user3 = self.create_user()
        user4 = self.create_user()

        team1 = self.create_team()
        team2 = self.create_team()

        self.create_member(user=user1, organization=self.organization, teams=[team1])
        self.create_member(user=user2, organization=self.organization, teams=[team2])
        self.create_member(user=user3, organization=self.organization, teams=[team1, team2])
        self.create_member(user=user4, organization=self.organization, teams=[])

        team1_events = set([
            self.create_event(),
            self.create_event(),
            self.create_event(),
            self.create_event(),
        ])
        team2_events = set([
            self.create_event(),
            self.create_event(),
            self.create_event(),
            self.create_event(),
        ])
        user4_events = set([self.create_event(), self.create_event()])
        events_by_actor = {
            Actor(team1.id, Team): team1_events,
            Actor(team2.id, Team): team2_events,
            Actor(user3.id, User): team1_events.union(team2_events),
            Actor(user4.id, User): user4_events,
        }
        user_by_events = {
            user1.id: team1_events,
            user2.id: team2_events,
            user3.id: team1_events.union(team2_events),
            user4.id: user4_events,
        }
        assert convert_actors_to_users(events_by_actor, user_by_events.keys()) == user_by_events