Example #1
0
        response = self.call(path="/inbound")
        self.assertTwiML(response)

    def test_sms(self):
        response = self.sms("Test")
        self.assertTwiML(response)


########NEW FILE########
__FILENAME__ = test_web
import unittest

from .context import app

app.config["TWILIO_ACCOUNT_SID"] = "ACxxxxxx"
app.config["TWILIO_AUTH_TOKEN"] = "yyyyyyyyy"
app.config["TWILIO_CALLER_ID"] = "+15558675309"
app.config["IOS_URI"] = "http://itunes.apple.com/us/app/plants-vs.-zombies/id350642635?mt=8&uo=4"
app.config["ANDROID_URI"] = "http://market.android.com/details?id=com.popcap.pvz_row"
app.config["WEB_URI"] = "http://www.popcap.com/games/plants-vs-zombies/pc"


class WebTest(unittest.TestCase):
    def setUp(self):
        self.app = app.test_client()


class IndexTests(WebTest):
    def test_index(self):
        response = self.app.get("/")
        self.assertEqual("200 OK", response.status)
Example #2
0
# Imports.
import os
from flask import flash, Flask, render_template, request, url_for
from flask.ext.twilio import Twilio, Response
from twilio.rest.exceptions import TwilioRestException
from jinja2 import DictLoader

# A standard test number.
# See https://www.twilio.com/docs/api/rest/test-credentials.
DEFAULT_NUMBER = "+15005550006"

# Application configuration.
app = Flask(__name__)
app.config["SECRET_KEY"] = os.urandom(24)
app.config["TWILIO_ACCOUNT_SID"] = os.environ["TWILIO_ACCOUNT_SID"]
app.config["TWILIO_AUTH_TOKEN"] = os.environ["TWILIO_AUTH_TOKEN"]
app.config["TWILIO_FROM"] = os.environ.get("TWILIO_FROM", DEFAULT_NUMBER)
twilio = Twilio(app)

# Main form template.
app.jinja_loader = DictLoader(
    {
        "example.html": """\
<!doctype html>
<title>Flask-Twilio Test</title>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<br>
<div class=container>