Skip to content

Commit 16f688b

Browse files
ghercegclaudep
authored andcommitted
Ensure valid xml in test_call_app
1 parent 4cacba4 commit 16f688b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tests/test_gateways.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from unittest.mock import Mock, patch
22
from urllib.parse import urlencode
3+
from xml.etree import ElementTree
34

45
from django.template.loader import render_to_string
56
from django.test import TestCase
@@ -17,7 +18,10 @@ def test_call_app(self):
1718
self.maxDiff = None
1819
url = reverse('two_factor_twilio:call_app', args=['123456'])
1920
response = self.client.get(url)
20-
self.assertEqual(response.content.decode('utf-8'), """<?xml version="1.0" encoding="UTF-8" ?>
21+
content = response.content.decode('utf-8')
22+
# raises an exception if invalid xml
23+
ElementTree.fromstring(content)
24+
self.assertEqual(content, """<?xml version="1.0" encoding="UTF-8" ?>
2125
<Response>
2226
<Gather timeout="15" numDigits="1" finishOnKey="">
2327
<Say language="en">Hi, this is testserver calling. Press any key to continue.</Say>
@@ -27,7 +31,10 @@ def test_call_app(self):
2731

2832
url = reverse('two_factor_twilio:call_app', args=['123456'])
2933
response = self.client.post(url)
30-
self.assertEqual(response.content.decode('utf-8'), """<?xml version="1.0" encoding="UTF-8" ?>
34+
content = response.content.decode('utf-8')
35+
# raises an exception if invalid xml
36+
ElementTree.fromstring(content)
37+
self.assertEqual(content, """<?xml version="1.0" encoding="UTF-8" ?>
3138
<Response>
3239
<Say language="en">Your token is:</Say>
3340
<Pause/>

0 commit comments

Comments
 (0)