-
Notifications
You must be signed in to change notification settings - Fork 774
Next gen twiml #316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Next gen twiml #316
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0af4776
Move TwiML to unique types
jingming bab5f05
Add unit tests
jingming 159a5ad
Delete old TwiML files
jingming b84ed80
Add docs
jingming 041760d
Merge branch 'next-gen' of https://github.com/twilio/twilio-python in…
jingming c374d0b
Return self on TwiML append
jingming 664c1fb
Throw exception on appending non-TwiML
jingming ed160fd
Add an exception message
jingming File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
<
8000
/div>
Failed to load files.
Loading
Diff view
Diff view
Throw exception on appending non-TwiML
- Loading branch information
commit 664c1fbc33cafc147ef56227fa054348e3339a98
There are no files selected for viewing
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
import unittest | ||
|
||
from nose.tools import raises | ||
from six import text_type | ||
|
||
from twilio.twiml import TwiMLException, TwiML | ||
|
||
|
||
class TwilioTest(unittest.TestCase): | ||
def strip(self, xml): | ||
return text_type(xml) | ||
|
||
@raises(TwiMLException) | ||
def test_append_fail(self): | ||
t = TwiML() | ||
t.append('foobar') |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,10 @@ def lower_camel(string): | |
return result[0].lower() + result[1:] | ||
|
||
|
||
class TwiMLException(Exception): | ||
pass | ||
|
||
|
||
class TwiML(object): | ||
""" | ||
Twilio basic verb object. | ||
|
@@ -50,7 +54,23 @@ def to_xml(self, xml_declaration=True): | |
else: | ||
return xml | ||
|
||
def append(self, verb): | ||
""" | ||
Add a TwiML doc | ||
:param verb: TwiML Document | ||
:return: | ||
""" | ||
if not isinstance(verb, TwiML): | ||
raise TwiMLException() | ||
|
||
self.verbs.append(verb) | ||
return self | ||
|
||
def xml(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Docs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or prefix with _ if not public |
||
""" | ||
Convert to XML | ||
:return: Generated TwiML | ||
""" | ||
el = ET.Element(self.name) | ||
|
||
keys = self.attrs.keys() | ||
|
@@ -70,7 +90,3 @@ def xml(self): | |
el.append(verb.xml()) | ||
|
||
return el | ||
|
||
def append(self, verb): | ||
self.verbs.append(verb) | ||
return self |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a message like "can't nest responses".