Ejemplo n.º 1
0
 def test_unauthorized(self):
     slug = 'webkom'
     methods = ['post', 'patch', 'put', 'delete']
     user = create_normal_user()
     self.client.force_login(user)
     for method in methods:
         call = getattr(self.client, method)
         response = call('/api/v1/pages/{0}/'.format(slug))
         self.assertEqual(response.status_code, 403)
Ejemplo n.º 2
0
 def test_unauthorized(self):
     slug = "webkom"
     methods = ["post", "patch", "put", "delete"]
     user = create_normal_user()
     self.client.force_authenticate(user)
     for method in methods:
         call = getattr(self.client, method)
         response = call("/api/v1/pages/{0}/".format(slug))
         self.assertEqual(response.status_code, 403)
Ejemplo n.º 3
0
 def test_edit_with_object_permissions(self):
     slug = "webkom"
     page = self.pages.get(slug=slug)
     user = create_normal_user()
     group = create_group()
     group.add_user(user)
     group.save()
     page.can_edit_groups.add(group)
     self.client.force_authenticate(user)
     response = self.client.patch("/api/v1/pages/{0}/".format(slug),
                                  get_new_unique_page())
     self.assertEqual(response.status_code, 200)