Example #1
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"))
Example #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("engine").connect())
Example #3
0
    def makeService(self, options):
        greatPath = FilePath(great.__file__).parent()
        staticPath = greatPath.child("static")
        templatesPath = greatPath.child("templates")

        rootResource = Resource()
        rootResource.putChild("", File(staticPath.child("index.html").path))
        rootResource.putChild("static", File(staticPath.path))
        rootResource.putChild("templates", File(templatesPath.path))

        rootResource.putChild("great", MinionResource(create_app()))

        greatService = StreamServerEndpointService(
            endpoint=options["endpoint"],
            factory=server.Site(rootResource),
        )

        redirects = options["redirects"]
        if not redirects:
            return greatService

        service = MultiService()
        greatService.setServiceParent(service)

        for redirect in redirects:
            redirectService = StreamServerEndpointService(
                endpoint=redirect,
                factory=server.Site(Redirect(options["canonical_url"])),
            )
            redirectService.setServiceParent(service)

        return service
Example #4
0
File: tap.py Project: Julian/Great
def makeService(options):
    if options["migrate"]:
        root = Path.from_string(__file__).sibling("alembic")
        alembic_config = alembic.config.Config(
            str(root.descendant("config.ini")),
        )
        alembic.command.upgrade(alembic_config, "head")

    greatPath = Path.from_string(great.__file__).parent()
    staticPath = greatPath.descendant("static")
    templatesPath = greatPath.descendant("templates")

    rootResource = twisted.web.resource.Resource()
    rootResource.putChild("", File(str(staticPath.descendant("index.html"))))
    rootResource.putChild("static", File(str(staticPath)))
    rootResource.putChild("api", MinionResource(create_app()))

    site = server.Site(rootResource)
    return strports.service(description=options["port"], factory=site)