Coverage for models/match_data.py: 0.00%

19 statements  

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

1""" 

2Match data model for message queue processing. 

3 

4This model validates match data received from RabbitMQ messages. 

5It must match the JSON schema defined in docs/08-integrations/match-message-schema.json. 

6 

7NOTE: This model is intentionally duplicated in match-scraper repo to avoid 

8cross-repo dependencies. Contract is enforced via JSON schema and tests. 

9""" 

10 

11from datetime import date 

12from typing import Literal 

13 

14from pydantic import BaseModel, Field 

15 

16 

17class MatchData(BaseModel): 

18 """ 

19 Match data model - must match match-message-schema.json. 

20 

21 This is used by Celery workers to validate incoming match messages. 

22 """ 

23 

24 # Required fields 

25 home_team: str = Field(..., min_length=1, description="Home team name") 

26 away_team: str = Field(..., min_length=1, description="Away team name") 

27 date: date = Field(..., description="Match date") 

28 season: str = Field(..., min_length=1, description="Season identifier") 

29 age_group: str = Field(..., min_length=1, description="Age group") 

30 match_type: str = Field(..., min_length=1, description="Match type") 

31 

32 # Optional fields 

33 division: str | None = Field(None, description="Division name") 

34 score_home: int | None = Field(None, ge=0, description="Home team score") 

35 score_away: int | None = Field(None, ge=0, description="Away team score") 

36 status: Literal["scheduled", "tbd", "completed", "postponed", "cancelled"] | None = Field( 

37 None, description="Match status (tbd = match played, score pending)" 

38 ) 

39 match_id: str | None = Field(None, description="External match ID for deduplication") 

40 location: str | None = Field(None, description="Match location/venue") 

41 notes: str | None = Field(None, description="Additional notes") 

42 

43 class Config: 

44 """Pydantic configuration.""" 

45 

46 json_schema_extra = { 

47 "examples": [ 

48 { 

49 "home_team": "Chicago Fire Juniors", 

50 "away_team": "Indiana Fire Academy", 

51 "date": "2025-10-13", 

52 "season": "2024-25", 

53 "age_group": "U14", 

54 "match_type": "League", 

55 "division": "Northeast", 

56 "score_home": 2, 

57 "score_away": 1, 

58 "status": "completed", 

59 "match_id": "mlsnext_12345", 

60 "location": "Toyota Park", 

61 } 

62 ] 

63 }