Пример #1
0
    def test_fill_empty_rooms_if_full_rooms_exist(self):
        TeamFactory(season=self.active_season, room=self.room1)
        TeamFactory(season=self.active_season, room=self.room1)
        TeamFactory(season=self.active_season, room=self.room2)
        TeamFactory(season=self.active_season, room=self.room2)

        self.assertEqual(
            4,
            Team.objects.filter(season=self.active_season,
                                room__isnull=False).count())
        teams_and_rooms = Team.objects.filter(season=self.active_season,
                                              room__isnull=False).values(
                                                  'id', 'room')

        team = TeamFactory(season=self.active_season, room=None)
        call_command('fillrooms')
        updated_teams_rooms = Team.objects.filter(season=self.active_season,
                                                  room__isnull=False).values(
                                                      'id', 'room')

        for tr in teams_and_rooms:
            self.assertIn(tr, updated_teams_rooms)

        team.refresh_from_db()
        team_info = {'id': team.id, 'room': team.room.id}
        self.assertIn(team_info, updated_teams_rooms)
        self.assertEqual(5, Team.objects.filter(room__isnull=False).count())
Пример #2
0
 def test_signal_sets_to_false_looking_for_team_property_after_team_membership_is_created(self):
     team = TeamFactory(season=self.season)
     TeamMembershipFactory(team=team,
                           competitor=self.competitor,
                           is_leader=False)
     self.season_competitor_info.refresh_from_db()
     self.assertFalse(self.season_competitor_info.looking_for_team)
Пример #3
0
 def setUp(self):
     self.active_season = SeasonFactory(is_active=True)
     self.room = RoomFactory(season=self.active_season)
     self.team = TeamFactory(season=self.active_season, room=self.room)
     self.competitor = CompetitorFactory()
     self.team_membership = TeamMembershipFactory(competitor=self.competitor,
                                                  team=self.team,
                                                  is_leader=True)
Пример #4
0
 def test_get_all_team_memberships_for_competitor_with_two_teams(self):
     new_active_season = SeasonFactory(is_active=True)
     room = RoomFactory(season=new_active_season)
     team = TeamFactory(season=new_active_season, room=room)
     team_membership = TeamMembershipFactory(competitor=self.competitor,
                                             team=team,
                                             is_leader=True)
     team_membership.refresh_from_db()
     self.assertEqual(2, TeamMembership.objects.get_all_team_memberships_for_competitor(
         competitor=self.competitor).count())
Пример #5
0
    def test_get_all_teams_for_competitor(self):
        self.assertEqual(1, Team.objects.count())
        self.assertEqual(1, Team.objects.get_all_teams_for_competitor(competitor=self.competitor).count())
        new_active_season = SeasonFactory(is_active=True)
        room = RoomFactory(season=new_active_season)
        team = TeamFactory(season=new_active_season, room=room)
        self.team_membership = TeamMembershipFactory(competitor=self.competitor,
                                                     team=team,
                                                     is_leader=False)

        self.assertEqual(2, Team.objects.get_all_teams_for_competitor(competitor=self.competitor).count())
Пример #6
0
    def test_get_all_teams_for_current_season(self):
        self.assertEqual(1, Team.objects.count())
        self.assertEqual(1, Team.objects.get_all_teams_for_current_season(season=self.active_season).count())

        room = RoomFactory(season=self.active_season)
        team = TeamFactory(season=self.active_season, room=room)
        competitor = CompetitorFactory()
        self.team_membership = TeamMembershipFactory(competitor=competitor,
                                                     team=team,
                                                     is_leader=False)

        self.assertEqual(2, Team.objects.get_all_teams_for_current_season(season=self.active_season).count())
Пример #7
0
 def test_fill_empty_rooms_if_all_rooms_were_empty(self):
     [
         TeamFactory(season=self.active_season, room=None)
         for _ in range(self.teams_count)
     ]
     self.assertEqual(
         0,
         Team.objects.filter(season=self.active_season,
                             room__isnull=False).count())
     call_command('fillrooms')
     self.assertEqual(
         self.teams_count,
         Team.objects.filter(season=self.active_season,
                             room__isnull=False).count())
Пример #8
0
    def setUp(self):
        self.active_season = SeasonFactory(is_active=True)
        self.room = RoomFactory(season=self.active_season)
        self.team = TeamFactory(season=self.active_season, room=self.room)
        self.competitor = CompetitorFactory()
        self.team_membership = TeamMembershipFactory(competitor=self.competitor,
                                                     team=self.team,
                                                     is_leader=True)

        self.company = HackFmiPartnerFactory()
        self.mentor = MentorFactory(from_company=self.company)

        self.team_mentorship = TeamMentorshipFactory(team=self.team,
                                                     mentor=self.mentor)
Пример #9
0
    def test_server_group_send_message_to_client_on_post_save_of_invitation(
            self):
        competitor = CompetitorFactory()

        # Add test-channel to Invitation example group
        expected_group_name = settings.INVITATION_GROUP_NAME.format(
            id=competitor.id)
        Group(expected_group_name).add("test-channel")

        team = TeamFactory(season__is_active=True)
        TeamMembershipFactory(team=team, competitor=competitor, is_leader=True)
        InvitationFactory(team=team, competitor=competitor)
        # Get the message that is transferred into the channel
        result = self.get_next_message("test-channel")
        result = json.loads(result.get('text'))
        self.assertEqual(result['message'], "New invitation was created.")
        self.assertEqual(result['leader'], competitor.full_name)
Пример #10
0
    def test_fill_teams_in_rooms_if_team_capacity_less_than_team_count(self):
        self.room2.capacity = 2
        self.room2.save()
        self.room3.capacity = 1
        self.room3.save()

        [
            TeamFactory(season=self.active_season, room=None)
            for _ in range(self.teams_count)
        ]
        self.assertEqual(
            0,
            Team.objects.filter(season=self.active_season,
                                room__isnull=False).count())
        call_command('fillrooms')
        self.assertEqual(
            self.teams_count,
            Team.objects.filter(season=self.active_season,
                                room__isnull=False).count())
        self.assertFalse(
            Team.objects.filter(season=self.active_season,
                                room__isnull=True).exists())
Пример #11
0
 def test_get_all_team_mentorships_for_team_with_no_mentors(self):
     room = RoomFactory(season=self.active_season)
     team = TeamFactory(season=self.active_season, room=room)
     self.assertEqual(None, TeamMentorship.objects.get_all_team_mentorships_for_team(
         team=team).first())
Пример #12
0
 def setUp(self):
     self.permission = IsTeamLeader()
     self.team = TeamFactory(season__is_active=True)
     self.competitor = CompetitorFactory()
     self.team_membership = TeamMembershipFactory(
         competitor=self.competitor, team=self.team, is_leader=False)
Пример #13
0
 def setUp(self):
     self.permission = IsTeamLeaderOrReadOnly()
     self.team = TeamFactory()
     self.competitor = CompetitorFactory()
     self.team_membership = TeamMembershipFactory(
         competitor=self.competitor, team=self.team, is_leader=False)