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


Python AjaxUpdateAreaView.post方法代码示例

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


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

示例1: test_post__add__no_perms

# 需要导入模块: from daguerre.views import AjaxUpdateAreaView [as 别名]
# 或者: from daguerre.views.AjaxUpdateAreaView import post [as 别名]
    def test_post__add__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': None,
        }

        params = {
            'x1': 50,
            'y1': 50,
            'x2': 100,
            'y2': 100,
            'priority': 1,
            'name': 'fun'
        }
        request = self.factory.post('/', params,
                                    HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        request.user = self.create_user(permissions=['daguerre.change_area'])
        self.assertTrue(request.user.has_perm('daguerre.change_area'))
        with self.assertNumQueries(1):
            response = view.post(request)

        self.assertEqual(response.status_code, 403)
        self.assertEqual(Area.objects.count(), 1)
        self.assertEqual(force_text(response.content), '')
开发者ID:fabrixxm,项目名称:django-daguerre,代码行数:29,代码来源:test_views.py

示例2: test_post__add

# 需要导入模块: from daguerre.views import AjaxUpdateAreaView [as 别名]
# 或者: from daguerre.views.AjaxUpdateAreaView import post [as 别名]
    def test_post__add(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': None,
        }

        params = {
            'x1': 50,
            'y1': 50,
            'x2': 100,
            'y2': 100,
            'priority': 1,
            'name': 'fun'
        }
        request = self.factory.post('/', params,
                                    HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        request.user = self.create_user(permissions=['daguerre.change_area',
                                                     'daguerre.add_area'])
        self.assertTrue(request.user.has_perm('daguerre.change_area'))
        self.assertTrue(request.user.has_perm('daguerre.add_area'))
        with self.assertNumQueries(3):
            response = view.post(request)

        self.assertEqual(response.status_code, 200)
        self.assertEqual(response['Content-Type'], "application/json")
        self.assertEqual(Area.objects.count(), 2)
        data = json.loads(force_text(response.content))
        new_area = Area.objects.exclude(pk=area.pk).get()
        self.assertEqual(data, new_area.serialize())
        del data['storage_path']
        del data['id']
        self.assertEqual(data, params)
开发者ID:fabrixxm,项目名称:django-daguerre,代码行数:37,代码来源:test_views.py

示例3: test_post__no_change_perms

# 需要导入模块: from daguerre.views import AjaxUpdateAreaView [as 别名]
# 或者: from daguerre.views.AjaxUpdateAreaView import post [as 别名]
	def test_post__no_change_perms(self):
		view = AjaxUpdateAreaView()
		request = self.factory.post('/', HTTP_X_REQUESTED_WITH='XMLHttpRequest')
		request.user = AnonymousUser()
		self.assertFalse(request.user.has_perm('daguerre.change_area'))
		with self.assertNumQueries(0):
			response = view.post(request)

		self.assertEqual(response.status_code, 403)
		self.assertEqual(response.content, '')
开发者ID:roverdotcom,项目名称:django-daguerre,代码行数:12,代码来源:test_views.py

示例4: test_post__update

# 需要导入模块: from daguerre.views import AjaxUpdateAreaView [as 别名]
# 或者: from daguerre.views.AjaxUpdateAreaView import post [as 别名]
    def test_post__update(self):
        area = self.create_area(x2=50, y2=50)
        self.assertEqual(Area.objects.count(), 1)
        old_serialize = area.serialize()
        view = AjaxUpdateAreaView()
        view.kwargs = {
            'storage_path': area.storage_path,
            'pk': area.pk,
        }

        params = {
            'x1': 50,
            'y1': 50,
            'x2': 100,
            'y2': 100,
            'priority': 1,
            'name': 'fun'
        }
        request = self.factory.post('/', params,
                                    HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        request.user = self.create_user(permissions=['daguerre.change_area'])
        self.assertTrue(request.user.has_perm('daguerre.change_area'))
        # SB: Used to assert 4 - don't remember why.
        # Three queries expected: get the area, update the area,
        # and clear the adjustment cache.
        with self.assertNumQueries(3):
            response = view.post(request)

        self.assertEqual(response.status_code, 200)
        self.assertEqual(response['Content-Type'], "application/json")
        self.assertEqual(Area.objects.count(), 1)
        data = json.loads(force_text(response.content))
        new_area = Area.objects.get(pk=area.pk, storage_path=area.storage_path)
        self.assertEqual(data, new_area.serialize())
        self.assertNotEqual(data, old_serialize)
        del data['storage_path']
        del data['id']
        self.assertEqual(data, params)
开发者ID:fitodic,项目名称:django-daguerre,代码行数:40,代码来源:test_views.py


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