Ejemplo n.º 1
0
 def test_a_layer_can_be_updated_sucessfully(self):
     data = {"layer": json.loads(open(LAYER_MEDIUM).read())}
     data["layer"]["label"] = "new_layer1"
     data["layer"]["viewingHint"] = "non-paged"
     response = self.client.put(URL + "/transcription", 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_200_OK)
     self.assertEqual(Layer.objects()[2].label, 'new_layer1')
     self.assertEqual(Layer.objects()[2].viewingHint, "non-paged")
Ejemplo n.º 2
0
 def test_a_layer_can_be_successfully_created_with_no_nested_structures(
         self):
     data = {"layer": json.loads(open(LAYER_SHORT).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(Layer.objects()[0].label, 'Diplomatic Transcription')
     self.assertEqual(Layer.objects()[0].ATid,
                      settings.IIIF_BASE_URL + "/book1/layer/transcription")
Ejemplo n.º 3
0
 def test_a_layer_can_be_successfully_created_with_one_level_nested_structures(
         self):
     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"])
     self.assertEqual(response.data["responseCode"],
                      status.HTTP_201_CREATED)
     self.assertEqual(Layer.objects()[0].label, 'Diplomatic Transcription')
     self.assertEqual(Layer.objects()[0].ATid,
                      settings.IIIF_BASE_URL + "/book1/layer/transcription")
     self.assertEqual(len(AnnotationList.objects()), 4)
     self.assertEqual(
         AnnotationList.objects.get(name="l2").ATid,
         settings.IIIF_BASE_URL + "/book1/list/l2")
     self.assertEqual(
         Layer.objects()[0].ATid
         in AnnotationList.objects.get(identifier='book1',
                                       name='l1').belongsTo, True)
     self.assertEqual(
         Layer.objects()[0].ATid
         in AnnotationList.objects.get(identifier='book1',
                                       name='l2').belongsTo, True)
     self.assertEqual(
         Layer.objects()[0].ATid
         in AnnotationList.objects.get(identifier='book1',
                                       name='l3').belongsTo, True)
     self.assertEqual(
         Layer.objects()[0].ATid
         in AnnotationList.objects.get(identifier='book1',
                                       name='l4').belongsTo, True)
Ejemplo n.º 4
0
 def test_a_layer_with_no_id_given_can_be_successfully_created(self):
     data = {"layer": json.loads(open(LAYER_SHORT).read())}
     del data["layer"]["@id"]
     response = self.client.post("/identifier/layer", 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(Layer.objects()[0].label, 'Diplomatic Transcription')
Ejemplo n.º 5
0
 def test_a_layer_with_new_id_can_be_updated_successfully(self):
     data = {
         "layer": {
             "@id": "http://example.org/iiif/new_book1/layer/new_layer1",
             "viewingHint": "non-paged"
         }
     }
     response = self.client.put(URL + "/transcription", 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_200_OK)
     self.assertEqual(
         Layer.objects()[2].ATid,
         settings.IIIF_BASE_URL + "/new_book1/layer/new_layer1")