コード例 #1
0
class PlayerTestSetUp(TestsSetUpBase):
    base_url = reverse('players-list')
    player1 = player(1)
    player2 = player(2)
    updated_player = PlayerRepresentation(1,
                                          team(1).model,
                                          player_person(2).model)

    def post_nested_to_single(self, person=player_person(1)):
        self.register_user()
        self.post_method(reverse('people-list'), person.json)
        self.post_method(reverse('teams-list'), team(1).json)

    def post_nested_to_both(self):
        self.post_nested_to_single()
        self.post_method(reverse('people-list'), player_person(2).json)

    def post_single_player(self):
        self.post_nested_to_single()
        self.post_method(self.base_url, self.player1.json)

    def post_two_players(self):
        self.post_nested_to_both()
        self.post_method(self.base_url, self.player1.json)
        self.post_method(self.base_url, self.player2.json)

    def get_nth_element_url(self, n):
        return self.get_specific_url(self.base_url, n)
コード例 #2
0
class TeamTestSetUp(TestsSetUpBase):
    base_url = reverse('teams-list')
    team1 = team(1)
    team2 = team(2)
    updated_team = team(1, 'updated_city')

    def post_single_team(self):
        self.register_user()
        self.post_method(self.base_url, self.team1.json)

    def post_two_teams(self):
        self.register_user()
        self.post_method(self.base_url, self.team1.json)
        self.post_method(self.base_url, self.team2.json)

    def get_nth_element_url(self, n):
        return self.get_specific_url(self.base_url, n)
コード例 #3
0
 def test_not_create_player_when_non_player_person_type(self):
     referee = referee_person(1)
     self.post_nested_to_single(referee)
     non_player_type_person = PlayerRepresentation(1,
                                                   team(1).model,
                                                   referee.model)
     response = self.post_method(self.base_url, non_player_type_person.json)
     self.assertEqual(status.HTTP_400_BAD_REQUEST, response.status_code)
コード例 #4
0
 def post_nested_to_single(self):
     self.register_user()
     self.create_goals()
     self.post_method(reverse('teams-list'), team(1).json)
     self.post_method(reverse('players-list'), self.player1.json)
     self.post_method(reverse('people-list'), coach_person(2).json)
     self.post_method(reverse('people-list'), referee_person(3).json)
     self.post_method(reverse('competitions-list'), league_competition(1).json)
     self.post_method(reverse('matches-list'), match(1, referee_person(3)).json)
     self.post_method(reverse('match_teams-list'), self.match_team.json)
コード例 #5
0
 def test_create_players_to_the_same_person(self):
     self.post_nested_to_single()
     player2_with_the_same_person = PlayerRepresentation(
         2,
         team(1).model,
         player_person(1).model)
     response = self.post_method(self.base_url, self.player1.json)
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     self.assertEqual(Player.objects.count(), 1)
     self.assertEqual(response.data, self.player1.json)
     response = self.post_method(self.base_url,
                                 player2_with_the_same_person.json)
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     self.assertEqual(Player.objects.count(), 2)
     self.assertEqual(response.data, player2_with_the_same_person.json)
コード例 #6
0
class TeamInMatchTestSetUp(TestsSetUpBase):
    base_url = reverse('teams_in_matches-list')
    competition = tournament_competition(1)
    referee = referee_person(1)
    coach = coach_person(2)
    team = team(1)
    match1 = match(1)
    match2 = match(2)
    team_in_match1 = TeamInMatchRepresentation(1, team.model, match1.model,
                                               coach.model)
    team_in_match2 = TeamInMatchRepresentation(2, team.model, match2.model,
                                               coach.model)
    updated_team_in_match = TeamInMatchRepresentation(1, team.model,
                                                      match2.model,
                                                      coach.model)

    def post_nested_to_single(self, coach_person=coach):
        self.register_user()
        self.post_method(reverse('teams-list'), self.team.json)
        self.post_method(reverse('people-list'), self.referee.json)
        self.post_method(reverse('people-list'), coach_person.json)
        self.post_method(reverse('competitions-list'), self.competition.json)
        self.post_method(reverse('matches-list'), self.match1.json)

    def post_nested_to_both(self):
        self.register_user()
        self.post_nested_to_single()
        self.post_method(reverse('matches-list'), self.match2.json)

    def post_single_match(self):
        self.post_nested_to_single()
        self.post_method(self.base_url, self.team_in_match1.json)

    def post_two_matches(self):
        self.post_nested_to_both()
        self.post_method(self.base_url, self.team_in_match1.json)
        self.post_method(self.base_url, self.team_in_match2.json)

    def get_nth_element_url(self, n):
        return self.get_specific_url(self.base_url, n)
コード例 #7
0
 def post_nested(self):
     self.register_user()
     self.post_method(reverse('teams-list'), team(1).json)
     self.post_method(reverse('teams-list'), team(2).json)
コード例 #8
0
 def post_nested_to_single(self, person=player_person(1)):
     self.register_user()
     self.post_method(reverse('people-list'), person.json)
     self.post_method(reverse('teams-list'), team(1).json)