示例#1
0
def test_create():
    s = fake.session()
    dataset = fake.dataset()

    attrs = tuple(
        [
            tc.SubAttribute(
                name=str(i),
                is_nullable=True,
                type=tc.attribute.type.Array(tc.attribute.type.STRING),
            )
            for i in range(4)
        ]
    )

    attr = tc.attribute.create(
        s,
        dataset,
        name="attr",
        is_nullable=False,
        type=tc.attribute.type.Record(attributes=attrs),
    )

    assert attr.name == "attr"
    assert not attr.is_nullable
    assert isinstance(attr.type, tc.attribute.type.Record)
    assert attr.type.attributes == attrs
示例#2
0
def test_create():
    s = utils.session()
    dataset = utils.dataset()

    attrs = tuple([
        tc.SubAttribute(
            name=str(i),
            is_nullable=True,
            type=tc.attribute.type.Array(tc.attribute.type.STRING),
        ) for i in range(4)
    ])

    attrs_url = tc.URL(path=dataset.url.path + "/attributes")
    url = replace(attrs_url, path=attrs_url.path + "/attr")
    attr_json = utils.load_json("attribute.json")
    responses.add(responses.POST, str(attrs_url), json=attr_json)
    attr = tc.attribute.create(
        s,
        dataset,
        name="attr",
        is_nullable=False,
        type=tc.attribute.type.Record(attributes=attrs),
    )

    assert attr == tc.attribute._from_json(url, attr_json)
示例#3
0
def test_from_resource_id():
    s = fake.session()
    dataset = fake.dataset()

    attrs = tuple(
        [
            tc.SubAttribute(
                name=str(i),
                is_nullable=True,
                type=tc.attribute.type.Array(tc.attribute.type.STRING),
            )
            for i in range(4)
        ]
    )

    attr = tc.attribute.from_resource_id(s, dataset, "attr")

    assert attr.name == "attr"
    assert not attr.is_nullable
    assert isinstance(attr.type, tc.attribute.type.Record)
    assert attr.type.attributes == attrs
示例#4
0
import tamr_client as tc
from tamr_client.attributes.attribute_type import Array, DOUBLE, Record, STRING

DEFAULT: Array = Array(STRING)

GEOSPATIAL: Record = Record(
    attributes=(
        tc.SubAttribute(name="point", is_nullable=True, type=Array(DOUBLE)),
        tc.SubAttribute(name="multiPoint", is_nullable=True, type=Array(Array(DOUBLE))),
        tc.SubAttribute(name="lineString", is_nullable=True, type=Array(Array(DOUBLE))),
        tc.SubAttribute(
            name="multiLineString", is_nullable=True, type=Array(Array(Array(DOUBLE)))
        ),
        tc.SubAttribute(
            name="polygon", is_nullable=True, type=Array(Array(Array(DOUBLE)))
        ),
        tc.SubAttribute(
            name="multiPolygon",
            is_nullable=True,
            type=Array(Array(Array(Array(DOUBLE)))),
        ),
    )
)