示例#1
0
 def test_valid_configuration(self):
     cleaver = Cleaver({}, FakeIdentityProvider(), SQLAlchemyBackend())
     assert isinstance(cleaver._identity, FakeIdentityProvider)
     assert isinstance(cleaver._backend, SQLAlchemyBackend)
示例#2
0
 def setUp(self):
     self.b = SQLAlchemyBackend()
示例#3
0
from cleaver.reports.web import CleaverWebUI
from cleaver.backend.db import SQLAlchemyBackend

app = CleaverWebUI(SQLAlchemyBackend('sqlite:///experiment.data'))

from wsgiref import simple_server
print "Serving at 0.0.0.0:8081"
simple_server.make_server('', 8081, app).serve_forever()
示例#4
0
from flask import Flask, request
from cleaver import SplitMiddleware
from cleaver.backend.db import SQLAlchemyBackend

app = Flask(__name__)
app.wsgi_app = SplitMiddleware(
    app.wsgi_app,
    lambda environ: environ['HTTP_USER_AGENT'],  # Track by browser
    SQLAlchemyBackend('sqlite:///experiment.data'))

template = """
    <form method="POST" action="/register">
        <button>%s</button>
    </form>
"""


@app.route("/")
def home():
    # Visiting / in a web browser will render a button
    return template % (request.environ['cleaver'](
        'call-to-action', ('control', 'Click Here, Dummy!'),
        ('test', 'Free Puppies!')))


@app.route("/register", methods=['POST'])
def register():
    # Submitting the form will go to /register to display a thank-you
    request.environ['cleaver'].score('call-to-action')
    return "Thanks for Signing Up!"
示例#5
0
 def setUp(self):
     self.b = SQLAlchemyBackend('sqlite://')