コード例 #1
0
    def testSubmitBadXML(self):
        f, path = tmpfile()
        with f:
            f.write("this isn't even close to xml")
        with open(path) as f:
            res = self.client.post(self.url, {"xml_submission_file": f})
            self.assertEqual(500, res.status_code)
            self.assertIn("Invalid XML", res.content)

        # make sure we logged it
        [log] = get_forms_by_type(self.domain.name, "SubmissionErrorLog", limit=1)

        self.assertIsNotNone(log)
        self.assertIn("Invalid XML", log.problem)
        self.assertEqual("this isn't even close to xml", log.get_xml())
コード例 #2
0
    def testSubmitBadXML(self):
        f, path = tmpfile()
        with f:
            f.write("this isn't even close to xml")
        with open(path) as f:
            res = self.client.post(self.url, {"xml_submission_file": f})
            self.assertEqual(500, res.status_code)
            self.assertIn('Invalid XML', res.content)

        # make sure we logged it
        [log] = FormAccessors(self.domain.name).get_forms_by_type(
            'SubmissionErrorLog', limit=1)

        self.assertIsNotNone(log)
        self.assertIn('Invalid XML', log.problem)
        self.assertEqual("this isn't even close to xml", log.get_xml())
コード例 #3
0
    def testSubmitBadXML(self):
        f, path = tmpfile()
        with f:
            f.write("this isn't even close to xml")
        with open(path, encoding='utf-8') as f:
            res = self.client.post(self.url, {
                    "xml_submission_file": f
            })
            self.assertEqual(500, res.status_code)
            self.assertIn('Invalid XML', res.content.decode('utf-8'))

        # make sure we logged it
        [log] = FormAccessors(self.domain.name).get_forms_by_type('SubmissionErrorLog', limit=1)

        self.assertIsNotNone(log)
        self.assertIn('Invalid XML', log.problem)
        self.assertEqual("this isn't even close to xml", log.get_xml().decode('utf-8'))
        self.assertEqual(log.form_data, {})
コード例 #4
0
 def testSubmitBadXML(self):
     f, path = tmpfile()
     with f:
         f.write("this isn't even close to xml")
     with open(path) as f:
         res = self.client.post(self.url, {
                 "xml_submission_file": f
         })
         self.assertEqual(500, res.status_code)
         self.assertIn('Invalid XML', res.content)
     
     # make sure we logged it
     log = SubmissionErrorLog.view("couchforms/all_submissions_by_domain",
                                   reduce=False,
                                   include_docs=True,
                                   startkey=[self.domain.name, "by_type", "SubmissionErrorLog"],
                                   endkey=[self.domain.name, "by_type", "SubmissionErrorLog", {}]).one()
     
     self.assertTrue(log is not None)
     self.assertIn('Invalid XML', log.problem)
     self.assertEqual("this isn't even close to xml", log.get_xml())
コード例 #5
0
    def testSubmitBadXML(self):
        f, path = tmpfile()
        with f:
            f.write("this isn't even close to xml")
        with open(path) as f:
            res = self.client.post(self.url, {"xml_submission_file": f})
            self.assertEqual(500, res.status_code)
            self.assertIn('Invalid XML', res.content)

        # make sure we logged it
        log = SubmissionErrorLog.view(
            "couchforms/all_submissions_by_domain",
            reduce=False,
            include_docs=True,
            startkey=[self.domain.name, "by_type", "SubmissionErrorLog"],
            endkey=[self.domain.name, "by_type", "SubmissionErrorLog",
                    {}]).one()

        self.assertTrue(log is not None)
        self.assertIn('Invalid XML', log.problem)
        self.assertEqual("this isn't even close to xml", log.get_xml())