当前位置: 首页>>代码示例>>Python>>正文


Python User.delete方法代码示例

本文整理汇总了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)
开发者ID:aviatorBeijing,项目名称:ptpy,代码行数:9,代码来源:user.py

示例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)
开发者ID:Modulus,项目名称:FlaskDemo,代码行数:13,代码来源:user_resource_test.py

示例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({})
开发者ID:jiajunhuang,项目名称:graduation,代码行数:14,代码来源:user.py

示例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)

#.........这里部分代码省略.........
开发者ID:aldarionsevero,项目名称:BusinemeWeb,代码行数:103,代码来源:test_user.py

示例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')
开发者ID:r4mp,项目名称:mete_python_cherrypy_jinja2,代码行数:5,代码来源:users.py


注:本文中的models.user.User.delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。