Skip to content

Instantly share code, notes, and snippets.

@komuw
Created July 2, 2015 13:31
Show Gist options
  • Save komuw/2602693775ed97461404 to your computer and use it in GitHub Desktop.
Save komuw/2602693775ed97461404 to your computer and use it in GitHub Desktop.
test xml in django/ rest framework
from rest_framework.test import APIClient
class SomeTests(LiveServerTestCase):
def setUp(self):
self.real_URL = settings.SOME_URL
settings.SOME_URL = '{0}/some-url/'.format(self.live_server_url)
self.client = APIClient()
self.payload = """<some>xml-string</xml>"""
def tearDown(self):
settings.SOME_URL = self.real_URL
def test_something(self):
response = self.client.post(reverse('view_name'), data=self.payload, content_type='application/xml')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment