Created
October 27, 2011 21:08
-
-
Save erikcw/1320881 to your computer and use it in GitHub Desktop.
Unittest demonstrating attribute stripping.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xml.etree.ElementTree as ET | |
from twilio import twiml | |
from django.test import TestCase | |
class TwimlTest(TestCase): | |
def test_twiml_conference_verb(self): | |
""" | |
Sanity check for TwiML generation. | |
""" | |
r = twiml.Response() | |
import ipdb; ipdb.set_trace() | |
with r.dial() as dial: | |
dial.conference("TestConferenceAttributes", beep=False, waitUrl="", startConferenceOnEnter=True, endConferenceOnExit=True) | |
xml = r.toxml() | |
#parse twiml XML string with Element Tree and inspect structure | |
tree = ET.fromstring(xml) | |
self.assertIsNotNone(tree.find(".//Dial/Conference")) | |
#check Conference tag attributes | |
conf = tree.find(".//Dial/Conference") | |
self.assertEqual(conf.text.strip(), "TestConferenceAttributes") | |
self.assertEqual(conf.get('beep'), "false") | |
self.assertEqual(conf.get('waitUrl'), "") | |
self.assertEqual(conf.get('startConferenceOnJoin'), "true") | |
self.assertEqual(conf.get('endConferenceOnExit'), "true") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that this tests both the problem with Twilio striping the False, 0, and '' attributes.
It also test the boolean uppercase issue.