From 468fe355a5ecf11ae87f542e98c1dccc6e2efc75 Mon Sep 17 00:00:00 2001 From: rob al Date: Tue, 23 Jul 2024 11:06:41 +0000 Subject: [PATCH] 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. --- pydantic_tfl_api/models/disruption.py | 8 ++++---- tests/config_for_tests.py | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pydantic_tfl_api/models/disruption.py b/pydantic_tfl_api/models/disruption.py index 424fd37..cb67f33 100644 --- a/pydantic_tfl_api/models/disruption.py +++ b/pydantic_tfl_api/models/disruption.py @@ -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') diff --git a/tests/config_for_tests.py b/tests/config_for_tests.py index 682c866..9da0f0d 100644 --- a/tests/config_for_tests.py +++ b/tests/config_for_tests.py @@ -157,35 +157,35 @@ "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": {