2014-10-22 00:06:27 +03:00
|
|
|
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)
|
2014-10-22 23:38:32 +03:00
|
|
|
app.config.update(self.configure())
|
2014-10-22 00:06:27 +03:00
|
|
|
return app
|
|
|
|
|
2014-10-22 23:38:32 +03:00
|
|
|
def configure(self):
|
|
|
|
return {}
|
|
|
|
|
2014-10-22 00:06:27 +03:00
|
|
|
def tearDown(self):
|
|
|
|
call(['rm', '-rf', self.app.config['WIKI_PATH']])
|
2014-11-17 19:25:26 +02:00
|
|
|
call(['rm', '-f', self.app.config['DB_URI'][10:]])
|