Exemplo n.º 1
0
def test_gather_object_artifacts_uselist_no_backref():
    """
    GIVEN specification with uselist but not backref and schemas
    WHEN gather_object_artifacts is called with the specification and schemas
    THEN MalformedRelationshipError is raised.
    """
    spec = {"$ref": "#/components/schemas/RefSchema"}
    schemas = {"RefSchema": {"type": "object", "x-uselist": False}}

    with pytest.raises(exceptions.MalformedRelationshipError):
        object_ref.gather_object_artifacts(spec=spec, logical_name="", schemas=schemas)
Exemplo n.º 2
0
def test_gather_object_artifacts_fk_column(spec, schemas, expected_fk_column):
    """
    GIVEN specification and schemas and expected foreign key column
    WHEN gather_object_artifacts is called with the specification and schemas
    THEN the expected foreign key column is returned.
    """
    obj_artifacts = object_ref.gather_object_artifacts(
        spec=spec, logical_name="", schemas=schemas
    )

    assert obj_artifacts.fk_column == expected_fk_column
Exemplo n.º 3
0
def test_gather_object_artifacts_secondary(spec, schemas, expected_secondary):
    """
    GIVEN specification and schemas and expected secondary
    WHEN gather_object_artifacts is called with the specification and schemas
    THEN the expected secondary is returned.
    """
    obj_artifacts = object_ref.gather_object_artifacts(
        spec=spec, logical_name="", schemas=schemas
    )

    assert obj_artifacts.secondary == expected_secondary
Exemplo n.º 4
0
def test_gather_object_artifacts_uselist(spec, schemas, expected_uselist):
    """
    GIVEN specification and schemas and expected uselist
    WHEN gather_object_artifacts is called with the specification and schemas
    THEN the expected uselist is returned.
    """
    obj_artifacts = object_ref.gather_object_artifacts(
        spec=spec, logical_name="", schemas=schemas
    )

    assert obj_artifacts.uselist == expected_uselist
Exemplo n.º 5
0
def test_gather_object_artifacts_backref(spec, schemas, expected_backref):
    """
    GIVEN specification and schemas and expected backref
    WHEN gather_object_artifacts is called with the specification and schemas
    THEN the expected backref is returned.
    """
    obj_artifacts = object_ref.gather_object_artifacts(
        spec=spec, logical_name="", schemas=schemas
    )

    assert obj_artifacts.backref == expected_backref
Exemplo n.º 6
0
def test_gather_object_artifacts_ref_logical_name(spec, schemas):
    """
    GIVEN specification and schemas
    WHEN gather_object_artifacts is called with the specification and schemas
    THEN the referenced schema name is returned as the ref logical name.
    """
    obj_artifacts = object_ref.gather_object_artifacts(
        spec=spec, logical_name="", schemas=schemas
    )

    assert obj_artifacts.ref_logical_name == "RefSchema"