def test_deidentify_dataset(capsys): datasets.create_dataset( service_account_json, project_id, cloud_region, dataset_id) datasets.deidentify_dataset( service_account_json, project_id, cloud_region, dataset_id, destination_dataset_id, whitelist_tags) # Clean up datasets.delete_dataset( service_account_json, project_id, cloud_region, dataset_id) datasets.delete_dataset( service_account_json, project_id, cloud_region, destination_dataset_id) out, _ = capsys.readouterr() # Check that de-identify worked assert 'De-identified data written to' in out
def test_CRUD_dataset(capsys, crud_dataset_id): datasets.create_dataset(project_id, cloud_region, crud_dataset_id) @retry( wait_exponential_multiplier=1000, wait_exponential_max=10000, stop_max_attempt_number=10, retry_on_exception=retry_if_server_exception, ) def get_dataset(): datasets.get_dataset(project_id, cloud_region, crud_dataset_id) get_dataset() datasets.list_datasets(project_id, cloud_region) datasets.delete_dataset(project_id, cloud_region, crud_dataset_id) out, _ = capsys.readouterr() # Check that create/get/list/delete worked assert "Created dataset" in out assert "Time zone" in out assert "Dataset" in out assert "Deleted dataset" in out
def test_get_set_dataset_iam_policy(capsys): datasets.create_dataset( service_account_json, project_id, cloud_region, dataset_id) get_response = datasets.get_dataset_iam_policy( service_account_json, project_id, cloud_region, dataset_id) set_response = datasets.set_dataset_iam_policy( service_account_json, project_id, cloud_region, dataset_id, 'serviceAccount:[email protected]', 'roles/viewer') # Clean up datasets.delete_dataset( service_account_json, project_id, cloud_region, dataset_id) out, _ = capsys.readouterr() assert 'etag' in get_response assert 'bindings' in set_response assert len(set_response['bindings']) == 1 assert 'python-docs-samples-tests' in str(set_response['bindings']) assert 'roles/viewer' in str(set_response['bindings'])
def test_CRUD_dataset(capsys): datasets.create_dataset( service_account_json, api_key, project_id, cloud_region, dataset_id) datasets.get_dataset( service_account_json, api_key, project_id, cloud_region, dataset_id) datasets.list_datasets( service_account_json, api_key, project_id, cloud_region) # Test and also clean up datasets.delete_dataset( service_account_json, api_key, project_id, cloud_region, dataset_id) out, _ = capsys.readouterr() # Check that create/get/list/delete worked assert 'Created dataset' in out assert 'Time zone' in out assert 'Dataset' in out assert 'Deleted dataset' in out
def test_dataset(): dataset = datasets.create_dataset(service_account_json, project_id, cloud_region, dataset_id) yield dataset # Clean up datasets.delete_dataset(service_account_json, project_id, cloud_region, dataset_id)
def clean_up(): try: datasets.delete_dataset(project_id, location, dataset_id) except HttpError as err: # The API returns 403 when the dataset doesn't exist. if err.resp.status == 404 or err.resp.status == 403: print("Got exception {} while deleting dataset".format(err.resp.status)) else: raise
def test_dataset(): dataset = datasets.create_dataset( service_account_json, project_id, cloud_region, dataset_id) yield dataset # Clean up datasets.delete_dataset( service_account_json, project_id, cloud_region, dataset_id)
def test_patch_dataset(capsys): datasets.create_dataset(service_account_json, api_key, project_id, cloud_region, dataset_id) datasets.patch_dataset(service_account_json, api_key, project_id, cloud_region, dataset_id, time_zone) # Clean up datasets.delete_dataset(service_account_json, api_key, project_id, cloud_region, dataset_id) out, _ = capsys.readouterr() # Check that the patch to the time zone worked assert 'UTC' in out
def test_CRUD_dataset(capsys, crud_dataset_id): datasets.create_dataset(project_id, cloud_region, crud_dataset_id) datasets.get_dataset(project_id, cloud_region, crud_dataset_id) datasets.list_datasets(project_id, cloud_region) datasets.delete_dataset(project_id, cloud_region, crud_dataset_id) out, _ = capsys.readouterr() # Check that create/get/list/delete worked assert 'Created dataset' in out assert 'Time zone' in out assert 'Dataset' in out assert 'Deleted dataset' in out
def test_CRUD_dataset(capsys): datasets.create_dataset(service_account_json, project_id, cloud_region, dataset_id) datasets.get_dataset(service_account_json, project_id, cloud_region, dataset_id) datasets.list_datasets(service_account_json, project_id, cloud_region) # Test and also clean up datasets.delete_dataset(service_account_json, project_id, cloud_region, dataset_id) out, _ = capsys.readouterr() # Check that create/get/list/delete worked assert 'Created dataset' in out assert 'Time zone' in out assert 'Dataset' in out assert 'Deleted dataset' in out
def test_patch_dataset(capsys): datasets.create_dataset( service_account_json, project_id, cloud_region, dataset_id) datasets.patch_dataset( service_account_json, project_id, cloud_region, dataset_id, time_zone) # Clean up datasets.delete_dataset( service_account_json, project_id, cloud_region, dataset_id) out, _ = capsys.readouterr() # Check that the patch to the time zone worked assert 'UTC' in out