コード例 #1
0
ファイル: test_unified.py プロジェクト: abafzal/tamr-client
def test_from_project():
    s = fake.session()
    instance = fake.instance()
    project = fake.mastering_project()

    dataset_json = utils.load_json("dataset.json")
    url = tc.URL(path="projects/1/unifiedDataset")
    responses.add(responses.GET, str(url), json=dataset_json)

    unified_dataset = tc.dataset.unified.from_project(s, instance, project)
    assert unified_dataset.name == "dataset 1 name"
    assert unified_dataset.description == "dataset 1 description"
    assert unified_dataset.key_attribute_names == ("tamr_id", )
コード例 #2
0
def test_operation_by_url():
    s = fake.session()
    url = tc.URL(path="operations/1")

    operation_json = utils.load_json("operation_succeeded.json")
    responses.add(responses.GET, str(url), json=operation_json)

    op = tc.operation._by_url(s, url)
    assert op.url == url
    assert op.type == operation_json["type"]
    assert op.description == operation_json["description"]
    assert op.status == operation_json["status"]
    assert tc.operation.succeeded(op)
コード例 #3
0
def test_by_resource_id():
    s = fake.session()
    instance = fake.instance()
    url = tc.URL(path="operations/1")

    operation_json = utils.load_json("operation_succeeded.json")
    responses.add(responses.GET, str(url), json=operation_json)

    resource_id = "1"
    op = tc.operation.by_resource_id(s, instance, resource_id)
    assert op.url == url
    assert op.type == operation_json["type"]
    assert op.description == operation_json["description"]
    assert op.status == operation_json["status"]
    assert tc.operation.succeeded(op)
コード例 #4
0
def test_operation_from_response():
    s = fake.session()
    instance = fake.instance()
    url = tc.URL(path="operations/1")

    operation_json = utils.load_json("operation_succeeded.json")
    responses.add(responses.GET, str(url), json=operation_json)

    r = s.get(str(url))
    op = tc.operation._from_response(instance, r)
    assert op.url == url
    assert op.type == operation_json["type"]
    assert op.description == operation_json["description"]
    assert op.status == operation_json["status"]
    assert tc.operation.succeeded(op)
コード例 #5
0
def test_from_dataset_all():
    s = utils.session()
    dataset = utils.dataset()

    attrs_url = replace(dataset.url, path=dataset.url.path + "/attributes")
    attrs_json = utils.load_json("attributes.json")
    responses.add(responses.GET, str(attrs_url), json=attrs_json, status=204)

    attrs = tc.attribute.from_dataset_all(s, dataset)

    row_num = attrs[0]
    assert row_num.name == "RowNum"
    assert row_num.type == tc.attribute.type.STRING

    geom = attrs[1]
    assert geom.name == "geom"
    assert isinstance(geom.type, tc.attribute.type.Record)
コード例 #6
0
def test_from_json():
    geom_json = utils.load_json("attributes.json")[1]
    geom_type = tc.attribute.type.from_json(geom_json["type"])
    assert isinstance(geom_type, tc.attribute.type.Record)

    for i, subattr in enumerate(geom_type.attributes):
        assert isinstance(subattr, tc.SubAttribute)
        if i == 0:
            assert subattr.name == "point"
            assert subattr.type == tc.attribute.type.Array(
                tc.attribute.type.DOUBLE)
            assert subattr.is_nullable
        elif i == 1:
            assert subattr.name == "lineString"
            assert subattr.type == tc.attribute.type.Array(
                tc.attribute.type.Array(tc.attribute.type.DOUBLE))
            assert subattr.is_nullable
        elif i == 2:
            assert subattr.name == "polygon"
            assert subattr.type == tc.attribute.type.Array(
                tc.attribute.type.Array(
                    tc.attribute.type.Array(tc.attribute.type.DOUBLE)))
            assert subattr.is_nullable