def test_add(self): """ 测试 添加信息 """ print self.test_add.__doc__.strip() from app.tools.db import add from app.models import User # 测试正确的场景 user_info = { 'email': '*****@*****.**', 'password': '******', 'nickname': 'Bob', } result = add(User, user_info) assert result == 4 # 测试错误的场景 user_info = { 'email': '*****@*****.**', 'password': '******', # 'nickname': 'Error', } try: result = add(User, user_info) except Exception as e: assert e.message == '(sqlite3.IntegrityError) NOT NULL constraint failed: user.nickname' assert result == 4
def add_user_auth(user_auth_data): """ 添加用户信息 :param user_auth_data: :return: None/Value of user.id """ return add(UserAuth, user_auth_data)
def add_blog(blog_data): """ 添加博客信息 :param blog_data: :return: None/Value of blog.id """ return add(Blog, blog_data)
def add_user(user_data): """ 添加用户信息 :param user_data: :return: None/Value of user.id """ return add(LoginUser, user_data)
def add_author(author_data): """ 添加博客信息 :param author_data: :return: None/Value of author.id """ return add(Author, author_data)