Skip to content
Permalink
Browse files
Setup app for testing
  • Loading branch information
brogand93 committed May 31, 2014
1 parent 1639b96 commit 1a5ee54aae199f2a8cd6ed2bfe4e1a87086bda5b
Showing 4 changed files with 40 additions and 5 deletions.
@@ -26,6 +26,7 @@ pip-log.txt

# Unit test / coverage reports
.coverage
cover
.tox
nosetests.xml

@@ -36,12 +36,16 @@ def _load_config_file():
return config_file


def configure_app():
config_file = _load_config_file()
app.config.from_pyfile(config_file)
def configure_app(settings=None):
app.config['DATA'] = os.path.abspath(os.path.dirname(__file__)) + '/data'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + \
os.path.join(app.config['DATA'], 'app.db')

if settings:
app.config.from_object(settings)
else:
config_file = _load_config_file()
app.config.from_pyfile(config_file)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + \
os.path.join(app.config['DATA'], 'app.db')


app = Flask(__name__)
@@ -1,8 +1,29 @@
#!/usr/bin/env python
# encoding: utf-8

from unittest import TestCase

from gstack import app, configure_app
from . import settings
from .utils import FlaskTestCaseMixin

class GStackTestCase(TestCase):
pass

class GStackAppTestCase(FlaskTestCaseMixin, GStackTestCase):

def _configure_app(self):
configure_app(settings=settings)

def setUp(self):
super(GStackTestCase, self).setUp()
self._configure_app()
self.app = app
self.client = self.app.test_client()
self.app_context = self.app.app_context()
self.app_context.push()

def tearDown(self):
super(GStackTestCase, self).tearDown()
self.app_context.pop()

@@ -0,0 +1,9 @@
#!/usr/bin/env python
# encoding: utf-8

from . import GStackAppTestCase

class SampleTestCase(GStackAppTestCase):

def test_sample(self):
pass

0 comments on commit 1a5ee54

Please sign in to comment.