Exemple #1
0
 def get(self, url, headers):
     app = TestApp(wsgi.create_app(self.minion))
     response = app.get(
         url,
         headers=[(k, ",".join(v)) for k , v in headers.canonicalized()],
     )
     return response.body
Exemple #2
0
    def setUp(self):
        super(ApplicationTestMixin, self).setUp()
        self.config = {"db" : {"url" : "sqlite://"}}
        self.great = create_app(config=self.config)
        self.app = TestApp(wsgi.create_app(self.great))

        METADATA.create_all(self.great.bin.provide("db"))
Exemple #3
0
 def get(self, url, headers):
     app = TestApp(wsgi.create_app(self.minion))
     response = app.get(
         url,
         headers=[(k, b",".join(v)) for k, v in headers.canonicalized()],
     )
     return response.body
Exemple #4
0
    def setUp(self):
        super(ApplicationTestMixin, self).setUp()
        self.config = {"db": {"url": "sqlite://"}}
        self.great = create_app(config=self.config)
        self.app = TestApp(wsgi.create_app(self.great))

        METADATA.create_all(self.great.bin.provide("engine").connect())
Exemple #5
0
 def test_script_name(self):
     self.minion.route(b"/home")(lambda request : Response(b"Hi!"))
     app = TestApp(
         wsgi.create_app(self.minion),
         extra_environ={"SCRIPT_NAME" : "/app"},
     )
     response = app.get(b"/app/home")
     self.assertEqual(response.body, b"Hi!")
Exemple #6
0
 def test_script_name(self):
     self.minion.route(b"/home")(lambda request: Response(b"Hi!"))
     app = TestApp(
         wsgi.create_app(self.minion),
         extra_environ={"SCRIPT_NAME": "/app"},
     )
     response = app.get(b"/app/home")
     self.assertEqual(response.body, b"Hi!")
Exemple #7
0
 def setUp(self):
     self.minion = Application()
     self.wsgi = TestApp(wsgi.create_app(self.minion))
Exemple #8
0
@app.bin.provides("db")
@app.bin.needs(["config"])
def connect_db(config):
    """Connects to the specific database."""
    rv = sqlite3.connect(config["database"]["uri"])
    rv.row_factory = sqlite3.Row
    return rv


def init_db():
    """Creates the database tables."""
    with closing(connect_db()) as db:
        db.cursor().execute("DROP TABLE IF EXISTS entries")
        db.cursor().execute(
            """
            CREATE TABLE entries (
                id INTEGER PRIMARY KEY AUTOINCREMENT,
                title TEXT NOT NULL,
                text TEXT NOT NULL
            )
            """
        )
        db.commit()


wsgi = create_app(app)


if __name__ == "__main__":
    init_db()
Exemple #9
0
from minion.core import Application
from minion.request import Response
from minion.routing import Router, RoutesMapper
from minion.wsgi import create_app

app = Application(router=Router(mapper=RoutesMapper()))


@app.route("/greet/{user}", greeting="Hey")
def greet(request, greeting, user):
    return Response("{} {}\n".format(greeting, user).encode("utf-8"))


wsgi = create_app(app)
Exemple #10
0
 def setUp(self):
     self.minion = Application()
     self.wsgi = TestApp(wsgi.create_app(self.minion))