@@ -383,6 +383,90 @@ def test_load_resource_spec_without_array_type_valid():
383383 assert result == schema
384384
385385
386+ def test_load_resource_spec_with_relationship_valid ():
387+ schema = {
388+ "typeName" : "AWS::FOO::BAR" ,
389+ "description" : "test schema" ,
390+ "additionalProperties" : False ,
391+ "properties" : {
392+ "foo" : {
393+ "type" : "string" ,
394+ "relationshipRef" : {
395+ "typeName" : "ABC::DEF::GHI" ,
396+ "propertyPath" : "/properties/id" ,
397+ },
398+ },
399+ "bar" : {"type" : "string" },
400+ },
401+ "definitions" : {
402+ "XYZ" : {
403+ "type" : "object" ,
404+ "additionalProperties" : False ,
405+ "properties" : {"Value" : {"type" : "string" }, "Key" : {"type" : "string" }},
406+ }
407+ },
408+ "primaryIdentifier" : ["/properties/foo" ],
409+ "readOnlyProperties" : ["/properties/foo" ],
410+ "createOnlyProperties" : ["/properties/foo" ],
411+ "conditionalCreateOnlyProperties" : ["/properties/bar" ],
412+ }
413+ result = load_resource_spec (json_s (schema ))
414+ assert result == schema
415+
416+
417+ def test_load_resource_spec_with_relationship_invalid ():
418+ schema = {
419+ "typeName" : "AWS::FOO::BAR" ,
420+ "description" : "test schema" ,
421+ "additionalProperties" : False ,
422+ "properties" : {
423+ "foo" : {"type" : "object" , "relationshipRef" : {"typeName" : "ABC::DEF::GHI" }},
424+ "bar" : {"type" : "string" },
425+ },
426+ "definitions" : {
427+ "XYZ" : {
428+ "type" : "object" ,
429+ "additionalProperties" : False ,
430+ "properties" : {"Value" : {"type" : "string" }, "Key" : {"type" : "string" }},
431+ }
432+ },
433+ "primaryIdentifier" : ["/properties/foo" ],
434+ "readOnlyProperties" : ["/properties/foo" ],
435+ "createOnlyProperties" : ["/properties/foo" ],
436+ "conditionalCreateOnlyProperties" : ["/properties/bar" ],
437+ }
438+ with pytest .raises (SpecValidationError ) as excinfo :
439+ load_resource_spec (json_s (schema ))
440+
441+ assert "Failed validating" in str (excinfo .value )
442+
443+
444+ def test_load_resource_spec_with_relationship_invalid_pattern ():
445+ schema = {
446+ "typeName" : "AWS::FOO::BAR" ,
447+ "description" : "test schema" ,
448+ "additionalProperties" : False ,
449+ "properties" : {
450+ "foo" : {
451+ "type" : "string" ,
452+ "relationshipRef" : {
453+ "typeName" : "string" ,
454+ "propertyPath" : "string" ,
455+ },
456+ },
457+ "bar" : {"type" : "string" },
458+ },
459+ "primaryIdentifier" : ["/properties/foo" ],
460+ "readOnlyProperties" : ["/properties/foo" ],
461+ "createOnlyProperties" : ["/properties/foo" ],
462+ "conditionalCreateOnlyProperties" : ["/properties/bar" ],
463+ }
464+ with pytest .raises (SpecValidationError ) as excinfo :
465+ load_resource_spec (json_s (schema ))
466+
467+ assert "does not match '^[a-zA-Z0-9]{2,64}::[a-zA-Z0-9]{2,64}" in str (excinfo .value )
468+
469+
386470def test_load_hook_spec_properties_key_is_invalid ():
387471 schema = {
388472 "typeName" : "AWS::FOO::BAR" ,
0 commit comments