Beispiel #1
0
 def setUp(self):
     User.create_user('user1', '*****@*****.**', 'user1password')
     self.user = User.create_user('testadmin', '*****@*****.**', 'testadminpass', True)
     jwt_payload_handler = api_settings.JWT_PAYLOAD_HANDLER
     jwt_encode_handler = api_settings.JWT_ENCODE_HANDLER
     payload = jwt_payload_handler(self.user)
     token = jwt_encode_handler(payload)
     self.client.credentials(HTTP_AUTHORIZATION='JWT ' + token)
Beispiel #2
0
 def test_a_sequence_will_update_its_user_permissions_field(self):
     self.user = User.create_user('testStaff', '*****@*****.**',
                                  'testStaffpass', False)
     jwt_payload_handler = api_settings.JWT_PAYLOAD_HANDLER
     jwt_encode_handler = api_settings.JWT_ENCODE_HANDLER
     payload = jwt_payload_handler(self.user)
     token = jwt_encode_handler(payload)
     self.client.credentials(HTTP_AUTHORIZATION='JWT ' + token)
     data = {"sequence": json.loads(open(SEQUENCE_MEDIUM).read())}
     response = self.client.post(URL, data)
     if settings.QUEUE_POST_ENABLED:
         while self.client.get(
                 response.data["status"]
         ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
             pass  # Wait till background process finishes
         response = self.client.get(response.data["status"])
     self.assertEqual(response.data["responseCode"],
                      status.HTTP_201_CREATED)
     self.assertEqual(
         Sequence.objects.get(identifier="book1", name="normal").ownedBy,
         ["testStaff"])
     self.assertEqual(
         Canvas.objects.get(identifier="book1", name="p1").ownedBy,
         ["testStaff"])
     self.assertEqual(
         Canvas.objects.get(identifier="book1", name="p2").ownedBy,
         ["testStaff"])
     self.assertEqual(
         Canvas.objects.get(identifier="book1", name="p3").ownedBy,
         ["testStaff"])
Beispiel #3
0
 def setUp(self):
     self.user = User.create_user('staff', '*****@*****.**', 'staffpass')
     jwt_payload_handler = api_settings.JWT_PAYLOAD_HANDLER
     jwt_encode_handler = api_settings.JWT_ENCODE_HANDLER
     payload = jwt_payload_handler(self.user)
     token = jwt_encode_handler(payload)
     self.client.credentials(HTTP_AUTHORIZATION='JWT ' + token)
 def setUp(self):
     self.user = User.create_user('user1', '*****@*****.**',
                                  'user1pass')
     jwt_payload_handler = api_settings.JWT_PAYLOAD_HANDLER
     jwt_encode_handler = api_settings.JWT_ENCODE_HANDLER
     payload = jwt_payload_handler(self.user)
     token = jwt_encode_handler(payload)
     self.client.credentials(HTTP_AUTHORIZATION='JWT ' + token)
     AnnotationList(
         label="annotationList1",
         identifier="book1",
         name="annotationList1",
         ATid="http://example.org/iiif/book1/list/annotationList1",
         viewingHint="paged",
         ownedBy=["user1"]).save()
     AnnotationList(
         label="annotationList2",
         identifier="book1",
         name="annotationList2",
         ATid="http://example.org/iiif/book1/list/annotationList2",
         ownedBy=["user1"]).save()
     data = {"annotationList": json.loads(open(ANNOTATIONLIST_FULL).read())}
     response = self.client.post(URL, data)
     if settings.QUEUE_POST_ENABLED:
         while self.client.get(
                 response.data["status"]
         ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
             pass  # Wait till background process finishes
         response = self.client.get(response.data["status"])
Beispiel #5
0
 def setUp(self):
     self.user = User.create_user('testadmin', '*****@*****.**',
                                  'testadminpass', True)
     jwt_payload_handler = api_settings.JWT_PAYLOAD_HANDLER
     jwt_encode_handler = api_settings.JWT_ENCODE_HANDLER
     payload = jwt_payload_handler(self.user)
     token = jwt_encode_handler(payload)
     self.client.credentials(HTTP_AUTHORIZATION='JWT ' + token)
     Layer(label="layer1",
           identifier="book1",
           name="layer1",
           ATid="http://example.org/iiif/book1/layer/layer1",
           viewingHint="paged").save()
     Layer(label="layer2",
           identifier="book1",
           name="layer2",
           ATid="http://example.org/iiif/book1/layer/layer2").save()
     data = {"layer": json.loads(open(LAYER_MEDIUM).read())}
     response = self.client.post(URL, data)
     if settings.QUEUE_POST_ENABLED:
         while self.client.get(
                 response.data["status"]
         ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
             pass  # Wait till background process finishes
         response = self.client.get(response.data["status"])
Beispiel #6
0
 def test_to_view_a_sequence_not_embedded_entirely_in_manifest(self):
     self.user = User.create_user('testadmin', '*****@*****.**',
                                  'testadminpass', True)
     jwt_payload_handler = api_settings.JWT_PAYLOAD_HANDLER
     jwt_encode_handler = api_settings.JWT_ENCODE_HANDLER
     payload = jwt_payload_handler(self.user)
     token = jwt_encode_handler(payload)
     self.client.credentials(HTTP_AUTHORIZATION='JWT ' + token)
     data = {"manifest": json.loads(open(MANIFEST_FULL).read())}
     data["manifest"]["sequences"].append({
         "@id":
         "http://example.org/iiif/book1/sequence/normal2",
         "label":
         "2nd Sequence",
         "viewingDirection":
         "right-to-left"
     })
     response = self.client.post('/book1/manifest', data)
     if settings.QUEUE_POST_ENABLED:
         while self.client.get(
                 response.data["status"]
         ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
             pass  # Wait till background process finishes
         response = self.client.get(response.data["status"])
     self.assertEqual(
         Sequence.objects().get(identifier="book1",
                                name="normal2").viewingDirection,
         "right-to-left")
     response = self.client.get('/book1/manifest')
     self.assertFalse("viewingDirection" in response.data["sequences"][1])
 def setUp(self):
     self.user = User.create_user('user1', '*****@*****.**', 'user1password')
     jwt_payload_handler = api_settings.JWT_PAYLOAD_HANDLER
     jwt_encode_handler = api_settings.JWT_ENCODE_HANDLER
     payload = jwt_payload_handler(self.user)
     token = jwt_encode_handler(payload)
     self.client.credentials(HTTP_AUTHORIZATION='JWT ' + token)
     data = {"manifest": json.loads(open(MANIFEST_FULL).read())}
     response = self.client.post('/book1/manifest', data)
     if settings.QUEUE_POST_ENABLED:
         while self.client.get(response.data["status"]).status_code!=status.HTTP_301_MOVED_PERMANENTLY: pass # Wait till background process finishes
     self.user = User.create_user('admin', '*****@*****.**', 'adminpassword', True)
     jwt_payload_handler = api_settings.JWT_PAYLOAD_HANDLER
     jwt_encode_handler = api_settings.JWT_ENCODE_HANDLER
     payload = jwt_payload_handler(self.user)
     token = jwt_encode_handler(payload)
     self.client.credentials(HTTP_AUTHORIZATION='JWT ' + token)
Beispiel #8
0
 def setUp(self):
     self.user = User.create_user('testadmin', '*****@*****.**', 'testadminpass', True)
     jwt_payload_handler = api_settings.JWT_PAYLOAD_HANDLER
     jwt_encode_handler = api_settings.JWT_ENCODE_HANDLER
     payload = jwt_payload_handler(self.user)
     token = jwt_encode_handler(payload)
     self.client.credentials(HTTP_AUTHORIZATION='JWT ' + token)
     Canvas(label="canvas1", identifier="book1", name="canvas1", ATid="http://example.org/iiif/book1/canvas/canvas1").save()
     Canvas(label="canvas2", identifier="book1", name="canvas2", ATid="http://example.org/iiif/book1/canvas/canvas2").save()
Beispiel #9
0
 def test_to_get_all_staffs_with_admin_privileges(self):
     self.user = User.create_user('testadmin', '*****@*****.**', 'testadminpass', True)
     jwt_payload_handler = api_settings.JWT_PAYLOAD_HANDLER
     jwt_encode_handler = api_settings.JWT_ENCODE_HANDLER
     payload = jwt_payload_handler(self.user)
     token = jwt_encode_handler(payload)
     self.client.credentials(HTTP_AUTHORIZATION='JWT ' + token)
     response = self.client.get('/auth/staff')
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     self.assertEqual(response.data[0]['username'], 'user1')
Beispiel #10
0
 def test_to_get_all_staffs_with_admin_privileges_where_no_staffs_are_present(self):
     User.objects.delete()
     self.user = User.create_user('testadmin', '*****@*****.**', 'testadminpass', True)
     jwt_payload_handler = api_settings.JWT_PAYLOAD_HANDLER
     jwt_encode_handler = api_settings.JWT_ENCODE_HANDLER
     payload = jwt_payload_handler(self.user)
     token = jwt_encode_handler(payload)
     self.client.credentials(HTTP_AUTHORIZATION='JWT ' + token)
     response = self.client.get('/auth/staff')
     self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
     self.assertEqual(response.data['error'], 'No staff users found.')
Beispiel #11
0
 def test_to_delete_a_staff_with_admin_privileges_with_invalid_userID(self):
     staffID = "InvalidID"
     self.user = User.create_user('testadmin', '*****@*****.**', 'testadminpass', True)
     jwt_payload_handler = api_settings.JWT_PAYLOAD_HANDLER
     jwt_encode_handler = api_settings.JWT_ENCODE_HANDLER
     payload = jwt_payload_handler(self.user)
     token = jwt_encode_handler(payload)
     self.client.credentials(HTTP_AUTHORIZATION='JWT ' + token)
     response = self.client.delete('/auth/staff/'+staffID)
     self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
     self.assertEqual(response.data["error"], "User with id 'InvalidID' does not exist.")
Beispiel #12
0
 def test_to_delete_a_staff_with_admin_privileges(self):
     staffID = str(self.user.id)
     self.user = User.create_user('testadmin', '*****@*****.**', 'testadminpass', True)
     jwt_payload_handler = api_settings.JWT_PAYLOAD_HANDLER
     jwt_encode_handler = api_settings.JWT_ENCODE_HANDLER
     payload = jwt_payload_handler(self.user)
     token = jwt_encode_handler(payload)
     self.client.credentials(HTTP_AUTHORIZATION='JWT ' + token)
     response = self.client.delete('/auth/staff/'+staffID)
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     self.assertEqual(response.data["message"], "Successfully deleted user with id '" + staffID + "'.")
Beispiel #13
0
 def test_to_update_a_staff_with_admin_privileges(self):
     staffID = str(self.user.id)
     self.user = User.create_user('testadmin', '*****@*****.**', 'testadminpass', True)
     jwt_payload_handler = api_settings.JWT_PAYLOAD_HANDLER
     jwt_encode_handler = api_settings.JWT_ENCODE_HANDLER
     payload = jwt_payload_handler(self.user)
     token = jwt_encode_handler(payload)
     self.client.credentials(HTTP_AUTHORIZATION='JWT ' + token)
     data = {"username": "******"}
     response = self.client.put('/auth/staff/'+staffID, data)
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     self.assertEqual(response.data["username"], "newUserName")
Beispiel #14
0
 def view_staffs(self, request, format=None):
     try:
         users = User.objects(is_superuser=False)
         if users:
             users_serializer = UserViewSerializer(
                 users, context={'request': request}, many=True)
             return Response(users_serializer.data)
         else:
             return Response(status=status.HTTP_404_NOT_FOUND,
                             data={'error': "No staff users found."})
     except Exception as e:  # pragma: no cover
         return Response(status=status.HTTP_500_INTERNAL_SERVER_ERROR,
                         data={'error': e.message})
Beispiel #15
0
 def test_to_delete_a_specific_activity_with_staff_user(self):
     self.user = User.create_user('teststaff', '*****@*****.**',
                                  'teststaffpass')
     jwt_payload_handler = api_settings.JWT_PAYLOAD_HANDLER
     jwt_encode_handler = api_settings.JWT_ENCODE_HANDLER
     payload = jwt_payload_handler(self.user)
     token = jwt_encode_handler(payload)
     self.client.credentials(HTTP_AUTHORIZATION='JWT ' + token)
     activity = Activity(responseCode=200).save()
     response = self.client.delete('/activity/' + str(activity.id))
     self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
     self.assertEqual(
         response.data['detail'],
         "You don't have the necessary permission to perform this action. Please contact your admin."
     )
     self.assertEqual(len(Activity.objects), 1)
 def test_to_verify_an_admin_can_delete_any_object(self):
     data = {"manifest": json.loads(open(MANIFEST_FULL).read())}
     response = self.client.post('/book1/manifest', data)
     if settings.QUEUE_POST_ENABLED:
         while self.client.get(response.data["status"]).status_code!=status.HTTP_301_MOVED_PERMANENTLY: pass # Wait till background process finishes
     self.user = User.create_user('admin', '*****@*****.**', 'adminpassword', True)
     jwt_payload_handler = api_settings.JWT_PAYLOAD_HANDLER
     jwt_encode_handler = api_settings.JWT_ENCODE_HANDLER
     payload = jwt_payload_handler(self.user)
     token = jwt_encode_handler(payload)
     self.client.credentials(HTTP_AUTHORIZATION='JWT ' + token)
     response = self.client.delete('/book1/sequence/s0', data)
     if settings.QUEUE_DELETE_ENABLED:
         while self.client.get(response.data["status"]).status_code!=status.HTTP_301_MOVED_PERMANENTLY: pass # Wait till background process finishes
         response = self.client.get(response.data["status"]) 
     self.assertEqual(response.data["responseCode"], status.HTTP_204_NO_CONTENT)
 def test_to_verify_another_staff_cannot_update_an_object_not_owned(self):
     data = {"manifest": json.loads(open(MANIFEST_FULL).read())}
     response = self.client.post('/book1/manifest', data)
     if settings.QUEUE_POST_ENABLED:
         while self.client.get(response.data["status"]).status_code!=status.HTTP_301_MOVED_PERMANENTLY: pass # Wait till background process finishes
     self.user = User.create_user('user2', '*****@*****.**', 'user1password')
     jwt_payload_handler = api_settings.JWT_PAYLOAD_HANDLER
     jwt_encode_handler = api_settings.JWT_ENCODE_HANDLER
     payload = jwt_payload_handler(self.user)
     token = jwt_encode_handler(payload)
     self.client.credentials(HTTP_AUTHORIZATION='JWT ' + token)
     response = self.client.put('/book1/sequence/s0', {"sequence": data})
     if settings.QUEUE_PUT_ENABLED:
         while self.client.get(response.data["status"]).status_code!=status.HTTP_301_MOVED_PERMANENTLY: pass # Wait till background process finishes
         response = self.client.get(response.data["status"]) 
     self.assertEqual(response.data["responseCode"], status.HTTP_401_UNAUTHORIZED)
     self.assertEqual(response.data["responseBody"]["error"], "You don't have the necessary permission to perform this action. Please contact your admin.")
Beispiel #18
0
 def setUp(self):
     self.user = User.create_user('staff', '*****@*****.**', 'password')
     jwt_payload_handler = api_settings.JWT_PAYLOAD_HANDLER
     jwt_encode_handler = api_settings.JWT_ENCODE_HANDLER
     payload = jwt_payload_handler(self.user)
     token = jwt_encode_handler(payload)
     self.client.credentials(HTTP_AUTHORIZATION='JWT ' + token)
     data = {"manifest": json.loads(open(MANIFEST_FULL).read())}
     response = self.client.post('/book1/manifest', data)
     if settings.QUEUE_POST_ENABLED:
         self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED)
         while self.client.get(
                 response.data["status"]
         ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
             pass  # Wait till background process finishes
         response = self.client.get(response.data["status"])
     self.assertEqual(response.data["responseCode"],
                      status.HTTP_201_CREATED)
     self.assertEqual(response.data["responseBody"]["@id"],
                      settings.IIIF_BASE_URL + "/book1/manifest")
 def setUp(self):
     self.user = User.create_user('user1', '*****@*****.**',
                                  'user1pass')
     jwt_payload_handler = api_settings.JWT_PAYLOAD_HANDLER
     jwt_encode_handler = api_settings.JWT_ENCODE_HANDLER
     payload = jwt_payload_handler(self.user)
     token = jwt_encode_handler(payload)
     self.client.credentials(HTTP_AUTHORIZATION='JWT ' + token)
     AnnotationList(
         label="annotationList1",
         identifier="book1",
         name="annotationList1",
         ATid="http://example.org/iiif/book1/list/annotationList1",
         ownedBy=["user1"]).save()
     AnnotationList(
         label="annotationList2",
         identifier="book1",
         name="annotationList2",
         ATid="http://example.org/iiif/book1/list/annotationList2",
         ownedBy=["user1"]).save()
Beispiel #20
0
 def setUp(self):
     self.user = User.create_user('staff', '*****@*****.**', 'staffpass',
                                  True)
     jwt_payload_handler = api_settings.JWT_PAYLOAD_HANDLER
     jwt_encode_handler = api_settings.JWT_ENCODE_HANDLER
     payload = jwt_payload_handler(self.user)
     token = jwt_encode_handler(payload)
     self.client.credentials(HTTP_AUTHORIZATION='JWT ' + token)
     data = {"manifest": json.loads(open(MANIFEST_FULL).read())}
     Activity(username="******",
              requestMethod="POST",
              responseBody={
                  "@id": "http://*****:*****@type": "someType"
              },
              responseCode=201,
              endTime=datetime.now()).save()
     Activity(username="******",
              requestMethod="PUT",
              responseBody={
                  "@id": "http://*****:*****@type": "someType"
              },
              responseCode=200,
              endTime=datetime.now()).save()
     Activity(username="******",
              requestMethod="DELETE",
              responseBody={
                  "@id": "http://*****:*****@type": "someType"
              },
              responseCode=204,
              endTime=datetime.now()).save()
     Activity(username="******",
              requestMethod="POST",
              responseBody={
                  "@id": "http://*****:*****@type": "someType"
              },
              responseCode=201,
              endTime=datetime.now()).save()
     Activity(username="******",
              requestMethod="PUT",
              responseBody={
                  "@id": "http://*****:*****@type": "someType"
              },
              responseCode=200,
              endTime=datetime.now()).save()
     Activity(username="******",
              requestMethod="DELETE",
              responseBody={
                  "@id": "http://*****:*****@type": "someType"
              },
              responseCode=204,
              endTime=datetime.now()).save()
     Activity(username="******",
              requestMethod="POST",
              responseBody={
                  "@id": "http://*****:*****@type": "someType"
              },
              responseCode=201,
              endTime=datetime.now()).save()
     Activity(username="******",
              requestMethod="PUT",
              responseBody={
                  "@id": "http://*****:*****@type": "someType"
              },
              responseCode=200,
              endTime=datetime.now()).save()
     Activity(username="******",
              requestMethod="DELETE",
              responseBody={
                  "@id": "http://*****:*****@type": "someType"
              },
              responseCode=204,
              endTime=datetime.now()).save()
     Activity(username="******",
              requestMethod="POST",
              responseBody={
                  "@id": "http://*****:*****@type": "someType"
              },
              responseCode=201,
              endTime=datetime.now()).save()
     Activity(username="******",
              requestMethod="PUT",
              responseBody={
                  "@id": "http://*****:*****@type": "someType"
              },
              responseCode=200,
              endTime=datetime.now()).save()
     Activity(username="******",
              requestMethod="DELETE",
              responseBody={
                  "@id": "http://*****:*****@type": "someType"
              },
              responseCode=204,
              endTime=datetime.now()).save()
     Activity(username="******",
              requestMethod="DELETE",
              responseBody={
                  "@id": "http://*****:*****@type": "someType"
              },
              responseCode=422,
              endTime=datetime.now()).save()
     Activity(username="******",
              requestMethod="POST",
              responseBody={
                  "@id": "http://*****:*****@type": "someType"
              },
              responseCode=201,
              endTime=datetime.now()).save()
     Activity(username="******",
              requestMethod="DELETE",
              responseBody={
                  "@id": "http://*****:*****@type": "someType"
              },
              responseCode=204,
              endTime=datetime.now()).save()
     Activity(username="******",
              requestMethod="PUT",
              responseBody={
                  "@id": "http://*****:*****@type": "someType"
              },
              responseCode=404,
              endTime=datetime.now()).save()
     Activity(username="******",
              requestMethod="DELETE",
              responseBody={
                  "@id": "http://*****:*****@type": "someType"
              },
              responseCode=404,
              endTime=datetime.now()).save()
     Activity(username="******",
              requestMethod="POST",
              responseBody={
                  "@id": "http://*****:*****@type": "someType"
              },
              responseCode=201,
              endTime=datetime.now()).save()
     Activity(username="******",
              requestMethod="PUT",
              responseBody={
                  "@id": "http://*****:*****@type": "someType"
              },
              responseCode=200,
              endTime=datetime.now()).save()
     Activity(username="******",
              requestMethod="DELETE",
              responseBody={
                  "@id": "http://*****:*****@type": "someType"
              },
              responseCode=204,
              endTime=datetime.now()).save()
     Activity(username="******",
              requestMethod="POST",
              responseBody={
                  "@id": "http://*****:*****@type": "someType"
              },
              responseCode=201,
              endTime=datetime.now()).save()
     Activity(username="******",
              requestMethod="PUT",
              responseBody={
                  "@id": "http://*****:*****@type": "someType"
              },
              responseCode=200,
              endTime=datetime.now()).save()
     Activity(username="******",
              requestMethod="DELETE",
              responseBody={
                  "@id": "http://*****:*****@type": "someType"
              },
              responseCode=204,
              endTime=datetime.now()).save()
     Activity(username="******",
              requestMethod="POST",
              responseBody={
                  "@id": "http://*****:*****@type": "someType"
              },
              responseCode=201,
              endTime=datetime.now()).save()
     Activity(username="******",
              requestMethod="PUT",
              responseBody={
                  "@id": "http://*****:*****@type": "someType"
              },
              responseCode=200,
              endTime=datetime.now()).save()
     Activity(username="******",
              requestMethod="DELETE",
              responseBody={
                  "@id": "http://*****:*****@type": "someType"
              },
              responseCode=204,
              endTime=datetime.now()).save()
     Activity(username="******",
              requestMethod="POST",
              responseBody={
                  "@id": "http://*****:*****@type": "someType"
              },
              responseCode=201,
              endTime=datetime.now()).save()
     Activity(username="******",
              requestMethod="PUT",
              responseBody={
                  "@id": "http://*****:*****@type": "someType"
              },
              responseCode=200,
              endTime=datetime.now()).save()
Beispiel #21
0
 def setUp(self):
     self.user = User.create_user('staff', '*****@*****.**', 'staffpass',
                                  True)
     jwt_payload_handler = api_settings.JWT_PAYLOAD_HANDLER
     jwt_encode_handler = api_settings.JWT_ENCODE_HANDLER
     payload = jwt_payload_handler(self.user)
     token = jwt_encode_handler(payload)
     self.client.credentials(HTTP_AUTHORIZATION='JWT ' + token)
     data = {"manifest": json.loads(open(MANIFEST_FULL).read())}
     response = self.client.post('/book1/manifest', data)
     while self.client.get(
             response.data["status"]
     ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
         pass  # Wait till background process finishes
     response = self.client.delete('/book1/manifest')
     while self.client.get(
             response.data["status"]
     ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
         pass  # Wait till background process finishes
     response = self.client.post('/book1/manifest', data)
     while self.client.get(
             response.data["status"]
     ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
         pass  # Wait till background process finishes
     response = self.client.put('/book1/manifest', data)
     while self.client.get(
             response.data["status"]
     ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
         pass  # Wait till background process finishes
     response = self.client.delete('/book1/manifest')
     while self.client.get(
             response.data["status"]
     ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
         pass  # Wait till background process finishes
     response = self.client.post('/book1/manifest', data)
     while self.client.get(
             response.data["status"]
     ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
         pass  # Wait till background process finishes
     response = self.client.put('/book1/manifest', data)
     while self.client.get(
             response.data["status"]
     ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
         pass  # Wait till background process finishes
     response = self.client.delete('/book1/manifest')
     while self.client.get(
             response.data["status"]
     ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
         pass  # Wait till background process finishes
     response = self.client.post('/book1/manifest', data)
     while self.client.get(
             response.data["status"]
     ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
         pass  # Wait till background process finishes
     response = self.client.put('/book1/manifest', data)
     while self.client.get(
             response.data["status"]
     ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
         pass  # Wait till background process finishes
     response = self.client.delete('/book1/manifest')
     while self.client.get(
             response.data["status"]
     ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
         pass  # Wait till background process finishes
     response = self.client.post('/book1/manifest', data)
     while self.client.get(
             response.data["status"]
     ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
         pass  # Wait till background process finishes
     response = self.client.post('/book1/manifest', data)
     while self.client.get(
             response.data["status"]
     ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
         pass  # Wait till background process finishes
     response = self.client.put('/book1/manifest', data)
     while self.client.get(
             response.data["status"]
     ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
         pass  # Wait till background process finishes
     response = self.client.delete('/book1/manifest')
     while self.client.get(
             response.data["status"]
     ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
         pass  # Wait till background process finishes
     response = self.client.put('/book1/manifest', data)
     while self.client.get(
             response.data["status"]
     ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
         pass  # Wait till background process finishes
     response = self.client.delete('/book1/manifest')
     while self.client.get(
             response.data["status"]
     ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
         pass  # Wait till background process finishes
     response = self.client.post('/book1/manifest', data)
     while self.client.get(
             response.data["status"]
     ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
         pass  # Wait till background process finishes
     response = self.client.put('/book1/manifest', data)
     while self.client.get(
             response.data["status"]
     ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
         pass  # Wait till background process finishes
     response = self.client.delete('/book1/manifest')
     while self.client.get(
             response.data["status"]
     ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
         pass  # Wait till background process finishes
     response = self.client.post('/book1/manifest', data)
     while self.client.get(
             response.data["status"]
     ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
         pass  # Wait till background process finishes
     response = self.client.put('/book1/manifest', data)
     while self.client.get(
             response.data["status"]
     ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
         pass  # Wait till background process finishes
     response = self.client.put('/book1/manifest', data)
     while self.client.get(
             response.data["status"]
     ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
         pass  # Wait till background process finishes
     response = self.client.put('/book1/manifest', data)
     while self.client.get(
             response.data["status"]
     ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
         pass  # Wait till background process finishes
     response = self.client.put('/book1/manifest', data)
     while self.client.get(
             response.data["status"]
     ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
         pass  # Wait till background process finishes
     response = self.client.delete('/book1/manifest')
     while self.client.get(
             response.data["status"]
     ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
         pass  # Wait till background process finishes
     response = self.client.post('/book1/manifest', data)
     while self.client.get(
             response.data["status"]
     ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
         pass  # Wait till background process finishes
     response = self.client.put('/book1/manifest', data)
     while self.client.get(
             response.data["status"]
     ).status_code != status.HTTP_301_MOVED_PERMANENTLY:
         pass  # Wait till background process finishes
     self.assertEqual(len(Activity.objects), 28)
Beispiel #22
0
 def create(self, validated_data):  # pragma: no cover
     return User.create_user(validated_data['username'],
                             validated_data['email'],
                             validated_data['password'],
                             is_superuser=True)
Beispiel #23
0
 def setUp(self):
     User.create_user('user1', '*****@*****.**', 'user1password')