Coverage for models/teams.py: 82.14%

26 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2026-04-13 00:07 +0000

1""" 

2Team-related Pydantic models. 

3""" 

4 

5from pydantic import BaseModel, model_validator 

6 

7 

8class Team(BaseModel): 

9 """Model for creating a new team.""" 

10 

11 name: str 

12 city: str 

13 age_group_ids: list[int] # Required: at least one age group 

14 match_type_ids: list[int] | None = None # Optional: game types team participates in 

15 division_id: int | None = None # Optional: required for league teams only 

16 club_id: int | None = None # FK to clubs table 

17 academy_team: bool | None = False 

18 

19 @model_validator(mode="after") 

20 def validate_team(self): 

21 """Validate team has at least one age group.""" 

22 if not self.age_group_ids or len(self.age_group_ids) == 0: 

23 raise ValueError("Team must have at least one age group") 

24 return self 

25 

26 

27class TeamUpdate(BaseModel): 

28 """Model for updating team information.""" 

29 

30 name: str 

31 city: str 

32 academy_team: bool | None = False 

33 club_id: int | None = None 

34 

35 

36class TeamMatchTypeMapping(BaseModel): 

37 """Model for team match type participation.""" 

38 

39 match_type_id: int 

40 age_group_id: int 

41 

42 

43class TeamMappingCreate(BaseModel): 

44 """Model for creating team mappings.""" 

45 

46 team_id: int 

47 age_group_id: int 

48 division_id: int