Exemplo n.º 1
0
    def test_get_survey_url(self):
        enketo = Enketo()
        enketo.configure(ENKETO_URL="https://test.enketo.org/", API_TOKEN="abc")

        with HTTMock(get_survey_mock):
            url = enketo.get_survey_url("https://testserver.com/bob", "widgets")
            self.assertEqual(url, "https://cz2pj.enketo.org/webform")
Exemplo n.º 2
0
 def test_get_edit_url(self):
     enketo = Enketo()
     enketo.configure(ENKETO_URL="https://test.enketo.org/", API_TOKEN="abc")
     xml_instance = "<?xml version='1.0' ?><clinic_registration id=\"clinic_registration\"><formhub><uuid>73242968f5754dc49c38463af658f3d2</uuid></formhub><user_id>0</user_id><clinic_name>Test clinic</clinic_name><meta><instanceID>uuid:ec5ce15e-5a0a-4246-93fe-acf60ef69bf2</instanceID></meta></clinic_registration>"
     instance_id = uuid.uuid4()
     return_url = "https://testserver.com/bob/1"
     with HTTMock(get_edit_url_mock):
         enketo.get_edit_url("https://testserver.com/bob", "widgets", xml_instance, instance_id, return_url)
Exemplo n.º 3
0
import csv
import codecs
import unicodedata

from collections import Counter
from hashids import Hashids
from pyenketo import Enketo
from babel.dates import format_date
from whoahqa.constants import characteristics
from pyramid.i18n import TranslationStringFactory, get_localizer

translation_string_factory = TranslationStringFactory('who-ahqa')
hashid = Hashids(min_length=4, alphabet='abcdefghijklmnpqrstuvwxyz123456789')
enketo = Enketo()

INITIAL_SCORE_MAP = {
    characteristics.EQUITABLE: 0,
    characteristics.ACCESSIBLE: 0,
    characteristics.ACCEPTABLE: 0,
    characteristics.APPROPRIATE: 0,
    characteristics.EFFECTIVE: 0
}


def tuple_to_dict_list(key_tuple, value_tuples):
    return [dict(zip(key_tuple, c)) for c in value_tuples]


def format_date_for_locale(value, format_def, request):
    localizer = get_localizer(request)
    return format_date(value, format_def, locale=localizer.locale_name)
Exemplo n.º 4
0
 def test_get_survey_notexist(self):
     enketo = Enketo()
     enketo.configure(ENKETO_URL="https://test.enketo.org/", API_TOKEN="abc")
     with HTTMock(get_survey_mock):
         self.assertRaises(Http404, enketo.get_survey_url, "https://testserver.com/notexist", "widgets")