Skip to content

Commit

Permalink
Ensure valid xml in test_call_app
Browse files Browse the repository at this point in the history
  • Loading branch information
gherceg authored and claudep committed Feb 24, 2024
1 parent 4cacba4 commit 16f688b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tests/test_gateways.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from unittest.mock import Mock, patch
from urllib.parse import urlencode
from xml.etree import ElementTree

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

url = reverse('two_factor_twilio:call_app', args=['123456'])
response = self.client.post(url)
self.assertEqual(response.content.decode('utf-8'), """<?xml version="1.0" encoding="UTF-8" ?>
content = response.content.decode('utf-8')
# raises an exception if invalid xml
ElementTree.fromstring(content)
self.assertEqual(content, """<?xml version="1.0" encoding="UTF-8" ?>
<Response>
<Say language="en">Your token is:</Say>
<Pause/>
Expand Down

0 comments on commit 16f688b

Please sign in to comment.