Esempio n. 1
0
def bootstrap_case_from_xml(test_class, filename, case_id_override=None, domain=None):
    starttime = utcnow_sans_milliseconds()

    file_path = os.path.join(os.path.dirname(__file__), "data", filename)
    with open(file_path, "rb") as f:
        xml_data = f.read()
    updated_xml, uid, case_id = _replace_ids_in_xform_xml(xml_data, case_id_override=case_id_override)

    domain = domain or "test-domain"
    _, _, [case] = FormProcessorInterface().submit_form_locally(updated_xml, domain=domain)
    test_class.assertLessEqual(starttime, case.server_modified_on)
    test_class.assertGreaterEqual(datetime.utcnow(), case.server_modified_on)
    test_class.assertEqual(case_id, case.case_id)
    return case
Esempio n. 2
0
def bootstrap_case_from_xml(test_class, filename, case_id_override=None, domain=None):
    starttime = utcnow_sans_milliseconds()
    
    file_path = os.path.join(os.path.dirname(__file__), "data", filename)
    with open(file_path, "rb") as f:
        xml_data = f.read()
    updated_xml, uid, case_id = _replace_ids_in_xform_xml(
        xml_data,
        case_id_override=case_id_override,
    )

    domain = domain or 'test-domain'
    _, xform, [case] = submit_form_locally(updated_xml, domain=domain)
    test_class.assertLessEqual(starttime, case.server_modified_on)
    test_class.assertGreaterEqual(datetime.utcnow(), case.server_modified_on)
    test_class.assertEqual(case_id, case.case_id)
    return xform, case
Esempio n. 3
0
def bootstrap_case_from_xml(test_class, filename, case_id_override=None,
                                 referral_id_override=None):
    
    starttime = utcnow_sans_milliseconds()
    
    file_path = os.path.join(os.path.dirname(__file__), "data", filename)
    with open(file_path, "rb") as f:
        xml_data = f.read()
    doc_id, uid, case_id, ref_id = replace_ids_and_post(xml_data, case_id_override=case_id_override,
                                                         referral_id_override=referral_id_override)  
    doc = XFormInstance.get(doc_id)
    process_cases(sender="testharness", xform=doc)
    case = CommCareCase.get(case_id)
    test_class.assertTrue(starttime <= case.server_modified_on)
    test_class.assertTrue(datetime.utcnow() >= case.server_modified_on)
    test_class.assertEqual(case_id, case.case_id)
    return case
Esempio n. 4
0
def bootstrap_case_from_xml(test_class, filename, case_id_override=None, domain=None):
    starttime = utcnow_sans_milliseconds()
    
    file_path = os.path.join(os.path.dirname(__file__), "data", filename)
    with open(file_path, "rb") as f:
        xml_data = f.read()
    doc, uid, case_id = _replace_ids_and_post(
        xml_data,
        case_id_override=case_id_override,
    )
    if domain:
        doc.domain = domain
    process_cases(doc)
    case = CommCareCase.get(case_id)
    test_class.assertLessEqual(starttime, case.server_modified_on)
    test_class.assertGreaterEqual(datetime.utcnow(), case.server_modified_on)
    test_class.assertEqual(case_id, case.case_id)
    return case
Esempio n. 5
0
def bootstrap_case_from_xml(test_class, filename, case_id_override=None, domain=None):
    starttime = utcnow_sans_milliseconds()
    
    file_path = os.path.join(os.path.dirname(__file__), "data", filename)
    with open(file_path, "rb") as f:
        xml_data = f.read()
    doc, uid, case_id = _replace_ids_and_post(
        xml_data,
        case_id_override=case_id_override,
    )
    if domain:
        doc.domain = domain
    process_cases(doc)
    case = CommCareCase.get(case_id)
    test_class.assertLessEqual(starttime, case.server_modified_on)
    test_class.assertGreaterEqual(datetime.utcnow(), case.server_modified_on)
    test_class.assertEqual(case_id, case.case_id)
    return case