Exemplo n.º 1
0
def test_from_resource_id_not_found():
    s = utils.session()
    instance = utils.instance()

    url = tc.URL(path="projects/1")
    responses.add(responses.GET, str(url), status=404)

    with pytest.raises(tc.project.NotFound):
        tc.project.from_resource_id(s, instance, "1")
Exemplo n.º 2
0
def test_from_project_dataset_not_found():
    s = utils.session()
    instance = utils.instance()
    project = utils.mastering_project()

    url = tc.URL(path="projects/1/unifiedDataset")
    responses.add(responses.GET, str(url), status=404)

    with pytest.raises(tc.dataset.unified.NotFound):
        tc.dataset.unified.from_project(s, instance, project)
Exemplo n.º 3
0
def test_from_resource_id_mastering():
    s = utils.session()
    instance = utils.instance()

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

    project = tc.project.from_resource_id(s, instance, "1")
    assert isinstance(project, tc.MasteringProject)
    assert project.name == "proj"
    assert project.description == "Mastering Project"
Exemplo n.º 4
0
def test_from_resource_id():
    s = utils.session()
    instance = utils.instance()

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

    dataset = tc.dataset.from_resource_id(s, instance, "1")
    assert dataset.name == "dataset 1 name"
    assert dataset.description == "dataset 1 description"
    assert dataset.key_attribute_names == ("tamr_id", )
Exemplo n.º 5
0
def test_from_project():
    s = utils.session()
    instance = utils.instance()
    project = utils.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", )
Exemplo n.º 6
0
def test_operation_from_response():
    s = utils.session()
    instance = utils.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)
Exemplo n.º 7
0
def test_operation_from_response_noop():
    s = utils.session()
    instance = utils.instance()
    url = tc.URL(path="operations/2")
    responses.add(responses.GET, str(url), status=204)

    url_dummy = tc.URL(path="operations/-1")
    responses.add(responses.GET, str(url_dummy), status=404)

    r = s.get(str(url))
    op2 = tc.operation._from_response(instance, r)

    assert op2.url is not None
    assert op2.type == "NOOP"
    assert op2.description is not None
    assert op2.status is not None
    assert op2.status["state"] == "SUCCEEDED"
    assert tc.operation.succeeded(op2)

    op2w = tc.operation.wait(s, op2)
    assert tc.operation.succeeded(op2w)

    with pytest.raises(tc.operation.NotFound):
        tc.operation.poll(s, op2w)