--- 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('<iri><text-annotation><id>d2c1d1fa-629d-4520-a3d2-955b4f2582c0</id><uri>http://www.leezam.com/pub/epub/123456!/OPS/chapter2.xhtml#pos=56,168</uri><tags><tag>tag1</tag><tag>tag2</tag></tags><content><color>#AAAAAA</color><description><![CDATA[texte de description]]></description><title><![CDATA[titre de l\'annotation]]></title><text><![CDATA[texte selectionne lors de la creation de l\'annotation]]></text></content><meta><contributor>oaubert</contributor><contributor-id>79cd0532-1dda-4130-b351-6a181130a7c9</contributor-id><created>2010-09-06 12:33:53.417550</created><creator>oaubert</creator><creator-id>79cd0532-1dda-4130-b351-6a181130a7c9</creator-id><modified>2010-09-06 12:33:53.420459</modified></meta></text-annotation></iri>')
# 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('<iri><text-annotation><id></id><uri></uri><tags><tag>tag1</tag><tag>tag2new</tag><tag>tag3</tag></tags><content><color>#DDDDDD</color><description><![CDATA[texte de description update]]></description><title></title><text><![CDATA[texte selectionne a nouveau lors de la creation de l\'annotation]]></text></content><meta><contributor>oaubert</contributor><contributor-id>80cd0532-1dda-4130-b351-6a181130a7c9</contributor-id><created></created><creator></creator><creator-id></creator-id><modified>2010-11-06 12:33:53.420459</modified></meta></text-annotation></iri>')
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('<iri><text-annotation><id>d2c1d1fa-629d-4520-a3d2-955b4f2582c0</id><uri>http://www.leezam.com/pub/epub/123456!/OPS/chapter2.xhtml#pos=56,168</uri><tags><tag>tag1</tag><tag>tag2</tag></tags><content><color>#AAAAAA</color><description><![CDATA[texte de description]]></description><title><![CDATA[titre de l\'annotation]]></title><text><![CDATA[texte selectionne lors de la creation de l\'annotation]]></text></content><meta><contributor>oaubert</contributor><contributor-id>79cd0532-1dda-4130-b351-6a181130a7c9</contributor-id><created>2010-09-06 12:33:53.417550</created><creator>oaubert</creator><creator-id>79cd0532-1dda-4130-b351-6a181130a7c9</creator-id><modified>2010-09-06 12:33:53.420459</modified></meta></text-annotation></iri>')
-# 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('<iri><text-annotation><id>d2c1d1fa-629d-4520-a3d2-955b4f2582c0</id><uri>http://www.leezam.com/pub/epub/123456!/OPS/chapter2.xhtml#pos=56,168</uri><tags><tag>tag1</tag><tag>tag2</tag></tags><content><color>#AAAAAA</color><description><![CDATA[texte de description]]></description><title><![CDATA[titre de l\'annotation]]></title><text><![CDATA[texte selectionne lors de la creation de l\'annotation]]></text></content><meta><contributor>oaubert</contributor><contributor-id>79cd0532-1dda-4130-b351-6a181130a7c9</contributor-id><created>2010-09-06 12:33:53.417550</created><creator>oaubert</creator><creator-id>79cd0532-1dda-4130-b351-6a181130a7c9</creator-id><modified>2010-09-06 12:33:53.420459</modified></meta></text-annotation></iri>')
+ response = self.c.post('/api/'+ VERSION_STR +'/text/update/', {'content':content,'id':'1'})
+ self.assertEqual(response.status_code,404)
+