Пример #1
0
    def test_submission_with_instance_id_on_root_node(self):
        view = XFormSubmissionApi.as_view({'post': 'create'})
        self._publish_xml_form()
        message = u"Successful submission."
        instanceId = u'5b2cc313-fc09-437e-8149-fcd32f695d41'
        self.assertRaises(
            Instance.DoesNotExist, Instance.objects.get, uuid=instanceId)
        submission_path = os.path.join(
            self.main_directory, 'fixtures', 'transportation',
            'view', 'submission.xml')
        count = Instance.objects.count()
        with codecs.open(submission_path, encoding='utf-8') as f:
            post_data = {'xml_submission_file': f}
            request = self.factory.post(self._submission_list_url, post_data)
            response = view(request)
            self.assertEqual(response.status_code, 401)
            auth = DigestAuth('bob', 'bobbob')

            # Rewind the file to avoid the xml parser to get an empty string
            # and throw and parsing error
            f.seek(0)
            # Create a new requests to avoid request.FILES to be empty
            request = self.factory.post(self._submission_list_url, post_data)
            request.META.update(auth(request.META, response))
            response = view(request, username=self.user.username)
            self.assertContains(response, message, status_code=201)
            self.assertContains(response, instanceId, status_code=201)
            self.assertEqual(Instance.objects.count(), count + 1)
 def setUp(self):
     super(self.__class__, self).setUp()
     self.view = XFormSubmissionApi.as_view({
         "head": "create",
         "post": "create"
     })
     self._publish_xls_form_to_project()
Пример #3
0
 def setUp(self):
     super().setUp()
     self.view = XFormSubmissionApi.as_view({
         "head": "create",
         "post": "create"
     })
     self.publish_xls_form()
Пример #4
0
 def submission_view(self):
     if not hasattr(self, '_submission_view'):
         setattr(
             self, '_submission_view',
             XFormSubmissionApi.as_view({
                 "head": "create",
                 "post": "create"
             }))
     return self._submission_view
Пример #5
0
 def test_submission_with_instance_id_on_root_node(self):
     view = XFormSubmissionApi.as_view({"post": "create"})
     self._publish_xml_form()
     message = u"Successful submission."
     instanceId = u"5b2cc313-fc09-437e-8149-fcd32f695d41"
     self.assertRaises(Instance.DoesNotExist, Instance.objects.get, uuid=instanceId)
     submission_path = os.path.join(self.main_directory, "fixtures", "transportation", "view", "submission.xml")
     count = Instance.objects.count()
     with codecs.open(submission_path, encoding="utf-8") as f:
         post_data = {"xml_submission_file": f}
         request = self.factory.post(self._submission_list_url, post_data)
         response = view(request)
         self.assertEqual(response.status_code, 401)
         auth = DigestAuth("bob", "bobbob")
         request.META.update(auth(request.META, response))
         response = view(request, username=self.user.username)
         self.assertContains(response, message, status_code=201)
         self.assertContains(response, instanceId, status_code=201)
         self.assertEqual(Instance.objects.count(), count + 1)