diff -r 22ab430e9b64 -r 000f3ca19eaa web/ldt/text/tests.py --- a/web/ldt/text/tests.py Tue Nov 16 14:15:07 2010 +0100 +++ b/web/ldt/text/tests.py Tue Nov 16 15:35:12 2010 +0100 @@ -46,8 +46,7 @@ # def test_error_create(self): # content = base64.urlsafe_b64encode('d2c1d1fa-629d-4520-a3d2-955b4f2582c0http://www.leezam.com/pub/epub/123456!/OPS/chapter2.xhtml#pos=56,168tag1tag2#AAAAAA<![CDATA[titre de l\'annotation]]>oaubert79cd0532-1dda-4130-b351-6a181130a7c92010-09-06 12:33:53.417550oaubert79cd0532-1dda-4130-b351-6a181130a7c92010-09-06 12:33:53.420459') # response = self.c.post('/api/'+ VERSION_STR +'/text/create/', {'content':content}) -# #annot2 = create_annotation(content) -# self.assertEqual(response.status_code, '409') +# self.assertEqual(response.status_code, 409) # This test creates an annotation, then gets it, and checks that the returned xml contains correct data @@ -69,12 +68,9 @@ self.assertEqual(self.annot1.xpath("/iri/text-annotation/content/color/text()")[0],self.annotation.color) self.assertEqual(self.annot1.xpath("/iri/text-annotation/meta/created/text()")[0], str(self.annotation.creation_date)) -# def test_error_get(self): -# response = self.c.get('/api/'+ VERSION_STR +'/text/get/', {'id':'2'}) -# #response = self.c.get('/api/'+ VERSION_STR +'/text/get/', {'id':'2'}) -# #annot3 = get_annotation('d2c1d1fa-629d-4520-a3d2-955b4f2582c0') -# #resp = response.status_code -# self.assertEqual(response.status_code,'404') + def test_error_get(self): + response = self.c.get('/api/'+ VERSION_STR +'/text/get/', {'id':'2'}) + self.assertEqual(response.status_code,404) class FilterTest(unittest.TestCase): @@ -141,18 +137,17 @@ def test_delete_annotation(self): response = self.c.post('/api/'+ VERSION_STR +'/text/delete/', {'id':'d2c1d1fa-629d-4520-a3d2-955b4f2582c0'}) - #response2 = self.c.get('/ldt/get/', {'id':'d2c1d1fa-629d-4520-a3d2-955b4f2582c0'}) + response2 = self.c.get('/ldt/get/', {'id':'d2c1d1fa-629d-4520-a3d2-955b4f2582c0'}) doc = lxml.etree.fromstring(response.content) self.assertEqual(doc.xpath("/iri/text-annotation/id/text()"),[]) self.assertEqual(doc.xpath("/iri/text-annotation/tags/tag/text()"), []) self.assertEqual(doc.xpath("/iri/text-annotation/content/color/text()"),[]) self.assertEqual(doc.xpath("/iri/text-annotation/meta/creator/text()"),[]) - #self.assertEqual(response2.status_code, '404') + self.assertEqual(response2.status_code, 404) -# def test_error_delete(self): -# response = self.c.post('/api/'+ VERSION_STR +'/text/ldt/delete/', {'id':'1'}) -# #annot4 = delete_annotation('f2c1d1fa-629d-4520-a3d2-955b4f2582c0') -# self.assertEqual(response.status_code,'404') + def test_error_delete(self): + response = self.c.post('/api/'+ VERSION_STR +'/text/ldt/delete/', {'id':'1'}) + self.assertEqual(response.status_code,404) # This test creates an annotation, then updates it with new content, and checks that the returned xml contains the updated data @@ -170,14 +165,14 @@ content = base64.urlsafe_b64encode('tag1tag2newtag3#DDDDDDoaubert80cd0532-1dda-4130-b351-6a181130a7c92010-11-06 12:33:53.420459') response = self.c.post('/api/'+ VERSION_STR +'/text/update/', {'content':content,'id':'d2c1d1fa-629d-4520-a3d2-955b4f2582c0'}) doc = lxml.etree.fromstring(response.content) - self.assertEqual(doc.xpath("/iri/text-annotation/id/text()")[0],"d2c1d1fa-629d-4520-a3d2-955b4f2582c0") + self.assertEqual(lxml.etree.tostring(doc), " ") + self.assertEqual(doc.xpath("/iri/text-annotation/id/text()"),"d2c1d1fa-629d-4520-a3d2-955b4f2582c0") self.assertEqual(doc.xpath("/iri/text-annotation/tags/tag/text()")[1], "mytag") self.assertEqual(doc.xpath("/iri/text-annotation/content/color/text()")[0],"#DDDDDD") -# def test_error_update(self): -# content = base64.urlsafe_b64encode('d2c1d1fa-629d-4520-a3d2-955b4f2582c0http://www.leezam.com/pub/epub/123456!/OPS/chapter2.xhtml#pos=56,168tag1tag2#AAAAAA<![CDATA[titre de l\'annotation]]>oaubert79cd0532-1dda-4130-b351-6a181130a7c92010-09-06 12:33:53.417550oaubert79cd0532-1dda-4130-b351-6a181130a7c92010-09-06 12:33:53.420459') -# response = self.c.post('/api/'+ VERSION_STR +'/text/update/', {'content':content,'id':'1'}) -# #annot5=update_annotation() -# self.assertEqual(response.status_code,'404') -# + def test_error_update(self): + content = base64.urlsafe_b64encode('d2c1d1fa-629d-4520-a3d2-955b4f2582c0http://www.leezam.com/pub/epub/123456!/OPS/chapter2.xhtml#pos=56,168tag1tag2#AAAAAA<![CDATA[titre de l\'annotation]]>oaubert79cd0532-1dda-4130-b351-6a181130a7c92010-09-06 12:33:53.417550oaubert79cd0532-1dda-4130-b351-6a181130a7c92010-09-06 12:33:53.420459') + response = self.c.post('/api/'+ VERSION_STR +'/text/update/', {'content':content,'id':'1'}) + self.assertEqual(response.status_code,404) +