本文整理汇总了Python中models.user.User.delete方法的典型用法代码示例。如果您正苦于以下问题:Python User.delete方法的具体用法?Python User.delete怎么用?Python User.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.user.User
的用法示例。
在下文中一共展示了User.delete方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import delete [as 别名]
def get(self,key):
user = User()
userInfo = UserInfo()
avatar =Avatar()
user.delete(key)
userInfo.delete(key)
avatar.delete(key)
示例2: testRawUserSave
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import delete [as 别名]
def testRawUserSave(self):
user = User(firstName="John", lastName="Skauge", userName="John", password="MyPassword")
# noinspection PyUnresolvedReferences
self.assertFalse(user.id)
user.save()
self.assertTrue(user.id)
user.delete()
#this will throw a DoesNotExist error, hence the @unittest.expectedFailure
user = User.objects.get(id=user.id)
示例3: delete
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import delete [as 别名]
def delete(self, uid):
"""
@apiDescription 删除用户信息
@api {delete} /user/([0-9]+)/? 删除用户信息
@api {delete} /shop/([0-9]+)/? 删除商家信息
@apiGroup user
@apiGroup shop
@apiPermission user
"""
User.delete(self.orm_session, uid)
self.write({})
示例4: UserControllerTest
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import delete [as 别名]
class UserControllerTest(SimpleTestCase):
def setUp(self):
self.client = Client()
def create_user(self):
self.user = User()
self.user.username = 'test_username'
self.user.password = 'test_password'
self.user.name = 'test_name'
self.user.email = '[email protected]'
self.user.save()
def register_post_data(self, name, email, username, password):
data = {'name': name,
'email': email,
'username': username,
'password': password}
return data
def login_post_data(self):
data = {'username': 'test_user',
'password': '1234'}
return data
def new_password(self):
data = {'password': '4321'}
return data
def test_register_user_duplicate_email(self):
data1 = self.register_post_data(
'test_user1', '[email protected]', 'test_user1', '1234')
data2 = self.register_post_data(
'test_user2', '[email protected]', 'test_user2', '1234')
response1 = self.client.post('/cadastrar/usuario/', data1, follow=True)
response2 = self.client.post('/cadastrar/usuario/', data2, follow=True)
self.assertEquals(
response1.redirect_chain, [('http://testserver/login/', 302)])
self.assertEquals(
response2.redirect_chain, [])
self.assertEquals(response1.status_code, STATUS_OK)
self.assertEquals(response2.status_code, STATUS_OK)
def test_register_user_invalid_email(self):
data = self.register_post_data(
'test_user2', 'testemail.com', 'test_user2', '1234')
response = self.client.post('/cadastrar/usuario/', data, follow=True)
self.assertEquals(response.redirect_chain, [])
self.assertEquals(response.status_code, STATUS_OK)
def test_register_user_invalid_username(self):
data1 = self.register_post_data(
'test_user1', '[email protected]', 'test_user_same', '1234')
data2 = self.register_post_data(
'test_user2', '[email protected]', 'test_user_same', '1234')
response1 = self.client.post('/cadastrar/usuario/', data1, follow=True)
response2 = self.client.post('/cadastrar/usuario/', data2, follow=True)
self.assertEquals(
response1.redirect_chain, [('http://testserver/login/', 302)])
self.assertEquals(
response2.redirect_chain, [])
self.assertEquals(response1.status_code, STATUS_OK)
self.assertEquals(response2.status_code, STATUS_OK)
def test_register_user_page(self):
response = self.client.get('/cadastro/')
self.assertEquals(response.status_code, STATUS_OK)
def test_register_user_success_status_code(self):
data = self.register_post_data(
'test_user', '[email protected]', 'test_user', '1234')
response = self.client.post('/cadastrar/usuario/', data)
self.assertEquals(response.status_code, STATUS_OK)
def test_register_user_success_db(self):
data = self.register_post_data(
'test_user', '[email protected]', 'test_user', '1234')
db_before = User.objects.all().count()
self.client.post('/cadastrar/usuario/', data)
db_after = User.objects.all().count()
self.assertTrue(db_after > db_before)
def test_loged_user(self):
self.create_user()
self.client.login(username='test_username', password='test_password')
response = self.client.get('/login/')
self.assertEquals(response.status_code, STATUS_OK)
self.client.logout()
self.user.delete()
def test_logout_user(self):
response = self.client.get('/login/?next=/sair/')
self.assertEquals(response.status_code, STATUS_OK)
def test_user_account(self):
response = self.client.get('/perfil/')
self.assertEquals(response.status_code, STATUS_REDIRECT)
#.........这里部分代码省略.........
示例5: delete
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import delete [as 别名]
def delete(self, id = 0):
User.delete(cherrypy.request.db, int(id))
raise cherrypy.HTTPRedirect('/users')