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)
class PersonTestSetUp(TestsSetUpBase): base_url = reverse('people-list') person1 = coach_person(1) person2 = player_person(2) updated_person = referee_person(1) def get_nth_element_url(self, n): return self.get_specific_url(self.base_url, n) def post_single_person(self): self.register_user() self.post_method(self.base_url, self.person1.json) def post_two_persons(self): self.register_user() self.post_method(self.base_url, self.person1.json) self.post_method(self.base_url, self.person2.json)
class TeamEventTestSetUp(TestsSetUpBase): base_url = reverse('team_events-list') player1 = player(1) match_team = match_team(1, coach_person(2), match(1, referee_person(3))) def create_events(self): self.register_user(2) self.event_info1 = event_info(1, self.get_user_model(2)) self.event_info2 = event_info(2, self.get_user_model(2)) self.team_event1 = TeamEventRepresentation(1, self.player1.model, self.match_team.model, self.event_info1.model) self.team_event2 = TeamEventRepresentation(2, self.player1.model, self.match_team.model, self.event_info2.model) self.updated_team_event = TeamEventRepresentation( 1, self.player1.model, self.match_team.model, self.event_info2.model) def post_nested_to_single(self): self.register_user() self.create_events() 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) def post_nested_to_both(self): self.post_nested_to_single() def post_single_match(self): self.post_nested_to_single() self.post_method(self.base_url, self.team_event1.json) def post_two_matches(self): self.post_nested_to_both() self.post_method(self.base_url, self.team_event1.json) self.post_method(self.base_url, self.team_event2.json) def get_nth_element_url(self, n): return self.get_specific_url(self.base_url, n)
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)
def setUp(self): self.coach = coach_person(1) self.post_nested_to_single(self.coach)