-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #442 from skalish/mastering-ops
TC: Fix mastering functions and conform to synchronous operations
- Loading branch information
Showing
16 changed files
with
531 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,40 @@ | ||
import pytest | ||
import responses | ||
|
||
import tamr_client as tc | ||
from tests.tamr_client import fake, utils | ||
from tests.tamr_client import fake | ||
|
||
|
||
@responses.activate | ||
@fake.json | ||
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) | ||
unified_dataset = tc.dataset.unified.from_project(s, project) | ||
assert unified_dataset.name == "dataset 1 name" | ||
assert unified_dataset.description == "dataset 1 description" | ||
assert unified_dataset.key_attribute_names == ("tamr_id",) | ||
|
||
|
||
@responses.activate | ||
@fake.json | ||
def test_from_project_dataset_not_found(): | ||
s = fake.session() | ||
instance = fake.instance() | ||
project = fake.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) | ||
tc.dataset.unified.from_project(s, project) | ||
|
||
|
||
@responses.activate | ||
def test_apply_changes(): | ||
@fake.json | ||
def test_apply_changes_async(): | ||
s = fake.session() | ||
dataset_json = utils.load_json("dataset.json") | ||
dataset_url = tc.URL(path="projects/1/unifiedDataset") | ||
unified_dataset = tc.dataset.unified._from_json(dataset_url, dataset_json) | ||
|
||
operation_json = utils.load_json("operation_pending.json") | ||
operation_url = tc.URL(path="operations/1") | ||
url = tc.URL(path="projects/1/unifiedDataset:refresh") | ||
responses.add(responses.POST, str(url), json=operation_json) | ||
|
||
response = tc.dataset.unified._apply_changes_async(s, unified_dataset) | ||
assert response == tc.operation._from_json(operation_url, operation_json) | ||
unified_dataset = fake.unified_dataset() | ||
|
||
op = tc.dataset.unified._apply_changes_async(s, unified_dataset) | ||
assert op.type == "SPARK" | ||
assert op.description == "operation 1 description" | ||
assert op.status == { | ||
"state": "PENDING", | ||
"startTime": "", | ||
"endTime": "", | ||
"message": "Job has not yet been submitted to Spark", | ||
} |
33 changes: 33 additions & 0 deletions
33
tests/tamr_client/fake_json/dataset/test_unified/test_apply_changes_async.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
[ | ||
{ | ||
"request": { | ||
"method": "POST", | ||
"path": "projects/1/unifiedDataset:refresh" | ||
}, | ||
"response": { | ||
"status": 200, | ||
"json": { | ||
"id": "1", | ||
"type": "SPARK", | ||
"description": "operation 1 description", | ||
"status": { | ||
"state": "PENDING", | ||
"startTime": "", | ||
"endTime": "", | ||
"message": "Job has not yet been submitted to Spark" | ||
}, | ||
"created": { | ||
"username": "admin", | ||
"time": "2020-06-12T18:21:42.288Z", | ||
"version": "operation 1 created version" | ||
}, | ||
"lastModified": { | ||
"username": "admin", | ||
"time": "2020-06-12T18:21:42.288Z", | ||
"version": "operation 1 modified version" | ||
}, | ||
"relativeId": "operations/1" | ||
} | ||
} | ||
} | ||
] |
34 changes: 34 additions & 0 deletions
34
tests/tamr_client/fake_json/dataset/test_unified/test_from_project.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[ | ||
{ | ||
"request": { | ||
"method": "GET", | ||
"path": "projects/1/unifiedDataset" | ||
}, | ||
"response": { | ||
"status": 200, | ||
"json": { | ||
"id": "unify://unified-data/v1/datasets/1", | ||
"externalId": "number 1", | ||
"name": "dataset 1 name", | ||
"description": "dataset 1 description", | ||
"version": "dataset 1 version", | ||
"keyAttributeNames": [ | ||
"tamr_id" | ||
], | ||
"tags": [], | ||
"created": { | ||
"username": "admin", | ||
"time": "2018-09-10T16:06:20.636Z", | ||
"version": "dataset 1 created version" | ||
}, | ||
"lastModified": { | ||
"username": "admin", | ||
"time": "2018-09-10T16:06:20.851Z", | ||
"version": "dataset 1 modified version" | ||
}, | ||
"relativeId": "datasets/1", | ||
"upstreamDatasetIds": [] | ||
} | ||
} | ||
} | ||
] |
11 changes: 11 additions & 0 deletions
11
tests/tamr_client/fake_json/dataset/test_unified/test_from_project_dataset_not_found.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[ | ||
{ | ||
"request": { | ||
"method": "GET", | ||
"path": "projects/1/unifiedDataset" | ||
}, | ||
"response": { | ||
"status": 404 | ||
} | ||
} | ||
] |
Oops, something went wrong.