Example #1
0
    def test_index_create(self):
        request = self.factory.get(self.index_create_url)
        response = views.index_create(request)
        content = json.loads(response.content.decode("utf-8"))
        self.assertEquals(0, len(content))

        response = self.create_annotation()
        self.assertEquals(303, response.status_code)
        self.assertTrue(response.has_header("Location"))

        request = self.factory.get(self.index_create_url)
        response = views.index_create(request)
        content = json.loads(response.content.decode("utf-8"))
        self.assertEquals(1, len(content))
    def test_index_create(self):
        request = self.factory.get(self.index_create_url)
        response = views.index_create(request)
        content = json.loads(response.content.decode("utf-8"))
        self.assertEquals(0, len(content))

        response = self.create_annotation()
        self.assertEquals(303, response.status_code)
        self.assertTrue(response.has_header("Location"))

        request = self.factory.get(self.index_create_url)
        response = views.index_create(request)
        content = json.loads(response.content.decode("utf-8"))
        self.assertEquals(1, len(content))
Example #3
0
    def test_read_update_delete(self):
        self.create_annotation()
        request = self.factory.get(self.index_create_url)
        response = views.index_create(request)
        content = json.loads(response.content.decode("utf-8"))

        request = self.factory.get(self.read_update_delete_url)
        response = views.read_update_delete(request, content[0].get("id"))
        content = json.loads(response.content.decode("utf-8"))

        for key in self.annotation.keys():
            self.assertEquals(content.get(key), self.annotation.get(key))
    def test_read_update_delete(self):
        self.create_annotation()
        request = self.factory.get(self.index_create_url)
        response = views.index_create(request)
        content = json.loads(response.content.decode("utf-8"))

        request = self.factory.get(self.read_update_delete_url)
        response = views.read_update_delete(request, content[0].get("id"))
        content = json.loads(response.content.decode("utf-8"))

        for key in self.annotation.keys():
            self.assertEquals(content.get(key), self.annotation.get(key))
Example #5
0
 def create_annotation(self):
     request = self.factory.post(self.index_create_url,
                                 data=json.dumps(self.annotation),
                                 content_type="application/json")
     response = views.index_create(request)
     return response
 def create_annotation(self):
     request = self.factory.post(
         self.index_create_url, data=json.dumps(self.annotation), content_type="application/json"
     )
     response = views.index_create(request)
     return response