def setup(): """ iniate bot_controller """ user.load_user_data() auth_token = user.get_user_token(os.getenv('TEST_USER')) groupware.load_project_list(auth_token) print('PROJECT_LIST:', groupware.PROJECT_LIST) print('user.ALIAS:', user.ALIAS)
def test_auth_custom_password(self): test_password = '******' query_insert = sqlalchemy.text( 'INSERT INTO users (username, password) VALUES (:username, :password)' ) db.get_conn().execute(query_insert, username=self.testuser, password=test_password) user.load_user_data() with self.assertRaises(Exception): user.get_user_token(self.testuser) query_delete = sqlalchemy.text( 'DELETE FROM users WHERE ((username = :username))') db.get_conn().execute(query_delete, username=self.testuser) user.load_user_data()
def test_auth_duplicate_alias(self): test_alias = 'dummy_alias' query_insert = sqlalchemy.text( 'INSERT INTO users (username, password, alias) VALUES (:username, :password, :alias)' ) db.get_conn().execute(query_insert, username=self.testuser, password=self.testuser, alias=test_alias) user.load_user_data() # make sure alias exists self.assertIsNotNone(user.get_user_token(test_alias)) # test adding alias res = user.set_alias(self.testuser, test_alias) self.assertFalse(res[0]) query_delete = sqlalchemy.text( 'DELETE FROM users WHERE ((username = :username))') db.get_conn().execute(query_delete, username=self.testuser)
def test_auth_custom_alias(self): test_alias = 'dummy_alias' query_insert = sqlalchemy.text( 'INSERT INTO users (username, password) VALUES (:username, :password)' ) db.get_conn().execute(query_insert, username=self.testuser, password=self.testuser) user.load_user_data() # make sure alias not exists yet self.assertIsNotNone(user.get_user_token(self.testuser)) with self.assertRaises(Exception): user.get_user_token(test_alias) # test adding alias user.set_alias(self.testuser, test_alias) self.assertIsNotNone(user.get_user_token(test_alias)) query_delete = sqlalchemy.text( 'DELETE FROM users WHERE ((username = :username))') db.get_conn().execute(query_delete, username=self.testuser)