@@ -86,10 +86,6 @@ class TestSpec(BaseTest):
86
86
spec_cache : ConnectorSpecification = None
87
87
previous_spec_cache : ConnectorSpecification = None
88
88
89
- @pytest .fixture (name = "connection_specification" , scope = "class" )
90
- def connection_specification_fixture (self , connector_spec_dict : dict ) -> dict :
91
- return connector_spec_dict ["connectionSpecification" ]
92
-
93
89
@pytest .fixture (name = "skip_backward_compatibility_tests" )
94
90
def skip_backward_compatibility_tests_fixture (
95
91
self ,
@@ -285,12 +281,12 @@ def _fail_on_errors(self, errors: List[str]):
285
281
if len (errors ) > 0 :
286
282
pytest .fail ("\n " .join (errors ))
287
283
288
- def test_property_type_is_not_array (self , connector_specification : dict ):
284
+ def test_property_type_is_not_array (self , connector_spec : ConnectorSpecification ):
289
285
"""
290
286
Each field has one or multiple types, but the UI only supports a single type and optionally "null" as a second type.
291
287
"""
292
288
errors = []
293
- for type_path , type_value in dpath .util .search (connector_specification , "**/properties/*/type" , yielded = True ):
289
+ for type_path , type_value in dpath .util .search (connector_spec . connectionSpecification , "**/properties/*/type" , yielded = True ):
294
290
if isinstance (type_value , List ):
295
291
number_of_types = len (type_value )
296
292
if number_of_types != 2 and number_of_types != 1 :
@@ -303,14 +299,14 @@ def test_property_type_is_not_array(self, connector_specification: dict):
303
299
)
304
300
self ._fail_on_errors (errors )
305
301
306
- def test_object_not_empty (self , connector_specification : dict ):
302
+ def test_object_not_empty (self , connector_spec : ConnectorSpecification ):
307
303
"""
308
304
Each object field needs to have at least one property as the UI won't be able to show them otherwise.
309
305
If the whole spec is empty, it's allowed to have a single empty object at the top level
310
306
"""
311
- schema_helper = JsonSchemaHelper (connector_specification )
307
+ schema_helper = JsonSchemaHelper (connector_spec . connectionSpecification )
312
308
errors = []
313
- for type_path , type_value in dpath .util .search (connector_specification , "**/type" , yielded = True ):
309
+ for type_path , type_value in dpath .util .search (connector_spec . connectionSpecification , "**/type" , yielded = True ):
314
310
if type_path == "type" :
315
311
# allow empty root object
316
312
continue
@@ -322,13 +318,13 @@ def test_object_not_empty(self, connector_specification: dict):
322
318
)
323
319
self ._fail_on_errors (errors )
324
320
325
- def test_array_type (self , connector_specification : dict ):
321
+ def test_array_type (self , connector_spec : ConnectorSpecification ):
326
322
"""
327
323
Each array has one or multiple types for its items, but the UI only supports a single type which can either be object, string or an enum
328
324
"""
329
- schema_helper = JsonSchemaHelper (connector_specification )
325
+ schema_helper = JsonSchemaHelper (connector_spec . connectionSpecification )
330
326
errors = []
331
- for type_path , type_type in dpath .util .search (connector_specification , "**/type" , yielded = True ):
327
+ for type_path , type_type in dpath .util .search (connector_spec . connectionSpecification , "**/type" , yielded = True ):
332
328
property_definition = schema_helper .get_parent (type_path )
333
329
if type_type != "array" :
334
330
# unrelated "items", not an array definition
@@ -342,7 +338,7 @@ def test_array_type(self, connector_specification: dict):
342
338
errors .append (f"Items of { type_path } has to be either object or string or define an enum" )
343
339
self ._fail_on_errors (errors )
344
340
345
- def test_forbidden_complex_types (self , connector_specification : dict ):
341
+ def test_forbidden_complex_types (self , connector_spec : ConnectorSpecification ):
346
342
"""
347
343
not, anyOf, patternProperties, prefixItems, allOf, if, then, else, dependentSchemas and dependentRequired are not allowed
348
344
"""
@@ -360,25 +356,25 @@ def test_forbidden_complex_types(self, connector_specification: dict):
360
356
]
361
357
found_keys = set ()
362
358
for forbidden_key in forbidden_keys :
363
- for path , value in dpath .util .search (connector_specification , f"**/{ forbidden_key } " , yielded = True ):
359
+ for path , value in dpath .util .search (connector_spec . connectionSpecification , f"**/{ forbidden_key } " , yielded = True ):
364
360
found_keys .add (path )
365
361
366
362
for forbidden_key in forbidden_keys :
367
363
# remove forbidden keys if they are used as properties directly
368
- for path , _value in dpath .util .search (connector_specification , f"**/properties/{ forbidden_key } " , yielded = True ):
364
+ for path , _value in dpath .util .search (connector_spec . connectionSpecification , f"**/properties/{ forbidden_key } " , yielded = True ):
369
365
found_keys .remove (path )
370
366
371
367
if len (found_keys ) > 0 :
372
368
key_list = ", " .join (found_keys )
373
369
pytest .fail (f"Found the following disallowed JSON schema features: { key_list } " )
374
370
375
- def test_date_pattern (self , connector_specification : dict , detailed_logger ):
371
+ def test_date_pattern (self , connector_spec : ConnectorSpecification , detailed_logger ):
376
372
"""
377
373
Properties with format date or date-time should always have a pattern defined how the date/date-time should be formatted
378
374
that corresponds with the format the datepicker component is creating.
379
375
"""
380
- schema_helper = JsonSchemaHelper (connector_specification )
381
- for format_path , format in dpath .util .search (connector_specification , "**/format" , yielded = True ):
376
+ schema_helper = JsonSchemaHelper (connector_spec . connectionSpecification )
377
+ for format_path , format in dpath .util .search (connector_spec . connectionSpecification , "**/format" , yielded = True ):
382
378
if not isinstance (format , str ):
383
379
# format is not a format definition here but a property named format
384
380
continue
@@ -393,12 +389,12 @@ def test_date_pattern(self, connector_specification: dict, detailed_logger):
393
389
f"{ format_path } is defining a date-time format without the corresponding pattern Consider setting the pattern to { DATETIME_PATTERN } to make it easier for users to edit this field in the UI."
394
390
)
395
391
396
- def test_date_format (self , connector_specification : dict , detailed_logger ):
392
+ def test_date_format (self , connector_spec : ConnectorSpecification , detailed_logger ):
397
393
"""
398
394
Properties with a pattern that looks like a date should have their format set to date or date-time.
399
395
"""
400
- schema_helper = JsonSchemaHelper (connector_specification )
401
- for pattern_path , pattern in dpath .util .search (connector_specification , "**/pattern" , yielded = True ):
396
+ schema_helper = JsonSchemaHelper (connector_spec . connectionSpecification )
397
+ for pattern_path , pattern in dpath .util .search (connector_spec . connectionSpecification , "**/pattern" , yielded = True ):
402
398
if not isinstance (pattern , str ):
403
399
# pattern is not a pattern definition here but a property named pattern
404
400
continue
0 commit comments