コード例 #1
0
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
コード例 #2
0
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
コード例 #3
0
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
コード例 #4
0
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
コード例 #5
0
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
コード例 #6
0
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"
コード例 #7
0
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"}
コード例 #8
0
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
コード例 #9
0
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
コード例 #10
0
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"