示例#1
0
    def test_create_team(self):
        section = Section()

        # ACT
        result = section.get_team('12', 'test team')

        # ASSERT
        self.assertIsInstance(result, Team)
        self.assertEqual(result.team_id, '12')
        self.assertEqual(result.name, 'test team')
示例#2
0
    def test_when_team_has_no_responses_expect_none(self):
        # ARRANGE
        section = Section()
        team = section.get_team('1', 'team 1')

        # ACT
        result = section.response_for_team(team)

        # ASSERT
        self.assertEqual(result, None)
示例#3
0
    def test_when_team_has_one_response_expect_one_response(self):
        # ARRANGE
        section = Section()
        team = section.get_team('1', 'team 1')
        response = Response(team=team)
        section.add_response(response)

        # ACT
        result = section.response_for_team(team)

        # ASSERT
        self.assertEqual(result, response)
示例#4
0
    def test_get_existing_team_with_quiz(self):
        quiz = Quiz()
        section = Section(quiz=quiz)
        team = Team('12', 'test team')
        quiz.teams = [team]

        # ACT
        result = section.get_team('12', 'test team')

        # ASSERT
        self.assertEqual(result, team)
        self.assertEqual(len(quiz.teams), 1)
示例#5
0
    def test_create_new_team_with_quiz(self):
        quiz = Quiz()
        section = Section(quiz=quiz)

        # ACT
        result = section.get_team('12', 'test team')

        # ASSERT
        self.assertIsInstance(result, Team)
        self.assertEqual(result.team_id, '12')
        self.assertEqual(result.name, 'test team')

        self.assertEqual(len(quiz.teams), 1)
示例#6
0
    def test_when_team_has_multiple_responses_expect_all_responses(self):
        # ARRANGE
        section = Section()
        team = section.get_team('1', 'team 1')
        response1 = Response(team=team)
        section.add_response(response1)
        response2 = Response(team=team)
        section.add_response(response2)

        # ACT
        result = section.responses_for_team(team)

        # ASSERT
        self.assertEqual(result, {response1, response2})
示例#7
0
    def test_when_team_has_multiple_responses_expect_first(self):
        # ARRANGE
        section = Section()
        team = section.get_team('1', 'team 1')
        response1 = Response(team=team, timestamp='2020/11/01 20:00:00')
        section.add_response(response1)
        response2 = Response(team=team, timestamp='2020/11/01 19:00:00')
        section.add_response(response2)
        response3 = Response(team=team, timestamp='2020/11/01 21:00:00')
        section.add_response(response3)

        # ACT
        result = section.response_for_team(team)

        # ASSERT
        self.assertEqual(result, response2)
示例#8
0
    def test_when_team_has_multiple_responses_expect_only_score_of_first_response(
            self):
        section = Section()
        team = section.get_team('1', 'team1')
        response1 = Response(team=team, timestamp='2020/11/01 20:00:00')
        response1.score = lambda: 5
        section.add_response(response1)

        response2 = Response(team=team, timestamp='2020/11/01 19:00:00')
        response2.score = lambda: 4
        section.add_response(response2)

        response3 = Response(team=team, timestamp='2020/11/01 21:00:00')
        response3.score = lambda: 3
        section.add_response(response3)

        # ACT
        result = section.scores()

        # ASSERT
        self.assertEqual(result, {team: 4})