예제 #1
0
 def test_guess_form_name_from_xmlns(self):
     form_name = 'my cool form'
     xmlns = 'http://a.b.org'
     self._send_form_to_es(
         xmlns=xmlns,
         form_name=form_name,
     )
     self.assertEqual(form_name, guess_form_name_from_submissions_using_xmlns(self.domain, xmlns))
예제 #2
0
 def test_guess_form_name_from_xmlns(self):
     form_name = 'my cool form'
     xmlns = 'http://a.b.org'
     self._send_form_to_es(
         xmlns=xmlns,
         form_name=form_name,
     )
     self.assertEqual(form_name, guess_form_name_from_submissions_using_xmlns(self.domain, xmlns))
예제 #3
0
    def get_unknown_form_name(self, xmlns, app_id=None, none_if_not_found=False):
        if app_id is not None and app_id != MISSING_APP_ID:
            try:
                app = Application.get_db().get(app_id)
            except ResourceNotFound:
                # must have been a weird app id, don't fail hard
                pass
            else:
                for module in app.get('modules', []):
                    for form in module['forms']:
                        if form['xmlns'] == xmlns:
                            return form['name'].values()[0]

        guessed_name = guess_form_name_from_submissions_using_xmlns(self.domain, xmlns)
        return guessed_name or (None if none_if_not_found else _("Name Unknown"))
예제 #4
0
    def get_unknown_form_name(self, xmlns, app_id=None, none_if_not_found=False):
        if app_id is not None and app_id != MISSING_APP_ID:
            try:
                app = Application.get_db().get(app_id)
            except ResourceNotFound:
                # must have been a weird app id, don't fail hard
                pass
            else:
                for module in app.get('modules', []):
                    for form in module['forms']:
                        if form['xmlns'] == xmlns:
                            return form['name'].values()[0]

        guessed_name = guess_form_name_from_submissions_using_xmlns(self.domain, xmlns)
        return guessed_name or (None if none_if_not_found else _("Name Unknown"))
예제 #5
0
 def test_guess_form_name_from_xmlns_not_found(self):
     self.assertEqual(
         None,
         guess_form_name_from_submissions_using_xmlns('missing', 'missing'))
예제 #6
0
 def test_guess_form_name_from_xmlns_not_found(self):
     self.assertEqual(None, guess_form_name_from_submissions_using_xmlns('missing', 'missing'))