def test_export_fhir_store_gcs(test_dataset, capsys): fhir_stores.create_fhir_store( service_account_json, project_id, cloud_region, dataset_id, fhir_store_id) fhir_stores.export_fhir_store_gcs( service_account_json, project_id, cloud_region, dataset_id, fhir_store_id, gcs_uri) # Clean up fhir_stores.delete_fhir_store( service_account_json, project_id, cloud_region, dataset_id, fhir_store_id) out, _ = capsys.readouterr() assert 'Exported FHIR resources to bucket' in out
def test_CRUD_fhir_store(test_dataset, capsys): fhir_stores.create_fhir_store( service_account_json, project_id, cloud_region, dataset_id, fhir_store_id) fhir_stores.get_fhir_store( service_account_json, project_id, cloud_region, dataset_id, fhir_store_id) fhir_stores.list_fhir_stores( service_account_json, project_id, cloud_region, dataset_id) fhir_stores.delete_fhir_store( service_account_json, project_id, cloud_region, dataset_id, fhir_store_id) out, _ = capsys.readouterr() # Check that create/get/list/delete worked assert 'Created FHIR store' in out assert 'Name' in out assert 'fhirStores' in out assert 'Deleted FHIR store' in out
def test_export_fhir_store_gcs(test_dataset, capsys): fhir_stores.create_fhir_store( service_account_json, api_key, project_id, cloud_region, dataset_id, fhir_store_id) fhir_stores.export_fhir_store_gcs( service_account_json, api_key, project_id, cloud_region, dataset_id, fhir_store_id, gcs_uri) # Clean up fhir_stores.delete_fhir_store( service_account_json, api_key, project_id, cloud_region, dataset_id, fhir_store_id) out, _ = capsys.readouterr() assert 'Exported FHIR resources to bucket' in out
def test_patch_fhir_store(test_dataset, capsys): fhir_stores.create_fhir_store( service_account_json, project_id, cloud_region, dataset_id, fhir_store_id) fhir_stores.patch_fhir_store( service_account_json, project_id, cloud_region, dataset_id, fhir_store_id) # Clean up fhir_stores.delete_fhir_store( service_account_json, project_id, cloud_region, dataset_id, fhir_store_id) out, _ = capsys.readouterr() assert 'Patched FHIR store' in out
def test_patch_fhir_store(test_dataset, capsys): fhir_stores.create_fhir_store( service_account_json, api_key, project_id, cloud_region, dataset_id, fhir_store_id) fhir_stores.patch_fhir_store( service_account_json, api_key, project_id, cloud_region, dataset_id, fhir_store_id, pubsub_topic) # Clean up fhir_stores.delete_fhir_store( service_account_json, api_key, project_id, cloud_region, dataset_id, fhir_store_id) out, _ = capsys.readouterr() assert 'Patched FHIR store' in out
def test_import_fhir_store_gcs(test_dataset, capsys): fhir_stores.create_fhir_store(service_account_json, project_id, cloud_region, dataset_id, fhir_store_id) storage_client = storage.Client() bucket = storage_client.get_bucket(gcs_uri) blob = bucket.blob(source_file_name) blob.upload_from_filename(resource_file) time.sleep(10) # Give new blob time to propagate fhir_stores.import_fhir_resources( service_account_json, project_id, cloud_region, dataset_id, fhir_store_id, import_object, ) # Clean up blob.delete() fhir_stores.delete_fhir_store(service_account_json, project_id, cloud_region, dataset_id, fhir_store_id) out, _ = capsys.readouterr() assert "Imported FHIR resources" in out
def test_get_set_fhir_store_iam_policy(test_dataset, capsys): fhir_stores.create_fhir_store(service_account_json, project_id, cloud_region, dataset_id, fhir_store_id) get_response = fhir_stores.get_fhir_store_iam_policy( service_account_json, project_id, cloud_region, dataset_id, fhir_store_id) set_response = fhir_stores.set_fhir_store_iam_policy( service_account_json, project_id, cloud_region, dataset_id, fhir_store_id, "serviceAccount:[email protected]", "roles/viewer", ) # Clean up fhir_stores.delete_fhir_store(service_account_json, project_id, cloud_region, dataset_id, fhir_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_get_set_fhir_store_iam_policy(test_dataset, capsys): fhir_stores.create_fhir_store(service_account_json, api_key, project_id, cloud_region, dataset_id, fhir_store_id) get_response = fhir_stores.get_fhir_store_iam_policy( service_account_json, api_key, project_id, cloud_region, dataset_id, fhir_store_id) set_response = fhir_stores.set_fhir_store_iam_policy( service_account_json, api_key, project_id, cloud_region, dataset_id, fhir_store_id, 'serviceAccount:[email protected]', 'roles/viewer') # Clean up fhir_stores.delete_fhir_store(service_account_json, api_key, project_id, cloud_region, dataset_id, fhir_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_import_fhir_store_gcs(test_dataset, capsys): fhir_stores.create_fhir_store(service_account_json, project_id, cloud_region, dataset_id, fhir_store_id) storage_client = storage.Client() bucket = storage_client.get_bucket(gcs_uri) blob = bucket.blob(source_file_name) blob.upload_from_filename(resource_file) time.sleep(10) # Give new blob time to propagate fhir_stores.import_fhir_resources( service_account_json, project_id, cloud_region, dataset_id, fhir_store_id, import_object, ) # Clean up try: blob.delete() # If blob not found, then it's already been deleted, so no need to clean up. except exceptions.NotFound: pass fhir_stores.delete_fhir_store(service_account_json, project_id, cloud_region, dataset_id, fhir_store_id) out, _ = capsys.readouterr() assert "Imported FHIR resources" in out
def test_create_delete_fhir_store(test_dataset, capsys): fhir_stores.create_fhir_store(service_account_json, project_id, cloud_region, dataset_id, fhir_store_id) fhir_stores.delete_fhir_store(service_account_json, project_id, cloud_region, dataset_id, fhir_store_id) out, _ = capsys.readouterr() # Check that create/get/list/delete worked assert "Created FHIR store" in out assert "Deleted FHIR store" in out
def create(): try: fhir_stores.create_fhir_store(project_id, cloud_region, dataset_id, fhir_store_id) except HttpError as err: # We ignore 409 conflict here, because we know it's most # likely the first request failed on the client side, but # the creation suceeded on the server side. if err.resp.status == 409: print("Got exception {} while creating FHIR store".format( err.resp.status)) else: raise
def test_crud_fhir_store(test_dataset, capsys): fhir_stores.create_fhir_store(project_id, cloud_region, dataset_id, fhir_store_id) fhir_stores.get_fhir_store(project_id, cloud_region, dataset_id, fhir_store_id) fhir_stores.list_fhir_stores(project_id, cloud_region, dataset_id) fhir_stores.delete_fhir_store(project_id, cloud_region, dataset_id, fhir_store_id) out, _ = capsys.readouterr() # Check that create/get/list/delete worked assert "Created FHIR store" in out assert "name" in out assert "fhirStores" in out assert "Deleted FHIR store" in out
def test_fhir_store(): fhir_store = fhir_stores.create_fhir_store(service_account_json, project_id, cloud_region, dataset_id, fhir_store_id) yield fhir_store fhir_stores.delete_fhir_store(service_account_json, project_id, cloud_region, dataset_id, fhir_store_id)
def test_CRUD_fhir_store(test_dataset, capsys): fhir_stores.create_fhir_store(service_account_json, project_id, cloud_region, dataset_id, fhir_store_id) fhir_stores.get_fhir_store(service_account_json, project_id, cloud_region, dataset_id, fhir_store_id) fhir_stores.list_fhir_stores(service_account_json, project_id, cloud_region, dataset_id) fhir_stores.delete_fhir_store(service_account_json, project_id, cloud_region, dataset_id, fhir_store_id) out, _ = capsys.readouterr() # Check that create/get/list/delete worked assert 'Created FHIR store' in out assert 'Name' in out assert 'fhirStores' in out assert 'Deleted FHIR store' in out
def test_get_set_fhir_store_iam_policy(test_dataset, capsys): fhir_stores.create_fhir_store( service_account_json, project_id, cloud_region, dataset_id, fhir_store_id) get_response = fhir_stores.get_fhir_store_iam_policy( service_account_json, project_id, cloud_region, dataset_id, fhir_store_id) set_response = fhir_stores.set_fhir_store_iam_policy( service_account_json, project_id, cloud_region, dataset_id, fhir_store_id, 'serviceAccount:[email protected]', 'roles/viewer') # Clean up fhir_stores.delete_fhir_store( service_account_json, project_id, cloud_region, dataset_id, fhir_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_import_fhir_store_gcs(test_dataset, capsys): fhir_stores.create_fhir_store( service_account_json, api_key, project_id, cloud_region, dataset_id, fhir_store_id) storage_client = storage.Client() bucket = storage_client.get_bucket(gcs_uri) blob = bucket.blob(source_file_name) blob.upload_from_filename(resource_file) fhir_stores.import_fhir_store( service_account_json, api_key, project_id, cloud_region, dataset_id, fhir_store_id, import_object) # Clean up blob.delete() fhir_stores.delete_fhir_store( service_account_json, api_key, project_id, cloud_region, dataset_id, fhir_store_id) out, _ = capsys.readouterr() assert 'Imported FHIR resources' in out
def test_fhir_store(): fhir_store = fhir_stores.create_fhir_store( service_account_json, project_id, cloud_region, dataset_id, fhir_store_id) yield fhir_store fhir_stores.delete_fhir_store( service_account_json, project_id, cloud_region, dataset_id, fhir_store_id)
def _create(): fhir_stores.create_fhir_store(project_id, location, dataset_id, fhir_store_id, version)
def create(): fhir_stores.create_fhir_store(service_account_json, project_id, cloud_region, dataset_id, fhir_store_id)
def _create(): fhir_stores.create_fhir_store(project_id, cloud_region, dataset_id, fhir_store_id)