def test_gather_object_artifacts_description(schema, schemas, expected_description): """ GIVEN schema and schemas and expected description value WHEN gather_object_artifacts is called with the schema and schemas THEN the expected description value is returned. """ obj_artifacts = artifacts.gather(schema=schema, logical_name="", schemas=schemas) assert obj_artifacts.description == expected_description
def test_gather_object_artifacts_kwargs(schema, schemas, expected_kwargs): """ GIVEN schema and schemas and expected kwargs value WHEN gather_object_artifacts is called with the schema and schemas THEN the expected kwargs value is returned. """ obj_artifacts = artifacts.gather(schema=schema, logical_name="", schemas=schemas) assert obj_artifacts.relationship.kwargs == expected_kwargs
def test_gather_object_artifacts_nullable(schema, schemas, expected_nullable): """ GIVEN schema and schemas and expected nullable value WHEN gather_object_artifacts is called with the schema and schemas THEN the expected nullable value is returned. """ obj_artifacts = artifacts.gather(schema=schema, logical_name="", schemas=schemas) assert obj_artifacts.nullable == expected_nullable
def test_gather_object_artifacts_fk_column(schema, schemas, expected_fk_column): """ GIVEN schema and schemas and expected foreign key column WHEN gather_object_artifacts is called with the schema and schemas THEN the expected foreign key column is returned. """ obj_artifacts = artifacts.gather(schema=schema, logical_name="", schemas=schemas) assert obj_artifacts.fk_column == expected_fk_column
def test_gather_object_artifacts_secondary(schema, schemas, expected_secondary): """ GIVEN schema and schemas and expected secondary WHEN gather_object_artifacts is called with the schema and schemas THEN the expected secondary is returned. """ obj_artifacts = artifacts.gather(schema=schema, logical_name="", schemas=schemas) assert obj_artifacts.relationship.secondary == expected_secondary
def test_gather_object_artifacts_ref_logical_name(schema, schemas): """ GIVEN schema and schemas WHEN gather_object_artifacts is called with the schema and schemas THEN the referenced schema name is returned as the ref logical name. """ obj_artifacts = artifacts.gather(schema=schema, logical_name="", schemas=schemas) assert obj_artifacts.relationship.model_name == "RefSchema"
def test_gather_object_artifacts_spec(schema, schemas): """ GIVEN schema, schemas and expected schema WHEN gather_object_artifacts is called with the schema and schemas THEN the expected schema is returned. """ obj_artifacts = artifacts.gather(schema=schema, logical_name="", schemas=schemas) assert obj_artifacts.spec == {"type": "object"}
def test_gather_object_artifacts_uselist(schema, schemas, expected_uselist): """ GIVEN schema and schemas and expected uselist WHEN gather_object_artifacts is called with the schema and schemas THEN the expected uselist is returned. """ obj_artifacts = artifacts.gather(schema=schema, logical_name="", schemas=schemas) if expected_uselist is None: assert obj_artifacts.relationship.back_reference is None else: assert obj_artifacts.relationship.back_reference.uselist == expected_uselist
def test_gather_object_artifacts_backref(schema, schemas, expected_backref): """ GIVEN schema and schemas and expected backref WHEN gather_object_artifacts is called with the schema and schemas THEN the expected backref is returned. """ obj_artifacts = artifacts.gather(schema=schema, logical_name="", schemas=schemas) if expected_backref is None: assert obj_artifacts.relationship.back_reference is None else: returned_backref = obj_artifacts.relationship.back_reference.property_name assert returned_backref == expected_backref
def test_gather_object_artifacts_logical_name(): """ GIVEN logical name WHEN gather_object_artifacts is called with the logical name THEN the expected logical name is returned. """ schema = {"$ref": "#/components/schemas/RefSchema"} schemas = {"RefSchema": {"type": "object"}} obj_artifacts = artifacts.gather( schema=schema, logical_name="logical name 1", schemas=schemas ) assert obj_artifacts.logical_name == "logical name 1"