本文整理匯總了Python中daguerre.views.AjaxUpdateAreaView.delete方法的典型用法代碼示例。如果您正苦於以下問題:Python AjaxUpdateAreaView.delete方法的具體用法?Python AjaxUpdateAreaView.delete怎麽用?Python AjaxUpdateAreaView.delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類daguerre.views.AjaxUpdateAreaView
的用法示例。
在下文中一共展示了AjaxUpdateAreaView.delete方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_delete
# 需要導入模塊: from daguerre.views import AjaxUpdateAreaView [as 別名]
# 或者: from daguerre.views.AjaxUpdateAreaView import delete [as 別名]
def test_delete(self):
area = self.create_area(x2=50, y2=50)
self.assertEqual(Area.objects.count(), 1)
view = AjaxUpdateAreaView()
view.kwargs = {
'storage_path': area.storage_path,
'pk': area.pk,
}
request = self.factory.delete('/', HTTP_X_REQUESTED_WITH='XMLHttpRequest')
request.user = self.create_user(permissions=['daguerre.delete_area'])
self.assertTrue(request.user.has_perm('daguerre.delete_area'))
with self.assertNumQueries(3):
response = view.delete(request)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.content, '')
self.assertEqual(Area.objects.count(), 0)
示例2: test_delete__no_perms
# 需要導入模塊: from daguerre.views import AjaxUpdateAreaView [as 別名]
# 或者: from daguerre.views.AjaxUpdateAreaView import delete [as 別名]
def test_delete__no_perms(self):
area = self.create_area(x2=50, y2=50)
self.assertEqual(Area.objects.count(), 1)
view = AjaxUpdateAreaView()
view.kwargs = {
'storage_path': area.storage_path,
'pk': area.pk,
}
request = self.factory.delete('/', HTTP_X_REQUESTED_WITH='XMLHttpRequest')
request.user = AnonymousUser()
self.assertFalse(request.user.has_perm('daguerre.delete_area'))
with self.assertNumQueries(0):
response = view.delete(request)
self.assertEqual(response.status_code, 403)
self.assertEqual(Area.objects.count(), 1)
self.assertEqual(response.content, '')