def setUp(self): self.app = app.test_client() # creates a test client self.app.testing = True #library = Library('Детскя библиотека №28') app.secret_key = 'strong SecReT Key 123123123!' #app.config['SESSION_TYPE'] = 'filesystem' # http://stackoverflow.com/a/26080974 login_manager = LoginManager() login_manager.init_app(app) login_manager.login_view = 'login'
def setUp(self): file_handler_log = FileHandler('tests_error.log') file_handler_log.setLevel(WARNING) file_handler_log.setFormatter(Formatter("%(name)s - %(levelname)s - %(asctime)s - %(message)s")) app.logger.addHandler(file_handler_log) #self.app.secret_key = 'strong SecReT Key 123123123!' app.secret_key = 'strong SecReT Key 123123123!' self.app = app.test_client() # creates a test client self.app.testing = True #self.app.trace = True db_file_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "library.db") library = Library('Тестовая библиотека №28', db_file_path) #admin = Librarian("test_admin", "Admin Ivanov", "12345678", 2, email="*****@*****.**", phone="+7-495-5555555") #print("Librarians before commit: {}".format(self.library.session.query(Librarian).filter_by(user='******'))) """ if not self.library.session.query(Librarian).filter_by(user_name='test_user').first(): self.user = Librarian("test_user", "User Userovich", "12345678", 1, email="*****@*****.**", phone="+7-495-5555555") self.library.session.add(self.user) self.library.session.commit() """ #print("Librarians after commit: {}".format(self.library.session.query(Librarian).all())) #def __init__(self, user_name, real_name, password, status=1, email=None, personal_info=None, phone=None, # address=None): #self.app.config['SESSION_TYPE'] = 'filesystem' # http://stackoverflow.com/a/26080974 login_manager = LoginManager() login_manager.init_app(app) login_manager.login_view = 'login' #resp = self.app.post('/login', data=dict(user_name='test_user', password="******")) resp = self.app.post('/login', data=dict(user_name='test2', password="******")) print("App: {}".format(dir(self.app))) #print("App Trace: {}".format(self.app.trace())) print("Login resp status: {} - {}".format(resp.status_code, resp.data))