示例#1
0
def test_bad_data_type():
    """
    Notify if column data type is wrong
    """
    patient = get_patient()
    bad_column_mapping = {
        'column': 'data_proxima_consulta',
        'data_type': 'omrs_datetime',
        'commcare_data_type': 'cc_date',
        'property': 'data_proxima_consulta'
    }
    with get_importer(bad_column_mapping) as importer:
        with assert_raises_regex(
                ConfigurationError,
                'Errors importing from <OpenmrsImporter None admin@http://www.example.com/openmrs>:\n'
                'Unable to deserialize value 1551564000000 '
                'in column "data_proxima_consulta" '
                'for case property "data_proxima_consulta". '
                'OpenMRS data type is given as "omrs_datetime". '
                'CommCare data type is given as "cc_date": '
                "argument of type 'int' is not iterable"):
            get_case_properties(patient, importer)
示例#2
0
def test_get_case_properties():
    """
    If given a patient as returned by an OpenMRS report, and an importer, then
    get_case_properties should return the case name and fields to update.
    """
    patient = get_patient()

    with get_importer() as importer:
        case_name, fields_to_update = get_case_properties(patient, importer)

        assert case_name == 'David John Smith'
        assert fields_to_update == {
            'a_faltar': 0,
            'apelido': 'Smith',
            'avenida': None,
            'bairro': 'Unidade H',
            'celula': None,
            'coinfectado': 'FALSE',
            'contact_phone_number': '811231234',
            'data_do_nacimento': '1981-10-31',
            'data_proxima_consulta': '2019-03-03',
            'data_ultima_consulta': '2019-02-25T00:00:00+02:00',
            'distrito': 'Matola',
            'estado_tarv': 'pre-TARV',
            'genero': 'M',
            'gravida': 'FALSE',
            'nid': '01234567/12/01234',
            'nome': 'David John',
            'numero_conviventes': None,
            'numero_de_filhos': 3,
            'numero_de_filhos_positivos': None,
            'numero_de_filhos_testados': 3,
            'parceiro_serologia': 'positive',
            'provincia': 'Maputo',
            'tarv_elegivel': 1
        }