adapting shipcall, times and user to include ValidationError (marshmallow). Adjusting the Schemas for User, Times and Shipcall to be validated with additional input validators. Creating a set of tests for the input validations.

This commit is contained in:
scopesorting 2023-12-07 12:01:41 +01:00 committed by Max Metz
parent 6aaaa32445
commit 16c8bebfe0
2 changed files with 9 additions and 2 deletions

8
brecal.code-workspace Normal file
View File

@ -0,0 +1,8 @@
{
"folders": [
{
"path": "."
}
],
"settings": {}
}

View File

@ -359,7 +359,7 @@ class TimesSchema(Schema):
berth_info = fields.String(metadata={'required':False}, allow_none=True, validate=[validate.Length(max=256)])
pier_side = fields.Bool(metadata={'required':False}, allow_none = True)
shipcall_id = fields.Integer(metadata={'required':True})
participant_type = fields.Enum(ParticipantType, metadata={'required':False}, allow_none=True, default=ParticipantType.undefined) #fields.Integer(metadata={'required':False}, allow_none=True)
participant_type = fields.Integer(Required = False, allow_none=True)# TODO: could become Enum. fields.Enum(ParticipantType, metadata={'required':False}, allow_none=True, default=ParticipantType.undefined) #fields.Integer(metadata={'required':False}, allow_none=True)
ata = fields.DateTime(metadata={'required':False}, allow_none=True)
atd = fields.DateTime(metadata={'required':False}, allow_none=True)
eta_interval_end = fields.DateTime(metadata={'required':False}, allow_none=True)
@ -370,7 +370,6 @@ class TimesSchema(Schema):
@validates("eta_berth")
def validate_eta_berth(self, value):
threshold_exceeded = validate_time_exceeds_threshold(value, months=12)
print(threshold_exceeded, value)
if threshold_exceeded:
raise ValidationError(f"the provided time exceeds the twelve month threshold.")