Example #1
0
 def test_officials_for_team_id_and_specific_year(self):
     official_service = OfficialService()
     team = DbSetupOfficials().create_officials_full_setup()
     result_list = official_service.get_officials_for(team_id=team.pk,
                                                      year=2020)
     assert len(result_list['officials_list']) == 1
     assert result_list['year'] == 2020
 def test_appearance_list_is_correct(self):
     team = DbSetupOfficials().create_officials_full_setup()
     current_year = datetime.today().year
     officials_list = OfficialAppearanceTeamList(team.pk, current_year)
     result = officials_list.as_json()
     assert result['year'] == current_year
     assert len(result['officials_list']) == 2
 def test_game_official_is_serialized(self):
     DbSetupOfficials().create_officials_full_setup()
     first_entry = GameOfficial.objects.first()
     first_entry.name = None
     first_entry.save()
     all_game_officials = GameOfficial.objects.all()
     serializer = GameOfficialAllInfosSerializer(instance=all_game_officials, many=True)
     assert serializer.data[0].get('name') == 'F***** F*****'
Example #4
0
 def test_get_officials_for_team(self):
     team: Team = DbSetupOfficials().create_officials_and_team();
     # last_game = Gameinfo.objects.last()
     # assert len(GameOfficial.objects.all()) == 0
     official = Official.objects.first();
     response = self.app.get(reverse(API_OFFICIALS_FOR_TEAM, kwargs={'pk': team.pk}))
     assert response.status_code == HTTPStatus.OK
     assert len(response.json) == 2
     assert response.json[0] == OfficialSerializer(official).data
 def test_list_entry_results_as_expected(self):
     DbSetupOfficials().create_officials_full_setup()
     current_year = datetime.today().year
     first_official = Official.objects.first()
     first_team = Team.objects.first()
     team_list_entry = OfficialAppearanceTeamListEntry(first_official, current_year).as_json()
     assert team_list_entry == {
         'id': first_official.pk,
         'first_name': 'Franzi',
         'last_name': 'Fedora',
         'team': 'Test Team',
         'team_id': first_team.pk,
         'license': 'F1',
         'referee': 1,
         'down_judge': 1,
         'field_judge': 1,
         'side_judge': 1,
         'overall': 4,
     }
Example #6
0
 def test_officials_for_team_id(self):
     official_service = OfficialService()
     team = DbSetupOfficials().create_officials_full_setup()
     result_list = official_service.get_officials_for(team_id=team.pk)
     assert len(result_list['officials_list']) == 2
 def test_names_are_obfuscated(self):
     DbSetupOfficials().create_officials_full_setup()
     all_game_officials = GameOfficial.objects.all()
     serializer = GameOfficialAllInfosSerializer(all_game_officials, many=True)
     assert serializer.data[0].get('name') == 'F***** F*****'
 def test_names_are_clear_for_same_team_name(self):
     DbSetupOfficials().create_officials_full_setup()
     all_game_officials = GameOfficial.objects.all()
     serializer = GameOfficialAllInfosSerializer(instance=all_game_officials, display_names_for_team='officials',
                                                 many=True)
     assert serializer.data[0].get('name') == 'Franzi Fedora'
 def test_names_are_clear_for_staff(self):
     DbSetupOfficials().create_officials_full_setup()
     all_game_officials = GameOfficial.objects.all()
     serializer = GameOfficialAllInfosSerializer(all_game_officials, is_staff=True, many=True)
     assert serializer.data[0].get('name') == 'Franzi Fedora'