def test_patch_dicom_store(test_dataset, capsys): dicom_stores.create_dicom_store( service_account_json, project_id, cloud_region, dataset_id, dicom_store_id) dicom_stores.patch_dicom_store( service_account_json, project_id, cloud_region, dataset_id, dicom_store_id, pubsub_topic) # Clean up dicom_stores.delete_dicom_store( service_account_json, project_id, cloud_region, dataset_id, dicom_store_id) out, _ = capsys.readouterr() assert 'Patched DICOM store' in out
def test_get_set_dicom_store_iam_policy(test_dataset, capsys): dicom_stores.create_dicom_store(service_account_json, project_id, cloud_region, dataset_id, dicom_store_id) get_response = dicom_stores.get_dicom_store_iam_policy( service_account_json, project_id, cloud_region, dataset_id, dicom_store_id) set_response = dicom_stores.set_dicom_store_iam_policy( service_account_json, project_id, cloud_region, dataset_id, dicom_store_id, 'serviceAccount:[email protected]', 'roles/viewer') # Clean up dicom_stores.delete_dicom_store(service_account_json, project_id, cloud_region, dataset_id, dicom_store_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_export_dicom_instance(test_dataset, capsys): dicom_stores.create_dicom_store( service_account_json, project_id, cloud_region, dataset_id, dicom_store_id) dicom_stores.export_dicom_instance( service_account_json, project_id, cloud_region, dataset_id, dicom_store_id, bucket) # Clean up dicom_stores.delete_dicom_store( service_account_json, project_id, cloud_region, dataset_id, dicom_store_id) out, _ = capsys.readouterr() assert 'Exported DICOM instance' in out
def test_CRUD_dicom_store(test_dataset, capsys): dicom_stores.create_dicom_store( service_account_json, project_id, cloud_region, dataset_id, dicom_store_id) dicom_stores.get_dicom_store( service_account_json, project_id, cloud_region, dataset_id, dicom_store_id) dicom_stores.list_dicom_stores( service_account_json, project_id, cloud_region, dataset_id) dicom_stores.delete_dicom_store( service_account_json, project_id, cloud_region, dataset_id, dicom_store_id) out, _ = capsys.readouterr() # Check that create/get/list/delete worked assert 'Created DICOM store' in out assert 'Name' in out assert 'dicomStores' in out assert 'Deleted DICOM store' in out
def test_export_dicom_instance(test_dataset, capsys): dicom_stores.create_dicom_store( service_account_json, api_key, project_id, cloud_region, dataset_id, dicom_store_id) dicom_stores.export_dicom_instance( service_account_json, api_key, project_id, cloud_region, dataset_id, dicom_store_id, bucket) # Clean up dicom_stores.delete_dicom_store( service_account_json, api_key, project_id, cloud_region, dataset_id, dicom_store_id) out, _ = capsys.readouterr() assert 'Exported DICOM instance' in out
def test_patch_dicom_store(test_dataset, capsys): dicom_stores.create_dicom_store( service_account_json, api_key, project_id, cloud_region, dataset_id, dicom_store_id) dicom_stores.patch_dicom_store( service_account_json, api_key, project_id, cloud_region, dataset_id, dicom_store_id, pubsub_topic) # Clean up dicom_stores.delete_dicom_store( service_account_json, api_key, project_id, cloud_region, dataset_id, dicom_store_id) out, _ = capsys.readouterr() assert 'Patched DICOM store' in out
def test_import_dicom_instance(test_dataset, capsys): dicom_stores.create_dicom_store( service_account_json, project_id, cloud_region, dataset_id, dicom_store_id) dicom_stores.import_dicom_instance( service_account_json, project_id, cloud_region, dataset_id, dicom_store_id, content_uri) # Clean up dicom_stores.delete_dicom_store( service_account_json, project_id, cloud_region, dataset_id, dicom_store_id) out, _ = capsys.readouterr() assert 'Imported DICOM instance' in out
def test_dicom_store(): dicom_store = dicom_stores.create_dicom_store(service_account_json, project_id, cloud_region, dataset_id, dicom_store_id) yield dicom_store # Clean up dicom_stores.delete_dicom_store(service_account_json, project_id, cloud_region, dataset_id, dicom_store_id)
def clean_up(): try: dicom_stores.delete_dicom_store(project_id, location, dataset_id, dicom_store_id) except HttpError as err: # The API returns 404 when the DICOM store doesn't exist. # The API returns 403 when the dataset doesn't exist, so # if we try to delete a DICOM store when the parent dataset # doesn't exist, the server will return a 403. if err.resp.status == 404 or err.resp.status == 403: print("Got exception {} while deleting DICOM store".format( err.resp.status)) else: raise
def test_import_dicom_instance(test_dataset, capsys): dicom_stores.create_dicom_store(service_account_json, api_key, project_id, cloud_region, dataset_id, dicom_store_id) dicom_stores.import_dicom_instance(service_account_json, api_key, project_id, cloud_region, dataset_id, dicom_store_id, content_uri) # Clean up dicom_stores.delete_dicom_store(service_account_json, api_key, project_id, cloud_region, dataset_id, dicom_store_id) out, _ = capsys.readouterr() assert 'Imported DICOM instance' in out
def test_dicom_store(): dicom_store = dicom_stores.create_dicom_store( service_account_json, project_id, cloud_region, dataset_id, dicom_store_id) yield dicom_store # Clean up dicom_stores.delete_dicom_store( service_account_json, project_id, cloud_region, dataset_id, dicom_store_id)
def test_CRUD_dicom_store(test_dataset, crud_dicom_store_id, capsys): dicom_stores.create_dicom_store(project_id, cloud_region, dataset_id, crud_dicom_store_id) dicom_stores.get_dicom_store(project_id, cloud_region, dataset_id, crud_dicom_store_id) dicom_stores.list_dicom_stores(project_id, cloud_region, dataset_id) dicom_stores.delete_dicom_store(project_id, cloud_region, dataset_id, crud_dicom_store_id) out, _ = capsys.readouterr() # Check that create/get/list/delete worked assert "Created DICOM store" in out assert "name" in out assert "dicomStores" in out assert "Deleted DICOM store" in out
def test_get_set_dicom_store_iam_policy(test_dataset, capsys): dicom_stores.create_dicom_store( service_account_json, project_id, cloud_region, dataset_id, dicom_store_id) get_response = dicom_stores.get_dicom_store_iam_policy( service_account_json, project_id, cloud_region, dataset_id, dicom_store_id) set_response = dicom_stores.set_dicom_store_iam_policy( service_account_json, project_id, cloud_region, dataset_id, dicom_store_id, 'serviceAccount:[email protected]', 'roles/viewer') # Clean up dicom_stores.delete_dicom_store( service_account_json, project_id, cloud_region, dataset_id, dicom_store_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_dicom_store(test_dataset, crud_dicom_store_id, capsys): @backoff.on_exception(backoff.expo, HttpError, max_time=60) def create(): dicom_stores.create_dicom_store(project_id, location, dataset_id, crud_dicom_store_id) create() dicom_stores.get_dicom_store(project_id, location, dataset_id, crud_dicom_store_id) dicom_stores.list_dicom_stores(project_id, location, dataset_id) dicom_stores.delete_dicom_store(project_id, location, dataset_id, crud_dicom_store_id) out, _ = capsys.readouterr() # Check that create/get/list/delete worked assert "Created DICOM store" in out assert "name" in out assert "dicomStores" in out assert "Deleted DICOM store" in out