|
1 #encoding:UTF-8 |
|
2 |
|
3 """ Run these tests with 'python manage.py test text' """ |
|
4 |
|
5 from django.conf import settings |
|
6 from django.contrib.auth.models import * |
|
7 from django.test import TestCase |
|
8 from ldt.core.models import Owner |
|
9 from ldt.test.testcases import OAuthWebTestCase |
|
10 from ldt.text import VERSION_STR |
|
11 from ldt.text.models import * |
|
12 from ldt.text.views import * |
|
13 from oauth_provider.models import Resource, Consumer, Token, Nonce |
|
14 import datetime |
|
15 import logging |
|
16 import lxml.etree |
|
17 import tempfile |
|
18 import time |
|
19 import unittest |
|
20 import urllib |
|
21 import uuid |
|
22 |
|
23 class OnServerGlobalTest(OAuthWebTestCase): |
|
24 |
|
25 fixtures = ['test_data'] |
|
26 |
|
27 def setUp(self): |
|
28 |
|
29 self.id = "mypersonnalid" |
|
30 self.id2 = "mypersonnalid2" |
|
31 |
|
32 self.CONSUMER_KEY = 'dpf43f3p2l4k3l03' |
|
33 self.CONSUMER_SECRET = 'kd94hf93k423kf44' |
|
34 |
|
35 self.set_consumer(self.CONSUMER_KEY, self.CONSUMER_SECRET) |
|
36 |
|
37 self.set_login_url("/accounts/login/") |
|
38 |
|
39 |
|
40 def test_everything(self): |
|
41 |
|
42 res = self.client.login(username='jane', password='toto') |
|
43 res = self.assertTrue(res) |
|
44 |
|
45 creation = self.client.post("/api/"+VERSION_STR+"/text/create/", data={'content':'<iri><text-annotation><id>'+self.id+'</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>'}) |
|
46 logging.debug("OnServerGlobalTest.test_everything creation : " + repr(creation.content)) |
|
47 |
|
48 creation2 = self.client.post("/api/"+VERSION_STR+"/text/create/", data={'content':'<iri><text-annotation><id>'+self.id2+'</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>#BBBBBB</color><description><![CDATA[texte de description2]]></description><title><![CDATA[titre de l\'annotation2]]></title><text><![CDATA[texte selectionne lors de la creation de l\'annotation2]]></text></content><meta><contributor>wakimd</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>'}) |
|
49 logging.debug("OnServerGlobalTest.test_everything creation2 : " + repr(creation2.content)) |
|
50 |
|
51 get = self.client.get("/api/"+VERSION_STR+"/text/get/", {"id":self.id}) |
|
52 logging.debug("OnServerGlobalTest.test_everything get : " + repr(get.content)) |
|
53 |
|
54 update = self.client.post("/api/"+VERSION_STR+"/text/update/", data={'content':'<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>','id':self.id}) |
|
55 logging.debug("OnServerGlobalTest.test_everything update : " + repr(update.content)) |
|
56 |
|
57 filt1 = self.client.get("/api/"+VERSION_STR+"/text/filter/", data={"uri":"http://www.leezam.com/pub/epub/123456!/OPS/chapter2.xhtml#pos=56,168"}) |
|
58 logging.debug("OnServerGlobalTest.test_everything filt1 : " + repr(filt1.content)) |
|
59 |
|
60 filt2 = self.client.get("/api/"+VERSION_STR+"/text/filter/", data={"uri":"http://www.leezam.com/pub/epub/123456!/OPS/chapter2.xhtml#pos=56,168","creator":"wakimd"}) |
|
61 |
|
62 logging.debug("OnServerGlobalTest.test_everything filt2 : " +repr(filt2.content)) |
|
63 |
|
64 delete = self.client.post("/api/"+VERSION_STR+"/text/delete/", {"id":self.id}) |
|
65 logging.debug("OnServerGlobalTest.test_everything delete1 : " + repr(delete.content)) |
|
66 delete = self.client.post("/api/"+VERSION_STR+"/text/delete/", {"id":self.id2}) |
|
67 logging.debug("OnServerGlobalTest.test_everything delete2 : " + repr(delete.content)) |
|
68 |