File tree 2 files changed +30
-0
lines changed
tests/functional/validator
2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -565,3 +565,24 @@ def eventbridge_schema_registry_cloudtrail_v2_s3():
565
565
"x-amazon-events-detail-type" : "AWS API Call via CloudTrail" ,
566
566
"x-amazon-events-source" : "aws.s3" ,
567
567
}
568
+
569
+
570
+ @pytest .fixture
571
+ def schema_datetime_format ():
572
+ return {
573
+ "$schema" : "http://json-schema.org/draft-07/schema" ,
574
+ "$id" : "http://example.com/example.json" ,
575
+ "type" : "object" ,
576
+ "title" : "Sample schema with string date-time format" ,
577
+ "description" : "The root schema comprises the entire JSON document." ,
578
+ "required" : ["message" ],
579
+ "properties" : {
580
+ "message" : {
581
+ "$id" : "#/properties/message" ,
582
+ "type" : "string" ,
583
+ "format" : "date-time" ,
584
+ "title" : "The message" ,
585
+ "examples" : ["hello world" ],
586
+ },
587
+ },
588
+ }
Original file line number Diff line number Diff line change @@ -151,3 +151,12 @@ def _func_echo_decoder(self, value):
151
151
envelope = "powertools_json(data).payload" ,
152
152
jmespath_options = jmespath_opts ,
153
153
)
154
+
155
+
156
+ def test_validate_date_time_format (schema_datetime_format ):
157
+ raw_event = {"message" : "2021-06-29T14:46:06.804Z" }
158
+ validate (event = raw_event , schema = schema_datetime_format )
159
+
160
+ invalid_datetime = {"message" : "2021-06-29T14" }
161
+ with pytest .raises (exceptions .SchemaValidationError , match = "data.message must be date-time" ):
162
+ validate (event = invalid_datetime , schema = schema_datetime_format )
You can’t perform that action at this time.
0 commit comments