web/ldt/ldt_utils/tests.py
changeset 9 22ab430e9b64
parent 6 4d17de9ee64e
--- a/web/ldt/ldt_utils/tests.py	Tue Nov 16 12:20:59 2010 +0100
+++ b/web/ldt/ldt_utils/tests.py	Tue Nov 16 14:15:07 2010 +0100
@@ -1,190 +1,179 @@
-#encoding:UTF-8
+"""
+This file demonstrates two different styles of tests (one doctest and one
+unittest). These will both pass when you run "manage.py test".
 
-""" Run these tests with 'python manage.py test ldt_utils'  """
+Replace these with more appropriate tests for your application.
+"""
 
 from django.test import TestCase
 import unittest
 import lxml.etree
-from ldt.ldt_utils.models import *
+from models import Project, Content
 from ldt.core.models import Owner
-from views import *
+from utils import LdtUtils, LdtSearch, create_ldt, create_empty_iri, copy_ldt
 import base64
 import uuid
 import tempfile
-import datetime
 from django.contrib.auth.models import *
+from views import get_attrib
 from django.conf import settings
-from django.test.client import Client
-from ldt.ldt_utils import VERSION_STR
+
+
+
+class SimpleTest(TestCase):
+    def test_basic_addition(self):
+        """
+        Tests that 1 + 1 always equals 2.
+        """
+        self.failUnlessEqual(1 + 1, 2)
+
+__test__ = {"doctest": """
+Another way to test that 1 + 1 is equal to 2.
+
+>>> 1 + 1 == 2
+True
+"""}
 
 
 
-# This test creates an annotation and checks that:
-# 1. the annotation was created in the database (by trying to access it through a 'get')
-# 2. the returned xml contains correct data
-class CreateTest(unittest.TestCase):
+class UtilsTest(unittest.TestCase):
     def setUp(self):
-        self.content = base64.urlsafe_b64encode('<iri><text-annotation><id>f2c1d1fa-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>')
-        self.c = Client()
-        self.annot = Annotation(id=u'd2c1d1fa-629d-4520-a3d2-955b4f2582c0', uri=u'http://iri.blabla', tags=[u'tag1',u'tag2'], title=u'montitre', description=u'madesc', text=u'letexteselectionne', color=u'#AAAAAA', creator=u'wakimd', contributor=u'wakimd', creation_date=u'2010-09-06 12:33:53.417550', update_date=u'2010-09-06 12:33:53.417550')
-        self.annot.save()
+        self.user = Owner()
+        self.user.username = "toto"
+        self.LU = LdtUtils()
+    
+        self.project = Project(title="titleproj1", owner=self.user)
+        self.project.ldt = '<iri ldtversion="1.0.3" xmlns:dc="http://dublincore.org/documents/dcmi-namespace/"><project id="af3b99e4-b695-11df-bfde-00145ea4a2be" user="admin" title="CA:reponse a TC" abstract=""/> <medias> <media extra="" id="laurentcantet_entrelesmurs" pict="" src="http://amateur.iri.centrepompidou.fr//atelier/static/media/ldt/laurentcantet_entrelesmurs/laurentcantet_entrelesmurs.iri" video="rtmp://media.iri.centrepompidou.fr/ddc_player/video/regardssignes/"/> </medias> <annotations> <content id="laurentcantet_entrelesmurs"> <ensemble id="ens_perso" idProject="fe0d5d4c-2201-11df-8a24-00145ea4a2be" title="Decoupages personnels" author="perso" abstract=""> <decoupage id="c_EFC3FFE7-0204-A086-EBEC-D2A03A0E56CB" author="perso"> <title>CA: prof et admin</title> <abstract/> <elements> <element id="s_442AAB3A-42DA-F9BF-75E7-D2A0663FD5FF" begin="985690" dur="373222" author="" date="2010/09/02" color="16711680" src=""> <title/> <abstract/> <audio source=""/> <tags/> </element> <element id="s_0050F043-3AD2-0A7C-6699-D2A03A1EBA02" begin="5052858" dur="124407" author="" date="2010/09/02" color="10053375" src=""> <title>conseil de classe</title> <abstract>Reprise de la figure precedente</abstract> <audio source="undefined"/> <tags/> </element> </elements> </decoupage> <decoupage id="c_EEEF5C29-86E1-4AAE-E068-04EB5B00E492" author="perso"> <title>TC: prof et admin</title> <abstract/> <elements> <element id="s_880D9D4B-8BC0-BA43-5ECA-04EBA9FC9E59" begin="2426894" dur="141478" author="" date="2010/02/25" color="10053375" src=""> <title>Conseil de classe</title> <abstract/> <audio source=""/> <tags> <tag>Argumentation</tag> </tags> </element> <element id="s_D568A57C-7110-DED2-3165-04EC54387060" begin="5052858" dur="124407" author="" date="2010/02/25" color="10053375" src=""> <title>conseil de classe</title> <abstract>Reprise de la figure precedente</abstract> <audio source="undefined"/> <tags/> </element> </elements> </decoupage> </ensemble> </content> </annotations> <displays> <display id="0" title="Init view" idsel="laurentcantet_entrelesmurs" tc="2426424" zoom="0" scroll="0" infoBAB=""> <audio source=""/> <content id="laurentcantet_entrelesmurs"> <decoupage idens="en_2" id="de_PPP" tagsSelect=""/> <decoupage idens="laurentcantet_entrelesmurs" id="c_14A2E638-1936-97DC-E303-2DBA6A82A8B3" tagsSelect=""/> <decoupage idens="ens_perso" id="c_EEEF5C29-86E1-4AAE-E068-04EB5B00E492" tagsSelect=""/> <decoupage idens="ens_perso" id="c_EFC3FFE7-0204-A086-EBEC-D2A03A0E56CB" tagsSelect=""/> </content> </display> </displays> <edits> <editing id="0" tags=""> <title>Bout a bout 1</title> <abstract/> <edit id="edit1" tags=""> <eList/> <caption/> <audio/> <mList/> </edit> <edit id="edit2" tags=""> <eList/> <caption/> <audio/> <mList/> </edit> </editing> </edits> </iri>'
+        self.project.id = "11"
+        self.project.ldt_id = str(uuid.uuid1())
+        self.project.save()
+        
+        self.projectcopy = Project(title="the2ndproject")
+        self.projectcopy.id="22"
+
     def tearDown(self):
-        annotlist=Annotation.objects.all()
-        for annot in annotlist:
-            annot.delete()
+        self.project.delete()
+        self.projectcopy.delete()
+        #self.cont1.delete()
+        #self.cont2.delete()
+
+    def test_generate_ldt(self):
+        self.cont1 = Content(iriurl="id1/iriurl1")
+        self.cont1.iri_id = "id1"
+        self.cont1.save()
+        
+        self.cont2 = Content(iriurl="id2/iriurl2")
+        self.cont2.iri_id = "id2"
+        self.cont2.save()
+        
+        self.project.contents.add(self.cont1,self.cont2)
+    
+        f=tempfile.TemporaryFile(mode='r+')
+        self.LU.generateLdt(Content.objects.all(),f)
+        f.seek(0)
+        ldoc = lxml.etree.parse(f)
+        self.assertEqual(ldoc.xpath("/iri/displays/display/content")[9].get("id"),self.cont2.iri_id)
+        self.assertEqual(ldoc.xpath("/iri/medias/media")[8].get("id"), self.cont1.iri_id)
+        f.close()
+
+    def test_generate_init(self):
+        self.cont3 = Content(iriurl="id3/iriurl1")
+        self.cont3.iri_id = "id3"
+        self.cont3.save()
+        
+        self.cont4 = Content(iriurl="id4/iriurl2")
+        self.cont4.iri_id = "id4"
+        self.cont4.save()
+        
+        self.project.contents.add(self.cont3,self.cont4)
+        ldoc = self.LU.generateInit(None,None)
+        self.assertEqual(ldoc.xpath("/iri/files/init")[0].tag, "init")
+        self.assertEqual(ldoc.xpath("/iri/files/library")[0].tag, "library")
+        self.assertEqual(ldoc.xpath("/iri/files/init/file")[0].get("video"), settings.STREAM_URL)
 
-    def test_create_annotation(self):
-        response = self.c.post('/api/'+ VERSION_STR +'/text/create/', {'content':self.content})
-        self.annot1 = lxml.etree.fromstring(response.content)
-        self.assertEqual(self.annot1.xpath("/iri/text-annotation/id/text()")[0],"f2c1d1fa-629d-4520-a3d2-955b4f2582c0")
-        self.assertEqual(self.annot1.xpath("/iri/text-annotation/content")[0].tag,"content")
-        self.assertEqual(self.annot1.xpath("/iri/text-annotation/tags/tag/text()")[0],"tag1")
-        self.assertEqual(self.annot1.xpath("/iri/text-annotation/content/text/text()")[0],u"texte selectionne lors de la creation de l\'annotation")
-        self.assertEqual(self.annot1.xpath("/iri/text-annotation/meta/created/text()")[0],"2010-09-06 12:33:53.417550")
-        annot = Annotation.objects.get(id="f2c1d1fa-629d-4520-a3d2-955b4f2582c0")
-        self.assertEqual(annot.uri, "http://www.leezam.com/pub/epub/123456!/OPS/chapter2.xhtml#pos=56,168")
+    def test_create_ldt(self):
+        self.cont5 = Content(iriurl="id5/iriurl1")
+        self.cont5.iri_id = "id5"
+        self.cont5.save()
+        
+        self.cont6 = Content(iriurl="id6/iriurl2")
+        self.cont6.iri_id = "id6"
+        self.cont6.save()
+        
+        self.project.contents.add(self.cont5,self.cont6)
+        self.project.ldt=""
+        create_ldt(self.project, self.user)
+        ldt = lxml.etree.fromstring(self.project.ldt)
+        self.assertEqual(ldt.xpath("/iri")[0].tag,"iri")
+        self.assertEqual(ldt.xpath("/iri/project")[0].get("title"), self.project.title)
+        self.assertEqual(ldt.xpath("/iri/medias/media")[0].get("src"), self.cont5.iri_url())
+        self.assertEqual(ldt.xpath("/iri/medias/media")[1].get("id"), self.cont6.iri_id)
+
+    def test_copy_ldt(self):
+        self.cont7 = Content(iriurl="id7/iriurl1")
+        self.cont7.iri_id = "id7"
+        self.cont7.save()
+        
+        self.cont8 = Content(iriurl="id8/iriurl2")
+        self.cont8.iri_id = "id8"
+        self.cont8.save()
         
-#    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.project.contents.add(self.cont7,self.cont8)
+        copy_ldt(self.project, self.projectcopy, self.user)
+        ldt1=lxml.etree.fromstring(self.project.ldt)
+        ldt2=lxml.etree.fromstring(self.projectcopy.ldt)
+        self.assertTrue(ldt1.xpath("/iri/project")[0].get("id")!= ldt2.xpath("/iri/project")[0].get("id"))
+        self.assertEqual(ldt1.xpath("/iri/medias/media")[0].get("id"),ldt2.xpath("/iri/medias/media")[0].get("id"))
+        self.assertEqual(ldt1.xpath("/iri/annotations/content/ensemble")[0].get("title"),ldt2.xpath("/iri/annotations/content/ensemble")[0].get("title"))
+        self.assertEqual(ldt1.xpath("/iri/annotations/content/ensemble/decoupage")[0].get("id"),ldt2.xpath("/iri/annotations/content/ensemble/decoupage")[0].get("id"))
+        self.assertEqual(ldt1.xpath("/iri/annotations/content/ensemble/decoupage/title")[1].text,ldt2.xpath("/iri/annotations/content/ensemble/decoupage/title")[1].text.strip("\n\t"))
+
+    def test_create_empty_iri(self):
+        self.cont9 = Content(iriurl="id9/iriurl1")
+        self.cont9.iri_id = "id9"
+        self.cont9.save()
+        
+        self.cont10 = Content(iriurl="id10/iriurl2")
+        self.cont10.iri_id = "id10"
+        self.cont10.save()
+        
+        self.project.contents.add(self.cont9,self.cont10)
+        tmp = tempfile.TemporaryFile(mode='r+')
+        create_empty_iri(tmp, self.cont9, "admin")
+        tmp.seek(0)
+        ldoc = lxml.etree.parse(tmp)
+        self.assertEqual(ldoc.xpath("/iri/head/meta")[0].get("content"), self.cont9.iri_id)
+        self.assertEqual(ldoc.xpath("/iri/body/medias/media/video")[0].get("id"), self.cont9.iri_id)
+        tmp.close()
+    
 
 
-# This test creates an annotation, then gets it, and checks that the returned xml contains correct data
-class GetTest(unittest.TestCase):
+
+class ViewsTest(unittest.TestCase):
     def setUp(self):
-        self.annotation = Annotation(id="d2c1d1fa-629d-4520-a3d2-955b4f2582c0", tags=[u"tag1",u"tag2",u"tag3"], title="titre de l\'annotation",text="texte selectionne lors de la creation de l\'annotation",color="#AAAAAA", creation_date="2010-09-06 12:33:53.417550", update_date="2010-09-06 12:33:53.420459")
-        self.annotation.save()
-        self.c = Client()
-    def tearDown(self):
-        annotlist=Annotation.objects.all()
-        for annot in annotlist:
-            annot.delete()
-      
-    def test_get_annotation(self):
-        response = self.c.get('/api/'+ VERSION_STR +'/text/get/', {'id':'d2c1d1fa-629d-4520-a3d2-955b4f2582c0'})
-        self.annot1 = lxml.etree.fromstring(response.content)
-        #self.annot1 = get_annotation("d2c1d1fa-629d-4520-a3d2-955b4f2582c0")
-        self.assertEqual(self.annot1.xpath("/iri/text-annotation/id/text()")[0],self.annotation.id)
-        self.assertEqual(self.annot1.xpath("/iri/text-annotation/tags/tag/text()")[1], self.annotation.tags[1])
-        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()"), 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')
-        
-        
-class FilterTest(unittest.TestCase):
-    def setUp(self):
-        self.annotation = Annotation(id="k2c1d1fa-629d-4520-a3d2-955b4f2582c0",title="titre de l\'annotation",text="texte selectionne lors de la creation de l\'annotation",color="#AAAAAA", uri="http://www.leezam.com/pub/epub/123456!/OPS/chapter2.xhtml#pos=56,168", creator="wakimd")
-        self.annotation.save()
-        self.annotation2 = Annotation(id="l2c1d1fa-629d-4520-a3d2-955b4f2582c0",title="titre de l\'annotation2",text="texte selectionne lors de la creation de l\'annotation2",color="#BBBBBB", uri="http://www.leezam.com/pub/epub/123456!/OPS/chapter2.xhtml#pos=56,168", creator="wakimd")
-        self.annotation2.save()
-        self.annotation3 = Annotation(id="m2c1d1fa-629d-4520-a3d2-955b4f2582c0", title="titre3", text="texte3", color="#CCCCCC", uri="http://blabla", creator="wakimd")
-        self.annotation3.save() 
-        self.c = Client()       
-    def tearDown(self):
-        annotlist=Annotation.objects.all()
-        for annot in annotlist:
-            annot.delete()
-        
-    def test_filter_annotation_creator_limit(self):
-        user = 'wakimd'
-        uri = "http://www.leezam.com/pub/epub/123456!/OPS/chapter2.xhtml#pos=56,168"
-        limit= 1
-        response = self.c.get('/api/'+ VERSION_STR +'/text/filter/', {'uri':uri,'creator':user,'limit':limit})
-        doc = lxml.etree.fromstring(response.content)
-        #doc = filter_annotation(uri,None,limit,user)
-        cpt = 0
-        for elem in doc.xpath("/iri/text-annotation"):
-            cpt = cpt + 1
-        if limit is not None:
-            self.assertEqual(cpt,limit)
-        for elem in doc.xpath("/iri/text-annotation/meta/creator/text()"):
-            self.assertEqual(elem,user)
-        for elem in doc.xpath("/iri/text-annotation/uri/text()"):
-            self.assertEqual(elem[:57],"http://www.leezam.com/pub/epub/123456!/OPS/chapter2.xhtml")
+        self.project = Project()
+        self.project.id = "121"
+        self.project.save()
+        self.project.ldt = '<iri ldtversion="1.0.3" xmlns:dc="http://dublincore.org/documents/dcmi-namespace/"><project id="af3b99e4-b695-11df-bfde-00145ea4a2be" user="admin" title="CA:reponse a TC" abstract=""/> <medias> <media extra="" id="laurentcantet_entrelesmurs" pict="" src="http://amateur.iri.centrepompidou.fr//atelier/static/media/ldt/laurentcantet_entrelesmurs/laurentcantet_entrelesmurs.iri" video="rtmp://media.iri.centrepompidou.fr/ddc_player/video/regardssignes/"/> </medias> <annotations> <content id="laurentcantet_entrelesmurs"> <ensemble id="ens_perso" idProject="fe0d5d4c-2201-11df-8a24-00145ea4a2be" title="Decoupages personnels" author="perso" abstract=""> <decoupage id="c_EFC3FFE7-0204-A086-EBEC-D2A03A0E56CB" author="perso"> <title>CA: prof et admin</title> <abstract/> <elements> <element id="s_442AAB3A-42DA-F9BF-75E7-D2A0663FD5FF" begin="985690" dur="373222" author="" date="2010/09/02" color="16711680" src=""> <title/> <abstract/> <audio source=""/> <tags/> </element> <element id="s_0050F043-3AD2-0A7C-6699-D2A03A1EBA02" begin="5052858" dur="124407" author="" date="2010/09/02" color="10053375" src=""> <title>conseil de classe</title> <abstract>Reprise de la figure precedente</abstract> <audio source="undefined"/> <tags/> </element> </elements> </decoupage> <decoupage id="c_EEEF5C29-86E1-4AAE-E068-04EB5B00E492" author="perso"> <title>TC: prof et admin</title> <abstract/> <elements> <element id="s_880D9D4B-8BC0-BA43-5ECA-04EBA9FC9E59" begin="2426894" dur="141478" author="" date="2010/02/25" color="10053375" src=""> <title>Conseil de classe</title> <abstract/> <audio source=""/> <tags> <tag>Argumentation</tag> </tags> </element> <element id="s_D568A57C-7110-DED2-3165-04EC54387060" begin="5052858" dur="124407" author="" date="2010/02/25" color="10053375" src=""> <title>conseil de classe</title> <abstract>Reprise de la figure precedente</abstract> <audio source="undefined"/> <tags/> </element> </elements> </decoupage> </ensemble> </content> </annotations> <displays> <display id="0" title="Init view" idsel="laurentcantet_entrelesmurs" tc="2426424" zoom="0" scroll="0" infoBAB=""> <audio source=""/> <content id="laurentcantet_entrelesmurs"> <decoupage idens="en_2" id="de_PPP" tagsSelect=""/> <decoupage idens="laurentcantet_entrelesmurs" id="c_14A2E638-1936-97DC-E303-2DBA6A82A8B3" tagsSelect=""/> <decoupage idens="ens_perso" id="c_EEEF5C29-86E1-4AAE-E068-04EB5B00E492" tagsSelect=""/> <decoupage idens="ens_perso" id="c_EFC3FFE7-0204-A086-EBEC-D2A03A0E56CB" tagsSelect=""/> </content> </display> </displays> <edits> <editing id="0" tags=""> <title>Bout a bout 1</title> <abstract/> <edit id="edit1" tags=""> <eList/> <caption/> <audio/> <mList/> </edit> <edit id="edit2" tags=""> <eList/> <caption/> <audio/> <mList/> </edit> </editing> </edits> </iri>' 
+    
+        self.cont1 = Content(iriurl="/laurentcantet_entrelesmurs/iriurl1")
+        self.cont1.iri_id = 'laurentcantet_entrelesmurs'
+        self.cont1.save()
+    
+        self.cont2 = Content(iriurl="/content_notinldt/iriurl2")
+        self.cont2.iri_id = 'content_notinldt'
+        self.cont2.save()
         
-    def test_filter_annotation_uri(self):
-        uri = "http://www.leezam.com/pub/epub/123456!/OPS/chapter2.xhtml#pos=56,168"
-        response = self.c.get('/api/'+ VERSION_STR +'/text/filter/', {'uri':uri})
-        doc = lxml.etree.fromstring(response.content)
-        #doc = filter_annotation(uri,None,limit,None)
-        for elem in doc.xpath("/iri/text-annotation/uri/text()"):
-            self.assertEqual(elem[:57],"http://www.leezam.com/pub/epub/123456!/OPS/chapter2.xhtml")
-            
-    def test_filter_annotation_filter(self):
-        uri = "http://www.leezam.com/pub/epub/123456!/OPS/chapter2.xhtml#pos=56,168"
-        filter = 'lors'
-        limit = None
-        response = self.c.get('/api/'+ VERSION_STR +'/text/filter/', {'uri':uri,'filter':'lors'})
-        doc = lxml.etree.fromstring(response.content)
-        #doc = filter_annotation(uri,filter,limit,user)
-        for elem in doc.xpath("/iri/text-annotation/content/text/text()"):
-            self.assertTrue('lors' in elem)  
-        for elem in doc.xpath("/iri/text-annotation/meta/creator/text()"):
-            self.assertEqual(elem,user)          
+        self.project.contents.add(self.cont1, self.cont2)
 
-
-# This test creates an annotation, then deletes it, and checks that:
-# 1. the annotation doesn't exist anymore in the database (by trying to access it through a 'get')
-# 2. the returned xml contains no data
-class DeleteTest(unittest.TestCase):
-    def setUp(self):
-        self.annotation = Annotation(id="d2c1d1fa-629d-4520-a3d2-955b4f2582c0",title="titre de l\'annotation",text="texte selectionne lors de la creation de l\'annotation",color="#AAAAAA", creation_date="2010-09-06T12:33:53.417550", update_date="2010-09-06T12:33:53.420459")
-        self.annotation.save()
-        self.c = Client()    
     def tearDown(self):
-        annotlist=Annotation.objects.all()
-        for annot in annotlist:
-            annot.delete()
-    
-    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'})
-        doc = lxml.etree.fromstring(response.content)
-        #doc=delete_annotation("d2c1d1fa-629d-4520-a3d2-955b4f2582c0")
-        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')   
-
-#    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')
-        
+        self.project.delete()
+        ##self.cont1.delete()
+        ##self.cont2.delete()
 
-# This test creates an annotation, then updates it with new content, and checks that the returned xml contains the updated data
-class UpdateTest(unittest.TestCase):
-    def setUp(self):
-        self.annotation = Annotation(id="d2c1d1fa-629d-4520-a3d2-955b4f2582c0", tags=['tag1','mytag'],title="titre de l\'annotation",text="texte selectionne lors de la creation de l\'annotation",color="#AAAAAA", creation_date="2010-09-06T12:33:53.417550", update_date="2010-09-06T12:33:53.420459")
-        self.annotation.save()
-        self.c = Client()
-    def tearDown(self):
-        annotlist=Annotation.objects.all()
-        for annot in annotlist:
-            annot.delete()
-            
-    def test_update_annotation(self):
-        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)
-        #doc = update_annotation(content,'d2c1d1fa-629d-4520-a3d2-955b4f2582c0')
-        self.assertEqual(doc.xpath("/iri/text-annotation/id/text()")[0],"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_get_attrib(self):
+#        get_attrib(self.project)
+#        ldoc = lxml.etree.fromstring(self.project.ldt)    
+#        self.assertEqual(self.project.title, ldoc.xpath("/iri/project")[0].get("title"))
+#        self.assertEqual(ldoc.xpath("/iri/medias/media")[0].get('id'), self.cont1.iri_id)
+#        self.assertTrue(self.cont2.iri_id not in self.project.contents.all())