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


Python User.delete方法代码示例

本文整理汇总了Python中payments.models.User.delete方法的典型用法代码示例。如果您正苦于以下问题:Python User.delete方法的具体用法?Python User.delete怎么用?Python User.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在payments.models.User的用法示例。


在下文中一共展示了User.delete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_index_handles_logged_in_user

# 需要导入模块: from payments.models import User [as 别名]
# 或者: from payments.models.User import delete [as 别名]
    def test_index_handles_logged_in_user(self):
        #create a session that appears to have a logged in user
        self.request.session = {"user": "1"}

        #setup dummy user
        #we need to save user so user -> badges relationship is created
        u = User(email="[email protected]")
        u.save()

        with mock.patch('main.views.User') as user_mock:

            #tell the mock what to do when called
            config = {'get_by_id.return_value': u}
            user_mock.configure_mock(**config)

            #run the test
            resp = index(self.request)

            #ensure we return the state of the session back to normal
            self.request.session = {}
            u.delete()

            #we are now sending a lot of state for logged in users, rather than
            #recreating that all here, let's just check for some text
            #that should only be present when we are logged in.
            self.assertContains(resp, "Report back to base")
开发者ID:chrisbeedie,项目名称:MEC,代码行数:28,代码来源:testMainPageView.py

示例2: test_index_handles_logged_in_user

# 需要导入模块: from payments.models import User [as 别名]
# 或者: from payments.models.User import delete [as 别名]
    def test_index_handles_logged_in_user(self):
         # Create a session that appears to have a logged in user
        self.request.session={'user':'1'}
        #setup dummy user
        #we need to save user so user -> badges relationship is created
        u=User(email="[email protected]")
        u.save()

        with mock.patch('main.views.User') as user_mock:
        # Tell the mock what to do when called
            config = {'get_by_id.return_value': u}# mock.Mock()}
            user_mock.configure_mock(**config)
             #Run the test
            resp=index(self.request)
            #ensure we return the state of the session back to normal so
           #we don't affect other test
            self.request.session={}
           #verify it returns the page for the logged in user
            # expectedHtml = render_to_response(
            # 'main/user.html', {'user': user_mock.get_by_id(1)})
            u.delete()

            #self.assertEquals(resp.content, expectedHtml.content)
            self.assertContains(resp,"Report back to base")
开发者ID:ujrc,项目名称:Realpython_book3,代码行数:26,代码来源:testMainPageView.py


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