class TestCase(unittest.TestCase):
session = None
def setUp(self):
self.app = create_app()
self.app.testing = True
###########################################################
# TODO: change settings
# import tempfile
# self.app.config['DATABASE'] = tempfile.mkstemp()
###########################################################
self.client = self.app.test_client()
self.login_required() def login_required(self):
rv = self.client.post('/login', data=dict(
account=PHONE,
password=PASSWORD
))
cookies = rv.headers.getlist('Set-Cookie')
session = parse_cookie(cookies[0])['session']
self.client.set_cookie('localhost', 'session', session)