def bob_setup(bob_account_id, record_id, carenet_id, allowed_docs, disallowed_docs): bob_chrome_client = IndivoClient("chrome", "chrome") bob_chrome_client.create_session(data.account02) # SZ: Bob should NOT be able to read the docs directly in the record for doc_id in allowed_docs + disallowed_docs: assert_403(bob_chrome_client.read_document(record_id=record_id, document_id=doc_id)) assert_403(bob_chrome_client.get_record_carenets(record_id=record_id)) # Bob should be able to read the allowed docs for doc_id in allowed_docs: assert_200(bob_chrome_client.get_carenet_document(carenet_id=carenet_id, document_id=doc_id)) # Bob should not be able to read the disallowed docs for doc_id in disallowed_docs: assert_404(bob_chrome_client.get_carenet_document(carenet_id=carenet_id, document_id=doc_id)) # Bob should be able to list docs in the carenet carenet_documents_list = bob_chrome_client.get_carenet_documents(carenet_id=carenet_id).response[PRD][ "Document" ] # with a parameter carenet_documents_list = bob_chrome_client.get_carenet_documents( carenet_id=carenet_id, parameters={"type": "http://indivo.org/vocab/xml/documents#Allergy"} ).response[PRD]["Document"] # Read carenet allergies assert_200(bob_chrome_client.read_carenet_allergies(carenet_id=carenet_id)) assert_200(bob_chrome_client.read_carenet_problems(carenet_id=carenet_id)) # Read the contact document, this should work contact_doc = parse_xml( bob_chrome_client.read_carenet_special_document(carenet_id=carenet_id, special_document="contact") ) contact_name = xpath( contact_doc, "/ns:Contact/ns:name/ns:fullName/text()", namespaces={"ns": "http://indivo.org/vocab/xml/documents#"}, ) assert contact_name bob_chrome_client.get_account_permissions(account_id=bob_account_id) bob_chrome_client.get_carenet_account_permissions( carenet_id=carenet_id, record_id=record_id, account_id=bob_account_id ) # Not yet implemented # bob_chrome_client.get_carenet_app_permissions(account_id=bob_account_id) return True
def bob_setup(bob_account_id, record_id, carenet_id, allowed_docs, disallowed_docs): bob_chrome_client = IndivoClient('chrome', 'chrome') bob_chrome_client.create_session(data.account02) # SZ: Bob should NOT be able to read the docs directly in the record for doc_id in allowed_docs+disallowed_docs: assert_403(bob_chrome_client.read_document(record_id=record_id, document_id=doc_id)) assert_403(bob_chrome_client.get_record_carenets(record_id=record_id)) # Bob should be able to read the allowed docs for doc_id in allowed_docs: assert_200(bob_chrome_client.get_carenet_document(carenet_id = carenet_id, document_id = doc_id)) # Bob should not be able to read the disallowed docs for doc_id in disallowed_docs: assert_404(bob_chrome_client.get_carenet_document(carenet_id = carenet_id, document_id = doc_id)) # Bob should be able to list docs in the carenet carenet_documents_list = bob_chrome_client.get_carenet_documents(carenet_id = carenet_id).response[PRD]['Document'] # with a parameter carenet_documents_list = bob_chrome_client.get_carenet_documents(carenet_id = carenet_id, parameters={'type': 'http://indivo.org/vocab/xml/documents#Allergy'}).response[PRD]['Document'] # Read carenet allergies # TODO: replace with generic call # assert_200(bob_chrome_client.read_carenet_allergies(carenet_id = carenet_id)) # Read the demographics document, this should work resp = bob_chrome_client.call('GET', '/carenets/%s/demographics'%carenet_id, options={'parameters':{'response_format':'application/xml'}} ) demographics_doc = parse_xml(resp) family_name = xpath(demographics_doc, '/Models/Model/Field[@name="name_family"]/text()') assert(family_name) bob_chrome_client.get_account_permissions(account_id=bob_account_id) bob_chrome_client.get_carenet_account_permissions(carenet_id= carenet_id, record_id=record_id, account_id=bob_account_id) # Not yet implemented #bob_chrome_client.get_carenet_app_permissions(account_id=bob_account_id) return True
def bob_setup(bob_account_id, record_id, carenet_id, allowed_docs, disallowed_docs): bob_chrome_client = IndivoClient('chrome', 'chrome') bob_chrome_client.create_session(data.account02) # SZ: Bob should NOT be able to read the docs directly in the record for doc_id in allowed_docs + disallowed_docs: assert_403( bob_chrome_client.read_document(record_id=record_id, document_id=doc_id)) assert_403(bob_chrome_client.get_record_carenets(record_id=record_id)) # Bob should be able to read the allowed docs for doc_id in allowed_docs: assert_200( bob_chrome_client.get_carenet_document(carenet_id=carenet_id, document_id=doc_id)) # Bob should not be able to read the disallowed docs for doc_id in disallowed_docs: assert_404( bob_chrome_client.get_carenet_document(carenet_id=carenet_id, document_id=doc_id)) # Bob should be able to list docs in the carenet carenet_documents_list = bob_chrome_client.get_carenet_documents( carenet_id=carenet_id).response[PRD]['Document'] # with a parameter carenet_documents_list = bob_chrome_client.get_carenet_documents( carenet_id=carenet_id, parameters={ 'type': 'http://indivo.org/vocab/xml/documents#Allergy' }).response[PRD]['Document'] # Read carenet allergies # TODO: replace with generic call # assert_200(bob_chrome_client.read_carenet_allergies(carenet_id = carenet_id)) # Read the demographics document, this should work resp = bob_chrome_client.call( 'GET', '/carenets/%s/demographics' % carenet_id, options={'parameters': { 'response_format': 'application/xml' }}) demographics_doc = parse_xml(resp) family_name = xpath(demographics_doc, '/Models/Model/Field[@name="name_family"]/text()') assert (family_name) bob_chrome_client.get_account_permissions(account_id=bob_account_id) bob_chrome_client.get_carenet_account_permissions( carenet_id=carenet_id, record_id=record_id, account_id=bob_account_id) # Not yet implemented #bob_chrome_client.get_carenet_app_permissions(account_id=bob_account_id) return True
def bob_setup(bob_account_id, record_id, carenet_id, allowed_docs, disallowed_docs): bob_chrome_client = IndivoClient('chrome', 'chrome') bob_chrome_client.create_session(data.account02) # SZ: Bob should NOT be able to read the docs directly in the record for doc_id in allowed_docs + disallowed_docs: assert_403( bob_chrome_client.read_document(record_id=record_id, document_id=doc_id)) assert_403(bob_chrome_client.get_record_carenets(record_id=record_id)) # Bob should be able to read the allowed docs for doc_id in allowed_docs: assert_200( bob_chrome_client.get_carenet_document(carenet_id=carenet_id, document_id=doc_id)) # Bob should not be able to read the disallowed docs for doc_id in disallowed_docs: assert_404( bob_chrome_client.get_carenet_document(carenet_id=carenet_id, document_id=doc_id)) # Bob should be able to list docs in the carenet carenet_documents_list = bob_chrome_client.get_carenet_documents( carenet_id=carenet_id).response[PRD]['Document'] # with a parameter carenet_documents_list = bob_chrome_client.get_carenet_documents( carenet_id=carenet_id, parameters={ 'type': 'http://indivo.org/vocab/xml/documents#Allergy' }).response[PRD]['Document'] # Read carenet allergies assert_200( bob_chrome_client.read_carenet_allergies(carenet_id=carenet_id)) assert_200( bob_chrome_client.read_carenet_problems(carenet_id=carenet_id)) # Read the contact document, this should work contact_doc = parse_xml( bob_chrome_client.read_carenet_special_document( carenet_id=carenet_id, special_document='contact')) contact_name = xpath( contact_doc, '/ns:Contact/ns:name/ns:fullName/text()', namespaces={'ns': 'http://indivo.org/vocab/xml/documents#'}) assert (contact_name) bob_chrome_client.get_account_permissions(account_id=bob_account_id) bob_chrome_client.get_carenet_account_permissions( carenet_id=carenet_id, record_id=record_id, account_id=bob_account_id) # Not yet implemented #bob_chrome_client.get_carenet_app_permissions(account_id=bob_account_id) return True