Пример #1
0
 def conditional_delete_resource():
     fhir_resources.conditional_delete_resource(
         service_account_json,
         base_url,
         project_id,
         cloud_region,
         dataset_id,
         fhir_store_id,
     )
def test_conditional_delete_resource(test_dataset, test_fhir_store,
                                     test_patient, capsys):
    # The conditional method tests use an Observation, so we have to create an
    # Encounter from test_patient and then create an Observation from the
    # Encounter.
    encounter_response = fhir_resources.create_encounter(
        service_account_json,
        base_url,
        project_id,
        cloud_region,
        dataset_id,
        fhir_store_id,
        test_patient,
    )

    encounter_resource_id = encounter_response.json()["id"]

    fhir_resources.create_observation(
        service_account_json,
        base_url,
        project_id,
        cloud_region,
        dataset_id,
        fhir_store_id,
        test_patient,
        encounter_resource_id,
    )

    fhir_resources.conditional_delete_resource(
        service_account_json,
        base_url,
        project_id,
        cloud_region,
        dataset_id,
        fhir_store_id,
    )

    out, _ = capsys.readouterr()

    print(out)

    assert "Conditionally deleted" in out
Пример #3
0
def test_CRUD_search_resource(test_dataset, test_fhir_store, capsys):
    response = fhir_resources.create_resource(service_account_json, base_url,
                                              project_id, cloud_region,
                                              dataset_id, fhir_store_id,
                                              resource_type)

    # Save the resource_id because you need to pass it into later tests
    resource_id = response.json()['id']

    fhir_resources.search_resources_get(service_account_json, base_url,
                                        project_id, cloud_region, dataset_id,
                                        fhir_store_id, resource_type)

    fhir_resources.get_resource(service_account_json, base_url, project_id,
                                cloud_region, dataset_id, fhir_store_id,
                                resource_type, resource_id)

    fhir_resources.update_resource(service_account_json, base_url, project_id,
                                   cloud_region, dataset_id, fhir_store_id,
                                   resource_type, resource_id)

    fhir_resources.conditional_update_resource(service_account_json, base_url,
                                               project_id, cloud_region,
                                               dataset_id, fhir_store_id,
                                               resource_type, resource_id)

    fhir_resources.patch_resource(service_account_json, base_url, project_id,
                                  cloud_region, dataset_id, fhir_store_id,
                                  resource_type, resource_id)

    fhir_resources.conditional_patch_resource(service_account_json, base_url,
                                              project_id, cloud_region,
                                              dataset_id, fhir_store_id,
                                              resource_type, resource_id)

    history = fhir_resources.list_resource_history(service_account_json,
                                                   base_url, project_id,
                                                   cloud_region, dataset_id,
                                                   fhir_store_id,
                                                   resource_type, resource_id)

    fhir_resources.get_resource_history(
        service_account_json, base_url, project_id, cloud_region, dataset_id,
        fhir_store_id, resource_type, resource_id,
        history['entry'][-1]['resource']['meta']['versionId'])

    fhir_resources.delete_resource_purge(service_account_json, base_url,
                                         project_id, cloud_region, dataset_id,
                                         fhir_store_id, resource_type,
                                         resource_id)

    fhir_resources.conditional_delete_resource(service_account_json, base_url,
                                               project_id, cloud_region,
                                               dataset_id, fhir_store_id,
                                               resource_type, resource_id)

    fhir_resources.delete_resource(service_account_json, base_url, project_id,
                                   cloud_region, dataset_id, fhir_store_id,
                                   resource_type, resource_id)

    out, _ = capsys.readouterr()

    # Check that create/search worked
    assert 'Created Resource' in out
    assert 'id' in out
    assert 'Conditionally updated' in out
    assert 'search' in out
    assert 'link' in out
    assert ' deleted' in out
    assert resource_id in out
    assert 'Deleted Resource' in out
def test_CRUD_search_resource(test_dataset, test_fhir_store, capsys):
    response = fhir_resources.create_resource(
        service_account_json,
        base_url,
        project_id,
        cloud_region,
        dataset_id,
        fhir_store_id,
        resource_type)

    # Save the resource_id because you need to pass it into later tests
    resource_id = response.json()['id']

    fhir_resources.search_resources_get(
        service_account_json,
        base_url,
        project_id,
        cloud_region,
        dataset_id,
        fhir_store_id,
        resource_type)

    fhir_resources.get_resource(
        service_account_json,
        base_url,
        project_id,
        cloud_region,
        dataset_id,
        fhir_store_id,
        resource_type,
        resource_id)

    fhir_resources.update_resource(
        service_account_json,
        base_url,
        project_id,
        cloud_region,
        dataset_id,
        fhir_store_id,
        resource_type,
        resource_id)

    fhir_resources.conditional_update_resource(
        service_account_json,
        base_url,
        project_id,
        cloud_region,
        dataset_id,
        fhir_store_id,
        resource_type,
        resource_id)

    fhir_resources.patch_resource(
        service_account_json,
        base_url,
        project_id,
        cloud_region,
        dataset_id,
        fhir_store_id,
        resource_type,
        resource_id)

    fhir_resources.conditional_patch_resource(
        service_account_json,
        base_url,
        project_id,
        cloud_region,
        dataset_id,
        fhir_store_id,
        resource_type,
        resource_id)

    history = fhir_resources.list_resource_history(
        service_account_json,
        base_url,
        project_id,
        cloud_region,
        dataset_id,
        fhir_store_id,
        resource_type,
        resource_id)

    fhir_resources.get_resource_history(
        service_account_json,
        base_url,
        project_id,
        cloud_region,
        dataset_id,
        fhir_store_id,
        resource_type,
        resource_id,
        history['entry'][-1]['resource']['meta']['versionId'])

    fhir_resources.delete_resource_purge(
        service_account_json,
        base_url,
        project_id,
        cloud_region,
        dataset_id,
        fhir_store_id,
        resource_type,
        resource_id)

    fhir_resources.conditional_delete_resource(
        service_account_json,
        base_url,
        project_id,
        cloud_region,
        dataset_id,
        fhir_store_id,
        resource_type,
        resource_id)

    fhir_resources.delete_resource(
        service_account_json,
        base_url,
        project_id,
        cloud_region,
        dataset_id,
        fhir_store_id,
        resource_type,
        resource_id)

    out, _ = capsys.readouterr()

    # Check that create/search worked
    assert 'Created Resource' in out
    assert 'id' in out
    assert 'Conditionally updated' in out
    assert 'search' in out
    assert 'link' in out
    assert ' deleted' in out
    assert resource_id in out
    assert 'Deleted Resource' in out