def get_by_doc_type(domain, doc_type): return XFormError.view( 'domain/docs', startkey=[domain, doc_type], endkey=[domain, doc_type, {}], reduce=False, include_docs=True, ).all()
def get(self, count): # this is a hack, but override the doc type because there is an # equivalent doc type in the view def _update_doc_type(form): form.doc_type = self.doc_type return form return [_update_doc_type(form) for form in \ XFormError.view("receiverwrapper/all_submissions_by_domain", include_docs=True, limit=count, **self._kwargs)]
def get(self, count): # this is a hack, but override the doc type because there is an # equivalent doc type in the view def _update_doc_type(form): form.doc_type = self.doc_type return form return [_update_doc_type(form) for form in \ XFormError.view("couchforms/all_submissions_by_domain", include_docs=True, limit=count, **self._kwargs)]
def test_no_case_id(self): """ submit form with a case block that has no case_id check that - it errors - the form is not saved under its original id - an XFormError is saved with the original id as orig_id - the error was logged (<-- is this hard to test?) <data xmlns="example.com/foo"> <case case_id=""> <update><foo>bar</foo></update> </case> </data> """ submit_form_locally( """<data xmlns="example.com/foo"> <meta> <instanceID>abc-easy-as-123</instanceID> </meta> <case case_id="" xmlns="http://commcarehq.org/case/transaction/v2"> <update><foo>bar</foo></update> </case> </data>""", 'my_very_special_domain', ) xform_errors = XFormError.view( 'domain/docs', startkey=['my_very_special_domain', 'XFormError'], endkey=['my_very_special_domain', 'XFormError', {}], reduce=False, include_docs=True, ).all() related_errors = [ xform_error for xform_error in xform_errors if xform_error.get_id == 'abc-easy-as-123' ] self.assertEqual(len(related_errors), 1) related_error = related_errors[0] self.assertEqual(related_error.problem, 'IllegalCaseId: case_id must not be empty')
def test_uses_referrals(self): """ submit form with a case block that uses referrals check that - it errors - the form is not saved under its original id - an XFormError is saved with the original id as orig_id """ submit_form_locally( """<data xmlns="example.com/foo"> <meta> <instanceID>abc-easy-as-456</instanceID> </meta> <case case_id="123" xmlns="http://commcarehq.org/case/transaction/v2"> <referral> <referral_id>456</referral_id> <open> <referral_types>t1 t2</referral_types> </open> </referral> </case> </data>""", 'my_very_special_domain', ) xform_errors = XFormError.view( 'domain/docs', startkey=['my_very_special_domain', 'XFormError'], endkey=['my_very_special_domain', 'XFormError', {}], reduce=False, include_docs=True, ).all() related_errors = [ xform_error for xform_error in xform_errors if xform_error.get_id == 'abc-easy-as-456' ] self.assertEqual(len(related_errors), 1) related_error = related_errors[0] self.assertEqual( related_error.problem, 'UsesReferrals: Sorry, referrals are no longer supported!')
def test_no_case_id(self): """ submit form with a case block that has no case_id check that - it errors - the form is not saved under its original id - an XFormError is saved with the original id as orig_id - the error was logged (<-- is this hard to test?) <data xmlns="example.com/foo"> <case case_id=""> <update><foo>bar</foo></update> </case> </data> """ submit_form_locally( """<data xmlns="example.com/foo"> <meta> <instanceID>abc-easy-as-123</instanceID> </meta> <case case_id="" xmlns="http://commcarehq.org/case/transaction/v2"> <update><foo>bar</foo></update> </case> </data>""", 'my_very_special_domain', ) xform_errors = XFormError.view( 'domain/docs', startkey=['my_very_special_domain', 'XFormError'], endkey=['my_very_special_domain', 'XFormError', {}], reduce=False, include_docs=True, ).all() related_errors = [xform_error for xform_error in xform_errors if xform_error.get_id == 'abc-easy-as-123'] self.assertEqual(len(related_errors), 1) related_error = related_errors[0] self.assertEqual(related_error.problem, 'IllegalCaseId: case_id must not be empty')
def test_uses_referrals(self): """ submit form with a case block that uses referrals check that - it errors - the form is not saved under its original id - an XFormError is saved with the original id as orig_id """ submit_form_locally( """<data xmlns="example.com/foo"> <meta> <instanceID>abc-easy-as-456</instanceID> </meta> <case case_id="123" xmlns="http://commcarehq.org/case/transaction/v2"> <referral> <referral_id>456</referral_id> <open> <referral_types>t1 t2</referral_types> </open> </referral> </case> </data>""", 'my_very_special_domain', ) xform_errors = XFormError.view( 'domain/docs', startkey=['my_very_special_domain', 'XFormError'], endkey=['my_very_special_domain', 'XFormError', {}], reduce=False, include_docs=True, ).all() related_errors = [xform_error for xform_error in xform_errors if xform_error.get_id == 'abc-easy-as-456'] self.assertEqual(len(related_errors), 1) related_error = related_errors[0] self.assertEqual(related_error.problem, 'UsesReferrals: Sorry, referrals are no longer supported!')
def get_total(self): return XFormError.view("receiverwrapper/all_submissions_by_domain", **self._kwargs).count()
def total_records(self): return XFormError.view("receiverwrapper/all_submissions_by_domain", startkey=[self.domain, "by_type"], endkey=[self.domain, "by_type", {}], reduce=False).count()
def total_records(self): return XFormError.view("couchforms/all_submissions_by_domain", startkey=[self.domain, "by_type"], endkey=[self.domain, "by_type", {}], reduce=False).count()
def get_total(self): return XFormError.view("couchforms/all_submissions_by_domain", **self._kwargs).count()