Created
November 10, 2012 01:38
-
-
Save octaflop/4049431 to your computer and use it in GitHub Desktop.
Flask sqlalchemy declarative db configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import someapp as j | |
| from someapp.db.database import init_db, drop_db | |
| import unittest | |
| import fixtures | |
| from BeautifulSoup import BeautifulSoup as bs | |
| appurl = "/api/%s" | |
| header = { "content-type": "application/json" } | |
| class JoyHikeDBCase(unittest.TestCase): | |
| test_user1 = { | |
| 'username': 'wxillixxaxxmm3', | |
| 'email': 'wixlm3@soxxxuthpark.com', | |
| 'password': 'pxmwerxxxs3' | |
| } | |
| def create_app(self): | |
| j.app.config['TESTING'] = True | |
| from joyhikeserve.db.testdatabase import dburi as testdburi | |
| from joyhikeserve.db.testdatabase import engine as testengine | |
| self.dburi = testdburi | |
| self.engine = testengine | |
| j.app.config['DATABASE'] = self.dburi | |
| j.app.config['SQLALCHEMY_DATABASE_URI'] = self.dburi | |
| self.app = j.app.test_client() | |
| def setUp(self): | |
| self.create_app() | |
| drop_db() # clear anything else in the db | |
| init_db() | |
| fixtures.install(self.engine, *fixtures.all_data) | |
| from joyhikeserve.db.testdatabase import db_session as testsession | |
| self.session = testsession | |
| def tearDown(self): | |
| drop_db() | |
| self.session.remove() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment