Skip to content

Commit

Permalink
chore: Update Disruption model fields to be optional (#63)
Browse files Browse the repository at this point in the history
* chore: Update Disruption model fields to be optional

Make the 'summary', 'additional_info', 'created', and 'last_update' fields in the Disruption model optional by setting their default value to None. This allows for more flexibility when creating instances of the Disruption class and handling data that may not always be available.

* Update test to model mapping
  • Loading branch information
mnbf9rca authored Jul 23, 2024
1 parent d41e815 commit add357e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions pydantic_tfl_api/models/disruption.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ class Disruption(BaseModel):
disruption_type: str = Field(alias='type')
category_description: str = Field(alias='categoryDescription')
description: str = Field(alias='description')
summary: str = Field(alias='summary')
additional_info: str = Field(alias='additionalInfo')
created: datetime = Field(alias='created')
last_update: datetime = Field(alias='lastUpdate')
summary: Optional[str] = Field(None, alias='summary')
additional_info: Optional[str] = Field(None, alias='additionalInfo')
created: Optional[datetime] = Field(None, alias='created')
last_update: Optional[datetime] = Field(None, alias='lastUpdate')
affected_routes: List[AffectedRoute] = Field(alias='affectedRoutes')
affected_stops: List[StopPoint] = Field(alias='affectedStops')
closure_text: str = Field(alias='closureText')
Expand Down
2 changes: 1 addition & 1 deletion pydantic_tfl_api/models/matched_stop.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class MatchedStop(BaseModel):
top_most_parent_id: Optional[str] = Field(None, alias='topMostParentId')
modes: list[str]
stop_type: str = Field(alias='stopType')
zone: str = Field(alias='zone')
zone: Optional[str] = Field(None, alias='zone')
lines: Optional[list[Identifier]] = Field([], alias='lines')
status: bool = Field(alias='status')
id: str = Field(alias='id')
Expand Down
18 changes: 9 additions & 9 deletions tests/config_for_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,63 +129,63 @@
"endpoint": "routeByLineIdWithDirection",
"endpoint_args": ["victoria", "inbound"],
"endpoint_params": {},
"model": "Line",
"model": "RouteSequence",
"result_is_empty": False,
},
"routeByLineIdWithDirection_14_outbound_None_Line": {
"endpoint": "routeByLineIdWithDirection",
"endpoint_args": ["14", "outbound"],
"endpoint_params": {},
"model": "Line",
"model": "RouteSequence",
"result_is_empty": False,
},
"routeByLineIdWithDirection_northern_all_None_Line": {
"endpoint": "routeByLineIdWithDirection",
"endpoint_args": ["northern", "all"],
"endpoint_params": {},
"model": "Line",
"model": "RouteSequence",
"result_is_empty": False,
},
"lineDisruptionsByLineId_victoria_None_Line": {
"endpoint": "lineDisruptionsByLineId",
"endpoint_args": ["victoria"],
"endpoint_params": {},
"model": "Line",
"model": "Disruption",
"result_is_empty": True,
},
"lineDisruptionsByLineId_victoria_northern_None_Line": {
"endpoint": "lineDisruptionsByLineId",
"endpoint_args": ["victoria,northern"],
"endpoint_params": {},
"model": "Line",
"model": "Disruption",
"result_is_empty": True,
},
"lineDisruptionsByLineId_piccadilly_None_Line": {
"endpoint": "lineDisruptionsByLineId",
"endpoint_args": ["piccadilly"],
"endpoint_params": {},
"model": "Line",
"model": "Disruption",
"result_is_empty": False,
},
"lineDisruptionsByLineId_14_None_Line": {
"endpoint": "lineDisruptionsByLineId",
"endpoint_args": ["14"],
"endpoint_params": {},
"model": "Line",
"model": "Disruption",
"result_is_empty": True,
},
"lineDisruptionsByMode_tube_None_Line": {
"endpoint": "lineDisruptionsByMode",
"endpoint_args": ["tube"],
"endpoint_params": {},
"model": "Line",
"model": "Disruption",
"result_is_empty": False,
},
"lineDisruptionsByMode_tube_overground_None_Line": {
"endpoint": "lineDisruptionsByMode",
"endpoint_args": ["tube,overground"],
"endpoint_params": {},
"model": "Line",
"model": "Disruption",
"result_is_empty": False,
},
"stopPointById_940GZZLUASL_None_StopPoint": {
Expand Down

0 comments on commit add357e

Please sign in to comment.