8000 Next gen twiml by jingming · Pull Request #316 · twilio/twilio-python · GitHub
[go: up one dir, main page]

Skip to content

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 8 commits into from
Mar 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
593 changes: 0 additions & 593 deletions tests/unit/test_twiml.py

This file was deleted.

16 changes: 16 additions & 0 deletions tests/unit/twiml/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +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')
78 changes: 78 additions & 0 deletions tests/unit/twiml/test_messaging_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
from nose.tools import assert_equal
from tests.unit.twiml import TwilioTest
from twilio.twiml.messaging_response import MessagingResponse, Body, Media


class TestResponse(TwilioTest):

def test_empty_response(self):
r = MessagingResponse()
assert_equal(
self.strip(r),
'<?xml version="1.0" encoding="UTF-8"?><Response />'
)

def test_response(self):
r = MessagingResponse()
r.message('Hello')
r.redirect(url='example.com')

assert_equal(
self.strip(r),
'<?xml version="1.0" encoding="UTF-8"?><Response><Message>Hello</Message><Redirect url="example.com" /></Response>'
)

def test_response_chain(self):
r = MessagingResponse().message('Hello').redirect(url='example.com')

assert_equal(
self.strip(r),
'<?xml version="1.0" encoding="UTF-8"?><Response><Message>Hello</Message><Redirect url="example.com" /></Response>'
)


class TestMessage(TwilioTest):

def test_body(self):
r = MessagingResponse()
r.message('Hello')

assert_equal(
self.strip(r),
'<?xml version="1.0" encoding="UTF-8"?><Response><Message>Hello</Message></Response>'
)

def test_nested_body(self):
b = Body('Hello World')

r = MessagingResponse()
r.append(b)

assert_equal(
self.strip(r),
'<?xml version="1.0" encoding="UTF-8"?><Response><Body>Hello World</Body></Response>'
)

def test_nested_body_media(self):
b = Body('Hello World')
m = Media('hey.jpg')

r = MessagingResponse()
r.append(b)
r.append(m)

assert_equal(
self.strip(r),
'<?xml version="1.0" encoding="UTF-8"?><Response><Body>Hello World</Body><Media>hey.jpg</Media></Response>'
)


class TestRedirect(TwilioTest):
def test_redirect(self):
r = MessagingResponse()
r.redirect(url='example.com')

assert_equal(
self.strip(r),
'<?xml version="1.0" encoding="UTF-8"?><Response><Redirect url="example.com" /></Response>'
)
Loading
0