Hi, I am new to Django and Python...That is not a very good point for me to start up a new Django based web application. I am trying my best to learn how to work with Django. If this is a stupid question, please forgive my ignorance.
How could I send a xml payload by Django test client to my application? Here is the code of the class based view I wrote for receiving the xml file. class NewReport(View): def post(self, request): rawdata = request.body ## cannot accept the request if body is null if (not rawdata): return HttpResponse('naked body') reportraw = ReportRaw(rawdata) reportraw.save() return HttpResponse('ok') Here is the test code. class ReportRawTests(TestCase): def test_new_view_with_no_data(self): """ If no report embedded in a request.body, an appropriate error code should be displayed. """ response = self.client.post(reverse('new'), {}) #### cause exception self.assertEqual(response.status_code, 200) self.assertContains(response, "naked body") As the comment describes, the test is about how server side should response to a request which has no report data inside. The expected behaviour is that the server will return 'naked body' string in response object. However, the test code cannot work and I got exceptions. How could I send a real xml payload with the test client? What about a empty payload? Best regards, /Adam -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.