def test_valid_configuration(self): cleaver = Cleaver({}, FakeIdentityProvider(), SQLAlchemyBackend()) assert isinstance(cleaver._identity, FakeIdentityProvider) assert isinstance(cleaver._backend, SQLAlchemyBackend)
def setUp(self): self.b = SQLAlchemyBackend()
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()
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!"
def setUp(self): self.b = SQLAlchemyBackend('sqlite://')