本文整理汇总了Python中models.users.Users.new方法的典型用法代码示例。如果您正苦于以下问题:Python Users.new方法的具体用法?Python Users.new怎么用?Python Users.new使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.users.Users
的用法示例。
在下文中一共展示了Users.new方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testAdd
# 需要导入模块: from models.users import Users [as 别名]
# 或者: from models.users.Users import new [as 别名]
def testAdd(self):
users = Users()
before_count = len(users.all())
self.assertTrue(users.add(users.new(), persist=False))
after_count = len(users.all())
self.assertGreater(after_count, before_count)
self.assertEqual(before_count + 1, after_count)
示例2: test_InsertQuery
# 需要导入模块: from models.users import Users [as 别名]
# 或者: from models.users.Users import new [as 别名]
def test_InsertQuery(self):
users = Users()
entity = users.new()
expected = OrderedDict([
('id', None), ('user_group', 'user'), ('username', None),
('name', None), ('email', None), ('password', None),
('virt_auth_data', None)
])
data = users._generate_query_data(entity)
self.assertEqual(expected, data)
expected = 'INSERT INTO users(id,user_group,username,name,email,password,virt_auth_data) VALUES (?,?,?,?,?,?,?)'
self.assertEqual(users._generate_insert_query(data), expected)
示例3: testDelete
# 需要导入模块: from models.users import Users [as 别名]
# 或者: from models.users.Users import new [as 别名]
def testDelete(self):
users = Users()
entity = users.new()
expected = 'DELETE FROM users WHERE id = ?'
self.assertEqual(users._generate_delete_query(entity.name), expected)
示例4: testNew
# 需要导入模块: from models.users import Users [as 别名]
# 或者: from models.users.Users import new [as 别名]
def testNew(self):
users = Users()
self.assertIsInstance(users.new(), User)
e = users.new(name="lol")
self.assertEqual(e.name, 'lol')
示例5: testFirst
# 需要导入模块: from models.users import Users [as 别名]
# 或者: from models.users.Users import new [as 别名]
def testFirst(self):
users = Users()
self.assertEqual(users.first(), None)
entity = users.new()
users.add(entity, persist=False)
self.assertEqual(users.first(), entity)