-
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 #253 from Nelson-Andrade/delete-resource
Delete resource from collection
- Loading branch information
Showing
7 changed files
with
229 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import pytest | ||
import responses | ||
|
||
from tamr_unify_client import Client | ||
from tamr_unify_client.auth import UsernamePasswordAuth | ||
|
||
|
||
@pytest.fixture | ||
def client(): | ||
auth = UsernamePasswordAuth("username", "password") | ||
tamr = Client(auth) | ||
return tamr | ||
|
||
|
||
@responses.activate | ||
def test_delete_by_resource_id(client): | ||
ds_url = url_prefix + "datasets/7" | ||
attr_url = ds_url + "/attributes/family_role" | ||
|
||
responses.add(responses.GET, ds_url, json=datasets_collection[0]) | ||
responses.add(responses.DELETE, attr_url, status=204) | ||
|
||
attributes = client.datasets.by_resource_id("7").attributes | ||
response = attributes.delete_by_resource_id("family_role") | ||
assert response.status_code == 204 | ||
|
||
|
||
url_prefix = "http://localhost:9100/api/versioned/v1/" | ||
|
||
datasets_collection = [ | ||
{ | ||
"id": "unify://unified-data/v1/datasets/115", | ||
"name": "Globex_Store_Customers", | ||
"description": "", | ||
"version": "659", | ||
"keyAttributeNames": ["custid"], | ||
"tags": [], | ||
"created": { | ||
"username": "admin", | ||
"time": "2019-08-02T20:11:51.643Z", | ||
"version": "23388", | ||
}, | ||
"lastModified": { | ||
"username": "admin", | ||
"time": "2019-08-08T18:18:14.047Z", | ||
"version": "26090", | ||
}, | ||
"relativeId": "datasets/115", | ||
"upstreamDatasetIds": [], | ||
"externalId": "05d15bfd-d709-472a-ad5a-048e3367cfab", | ||
} | ||
] |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import pytest | ||
import responses | ||
|
||
from tamr_unify_client import Client | ||
from tamr_unify_client.auth import UsernamePasswordAuth | ||
|
||
|
||
@pytest.fixture | ||
def client(): | ||
auth = UsernamePasswordAuth("username", "password") | ||
tamr = Client(auth) | ||
return tamr | ||
|
||
|
||
@responses.activate | ||
def test_delete_by_resource_id(client): | ||
ds_url = url_prefix + "datasets/115" | ||
|
||
responses.add(responses.DELETE, ds_url, status=204) | ||
|
||
response = client.datasets.delete_by_resource_id("115") | ||
assert response.status_code == 204 | ||
|
||
|
||
url_prefix = "http://localhost:9100/api/versioned/v1/" |
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,59 @@ | ||
import pytest | ||
import responses | ||
|
||
from tamr_unify_client import Client | ||
from tamr_unify_client.auth import UsernamePasswordAuth | ||
|
||
|
||
@pytest.fixture | ||
def client(): | ||
auth = UsernamePasswordAuth("username", "password") | ||
tamr = Client(auth) | ||
return tamr | ||
|
||
|
||
@responses.activate | ||
def test_delete_by_resource_id(client): | ||
taxonomy_url = categorization_project + "/taxonomy" | ||
category_url = taxonomy_url + "/categories/3" | ||
|
||
responses.add( | ||
responses.GET, categorization_project, json=categorization_project_config | ||
) | ||
|
||
responses.add(responses.GET, taxonomy_url, json=taxonomy) | ||
responses.add(responses.DELETE, category_url, status=204) | ||
|
||
category_collection = client.projects.by_resource_id("2").as_categorization() | ||
response = category_collection.taxonomy().categories().delete_by_resource_id("3") | ||
assert response.status_code == 204 | ||
|
||
|
||
url_prefix = "http://localhost:9100/api/versioned/v1/" | ||
categorization_project = url_prefix + "projects/2" | ||
|
||
categorization_project_config = { | ||
"id": "unify://unified-data/v1/projects/2", | ||
"name": "cat", | ||
"description": "Categorization Project", | ||
"type": "CATEGORIZATION", | ||
"unifiedDatasetName": "", | ||
"relativeId": "projects/2", | ||
"externalId": "904bf89e-74ba-45c5-8b4a-5ff913728f66", | ||
} | ||
|
||
taxonomy = { | ||
"id": "unify://unified-data/v1/projects/2/taxonomy", | ||
"name": "tax", | ||
"created": { | ||
"username": "admin", | ||
"time": "2019-07-12T13:09:14.981Z", | ||
"version": "405", | ||
}, | ||
"lastModified": { | ||
"username": "admin", | ||
"time": "2019-07-12T13:09:14.981Z", | ||
"version": "405", | ||
}, | ||
"relativeId": "projects/2/taxonomy", | ||
} |
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,64 @@ | ||
import pytest | ||
import responses | ||
|
||
from tamr_unify_client import Client | ||
from tamr_unify_client.auth import UsernamePasswordAuth | ||
|
||
|
||
@pytest.fixture | ||
def client(): | ||
auth = UsernamePasswordAuth("username", "password") | ||
tamr = Client(auth) | ||
return tamr | ||
|
||
|
||
@responses.activate | ||
def test_delete_by_resource_id(client): | ||
input_collection = url_prefix + "projects/1/inputDatasets" | ||
input_ds = input_collection + "/6" | ||
|
||
responses.add(responses.GET, mastering_project, json=mastering_project_config) | ||
|
||
responses.add(responses.GET, input_collection, json=input_ds_json) | ||
responses.add(responses.DELETE, input_ds, status=204) | ||
|
||
input_ds_collection = client.projects.by_resource_id("1").input_datasets() | ||
response = input_ds_collection.delete_by_resource_id("6") | ||
assert response.status_code == 204 | ||
|
||
|
||
url_prefix = "http://localhost:9100/api/versioned/v1/" | ||
mastering_project = url_prefix + "projects/1" | ||
|
||
mastering_project_config = { | ||
"name": "Project 1", | ||
"description": "Mastering Project", | ||
"type": "DEDUP", | ||
"unifiedDatasetName": "Project 1 - Unified Dataset", | ||
"externalId": "Project1", | ||
"resourceId": "1", | ||
} | ||
|
||
input_ds_json = [ | ||
{ | ||
"id": "unify://unified-data/v1/datasets/6", | ||
"name": "febrl_sample_2k.csv", | ||
"description": "charlotte SM dataset", | ||
"version": "5", | ||
"keyAttributeNames": ["rec_id"], | ||
"tags": [], | ||
"created": { | ||
"username": "admin", | ||
"time": "2019-06-05T16:16:31.964Z", | ||
"version": "35", | ||
}, | ||
"lastModified": { | ||
"username": "admin", | ||
"time": "2019-07-19T17:44:42.369Z", | ||
"version": "22919", | ||
}, | ||
"relativeId": "datasets/6", | ||
"upstreamDatasetIds": [], | ||
"externalId": "febrl_sample_2k.csv", | ||
} | ||
] |