def client(): app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///database_test.db' app.config['TESTING'] = True with app.test_client() as client: with app.app_context(): init_db() yield client
def setUp(self): self.bd_tp, application.app.config['DATABASE'] = tempfile.mktemp() application.app.config['TESTING'] = True self.app = application.app.test_client() with application.app.app_context(): application.init_db() pass
def app(): """Create and configure a new app instance for each test.""" # create the app with common test config app = create_app({ "TESTING": True, "SQLALCHEMY_DATABASE_URI": "sqlite:///:memory:" }) with app.app_context(): init_db() yield app
def client(): db_fd, appl.app.config['DATABASE'] = tempfile.mkstemp() appl.app.config['TESTING'] = True client = appl.app.test_client() with appl.app.app_context(): appl.init_db() yield client os.close(db_fd) os.unlink(appl.app.config['DATABASE'])
def setUp(self): app.config['testing'] = True app.config['WTF_CSRF_ENABLED'] = False app.debug = True app.secret_key = "something_secret" app.testing = True self.app = app.test_client() init_db('sqlite://') # login session query = dict(state='testingstate') self.app.post('/fbconnect', query_string=query, data='testytesttest') with open(test_image_name_1, 'r') as test_image: self.image_string = StringIO(test_image.read()) with open(test_image_name_2, 'r') as test_image2: self.image2_string = StringIO(test_image2.read()) del test_image del test_image2
def test_init_db_initialises_db_with_one_video(app, client): with app.app_context(): init_db() videos = Video.query.all() assert videos[1].title == "DreamHackCS"
from application import init_db, db_session init_db() import application test_app = application.app.test_client() def teardown(): db_session.remove()
def setUp(self): application.init_db() self.driver = webdriver.Firefox()