def test_guess_form_name_from_xmlns(self): domain = uuid.uuid4().hex xmlns = uuid.uuid4().hex form_id = uuid.uuid4().hex form_name = 'my cool form' metadata = TestFormMetadata(domain=domain, xmlns=xmlns, form_name=form_name) get_simple_wrapped_form(form_id, metadata=metadata) update_reports_analytics_indexes() self.assertEqual(form_name, guess_form_name_from_submissions_using_xmlns(domain, xmlns))
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"))
def test_guess_form_name_from_xmlns_not_found(self): self.assertEqual(None, guess_form_name_from_submissions_using_xmlns('missing', 'missing'))