2021-07-16 15:51:06 +00:00
|
|
|
import os
|
|
|
|
from nanoid import generate
|
|
|
|
|
|
|
|
from flask_testing import TestCase
|
|
|
|
|
|
|
|
from capsulflask import create_app
|
2021-07-17 09:42:44 +00:00
|
|
|
from capsulflask.db import get_model
|
2021-07-16 15:51:06 +00:00
|
|
|
|
|
|
|
class BaseTestCase(TestCase):
|
|
|
|
def create_app(self):
|
|
|
|
# Use default connection paramaters
|
|
|
|
os.environ['POSTGRES_CONNECTION_PARAMETERS'] = "host=localhost port=5432 user=postgres password=dev dbname=capsulflask_test"
|
|
|
|
os.environ['TESTING'] = '1'
|
2021-07-27 17:48:48 +00:00
|
|
|
os.environ['LOG_LEVEL'] = 'DEBUG'
|
2021-07-16 15:51:06 +00:00
|
|
|
os.environ['SPOKE_MODEL'] = 'mock'
|
2021-07-27 17:48:48 +00:00
|
|
|
os.environ['HUB_MODEL'] = 'capsul-flask'
|
2021-07-16 15:51:06 +00:00
|
|
|
return create_app()
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def _login(self, user_email):
|
2021-07-17 09:42:44 +00:00
|
|
|
get_model().login(user_email)
|
2021-07-16 15:51:06 +00:00
|
|
|
with self.client.session_transaction() as session:
|
|
|
|
session['account'] = user_email
|
|
|
|
session['csrf-token'] = generate()
|