Example #1
0
    def create_app(self):
        views.app.config['TESTING'] = True
        views.app.config['FIXTURES_DIRS'] = [os.environ.get('FIXTURES_DIR')]
        views.app.config[
            'SQLALCHEMY_DATABASE_URI'] = 'postgresql://%s:%s@%s:%s/%s' % (
                self.db_cfg['DB_USER'], self.s_db_cfg['DB_PASS'],
                self.db_cfg['DB_HOST'], self.db_cfg['DB_PORT'],
                self.db_cfg['TEST_DB_NAME'])

        FixturesMixin.init_app(views.app, db)

        return views.app
Example #2
0
import inspect
import os
import sys
import unittest

from myapp import app
from myapp.models import db, Book, Author

from flask.ext.fixtures import FixturesMixin
from flask.ext.fixtures.utils import can_persist_fixtures

# Configure the app with the testing configuration
app.config.from_object('myapp.config.TestConfig')

# Initialize the Flask-Fixtures mixin class
FixturesMixin.init_app(app, db)

# The setUpClass and tearDownClass methods were added to unittest.TestCase in
# python 2.7, so if we're running a version of python below that this test
# will fail. So, make sure we only run the test with python 2.7 or greater.
if can_persist_fixtures():

    class TestPersistFixtures(unittest.TestCase, FixturesMixin):

        # Specify the fixtures file(s) you want to load
        fixtures = ['authors.json']
        persist_fixtures = True

        @classmethod
        def setUpClass(self):
            # Make sure we start out with 1 author and 3 books
import inspect
import os
import sys
import unittest

from myapp import app
from myapp.models import db, Book, Author

from flask.ext.fixtures import FixturesMixin
from flask.ext.fixtures.utils import can_persist_fixtures

# Configure the app with the testing configuration
app.config.from_object('myapp.config.TestConfig')

# Initialize the Flask-Fixtures mixin class
FixturesMixin.init_app(app, db)


# The setUpClass and tearDownClass methods were added to unittest.TestCase in
# python 2.7, so if we're running a version of python below that this test
# will fail. So, make sure we only run the test with python 2.7 or greater.
if can_persist_fixtures():

    class TestPersistFixtures(unittest.TestCase, FixturesMixin):

        # Specify the fixtures file(s) you want to load
        fixtures = ['authors.json']
        persist_fixtures = True

        @classmethod
        def setUpClass(self):
Example #4
0
    def create_app(self):
        app = create_app('testing')
        FixturesMixin.init_app(app, db)

        return app
Example #5
0
import unittest
import flask.ext.testing

from flask.ext.testing import TestCase
from flask.ext.testing import Twill
from flask.ext.fixtures import FixturesMixin


from app import app
from config import TestingConfig


FixturesMixin.init_app(app)

class PortalTestBase(TestCase, FixturesMixin):
    """Base TestClass for your application."""

    fixtures = ['channels.yaml']

    def create_app(self):
        """Create and return a testing flask app."""

        app.config.from_object(TestingConfig)
        self.twill = Twill(app, port=3000)
        return app

    def setUp(self):
        pass

    def tearDown(self):
        pass