本文整理汇总了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")
示例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")