use application factory, WIP
This commit is contained in:
parent
e6bc4928c9
commit
38e5ef85c0
17 changed files with 200 additions and 120 deletions
|
@ -42,7 +42,6 @@ class HookMixin(object):
|
|||
return f
|
||||
return outer
|
||||
|
||||
|
||||
@classmethod
|
||||
def before(cls, method_name):
|
||||
def outer(f, *args, **kwargs):
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import json
|
||||
from realms import db
|
||||
from sqlalchemy import not_
|
||||
from datetime import datetime
|
||||
from flask.ext.sqlalchemy import SQLAlchemy
|
||||
|
||||
db = SQLAlchemy()
|
||||
|
||||
|
||||
class Model(db.Model):
|
||||
|
|
19
realms/lib/test.py
Normal file
19
realms/lib/test.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
from flask.ext.testing import TestCase
|
||||
from realms.lib.util import random_string
|
||||
from realms import create_app
|
||||
from subprocess import call
|
||||
|
||||
|
||||
class BaseTest(TestCase):
|
||||
|
||||
def create_app(self):
|
||||
app = create_app()
|
||||
app.config['TESTING'] = True
|
||||
app.config['PRESERVE_CONTEXT_ON_EXCEPTION'] = False
|
||||
app.config['WIKI_PATH'] = '/tmp/%s' % random_string(12)
|
||||
app.config['DB_URI'] = 'sqlite:////tmp/%s.db' % random_string(12)
|
||||
return app
|
||||
|
||||
def tearDown(self):
|
||||
call(['rm', '-rf', self.app.config['WIKI_PATH']])
|
||||
call(['rm', '-f', self.app.config['DB_URI'][10:]])
|
|
@ -1,3 +1,4 @@
|
|||
import click
|
||||
import re
|
||||
import os
|
||||
import hashlib
|
||||
|
@ -109,6 +110,18 @@ def is_su():
|
|||
return os.geteuid() == 0
|
||||
|
||||
|
||||
def green(s):
|
||||
click.secho(s, fg='green')
|
||||
|
||||
|
||||
def yellow(s):
|
||||
click.secho(s, fg='yellow')
|
||||
|
||||
|
||||
def red(s):
|
||||
click.secho(s, fg='red')
|
||||
|
||||
|
||||
def upstart_script(user='root', app_dir=None, port=5000, workers=2, path=None):
|
||||
script = """
|
||||
limit nofile 65335 65335
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue