2016-08-20 01:48:00 +03:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2016-07-06 03:29:36 +03:00
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
import tempfile
|
2016-08-20 01:48:00 +03:00
|
|
|
|
2016-07-15 00:59:08 +03:00
|
|
|
from flask_testing import TestCase
|
2016-08-20 01:48:00 +03:00
|
|
|
|
2014-10-22 00:06:27 +03:00
|
|
|
from realms import create_app
|
2016-09-05 00:25:55 +03:00
|
|
|
from realms.lib.util import random_string
|
2014-10-22 00:06:27 +03:00
|
|
|
|
|
|
|
|
|
|
|
class BaseTest(TestCase):
|
|
|
|
|
|
|
|
def create_app(self):
|
2016-07-06 03:29:36 +03:00
|
|
|
self.tempdir = tempfile.mkdtemp()
|
2014-10-22 00:06:27 +03:00
|
|
|
app = create_app()
|
|
|
|
app.config['TESTING'] = True
|
|
|
|
app.config['PRESERVE_CONTEXT_ON_EXCEPTION'] = False
|
2016-07-06 03:29:36 +03:00
|
|
|
app.config['WIKI_PATH'] = os.path.join(self.tempdir, random_string(12))
|
|
|
|
app.config['DB_URI'] = 'sqlite:///%s/%s.db' % (self.tempdir, 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):
|
2016-07-06 03:29:36 +03:00
|
|
|
shutil.rmtree(self.tempdir)
|