diff -r 20c41a7e2173 -r 83b28fc0d731 web/ldt/text/tests/server_tests.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/ldt/text/tests/server_tests.py Mon Dec 13 23:55:19 2010 +0100 @@ -0,0 +1,68 @@ +#encoding:UTF-8 + +""" Run these tests with 'python manage.py test text' """ + +from django.conf import settings +from django.contrib.auth.models import * +from django.test import TestCase +from ldt.core.models import Owner +from ldt.test.testcases import OAuthWebTestCase +from ldt.text import VERSION_STR +from ldt.text.models import * +from ldt.text.views import * +from oauth_provider.models import Resource, Consumer, Token, Nonce +import datetime +import logging +import lxml.etree +import tempfile +import time +import unittest +import urllib +import uuid + +class OnServerGlobalTest(OAuthWebTestCase): + + fixtures = ['test_data'] + + def setUp(self): + + self.id = "mypersonnalid" + self.id2 = "mypersonnalid2" + + self.CONSUMER_KEY = 'dpf43f3p2l4k3l03' + self.CONSUMER_SECRET = 'kd94hf93k423kf44' + + self.set_consumer(self.CONSUMER_KEY, self.CONSUMER_SECRET) + + self.set_login_url("/accounts/login/") + + + def test_everything(self): + + res = self.client.login(username='jane', password='toto') + res = self.assertTrue(res) + + creation = self.client.post("/api/"+VERSION_STR+"/text/create/", data={'content':''+self.id+'http://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'}) + logging.debug("OnServerGlobalTest.test_everything creation : " + repr(creation.content)) + + creation2 = self.client.post("/api/"+VERSION_STR+"/text/create/", data={'content':''+self.id2+'http://www.leezam.com/pub/epub/123456!/OPS/chapter2.xhtml#pos=56,168tag1tag2#BBBBBB<![CDATA[titre de l\'annotation2]]>wakimd79cd0532-1dda-4130-b351-6a181130a7c92010-09-06 12:33:53.417550oaubert79cd0532-1dda-4130-b351-6a181130a7c92010-09-06 12:33:53.420459'}) + logging.debug("OnServerGlobalTest.test_everything creation2 : " + repr(creation2.content)) + + get = self.client.get("/api/"+VERSION_STR+"/text/get/", {"id":self.id}) + logging.debug("OnServerGlobalTest.test_everything get : " + repr(get.content)) + + update = self.client.post("/api/"+VERSION_STR+"/text/update/", data={'content':'tag1tag2newtag3#DDDDDDoaubert80cd0532-1dda-4130-b351-6a181130a7c92010-11-06 12:33:53.420459','id':self.id}) + logging.debug("OnServerGlobalTest.test_everything update : " + repr(update.content)) + + filt1 = self.client.get("/api/"+VERSION_STR+"/text/filter/", data={"uri":"http://www.leezam.com/pub/epub/123456!/OPS/chapter2.xhtml#pos=56,168"}) + logging.debug("OnServerGlobalTest.test_everything filt1 : " + repr(filt1.content)) + + 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"}) + + logging.debug("OnServerGlobalTest.test_everything filt2 : " +repr(filt2.content)) + + delete = self.client.post("/api/"+VERSION_STR+"/text/delete/", {"id":self.id}) + logging.debug("OnServerGlobalTest.test_everything delete1 : " + repr(delete.content)) + delete = self.client.post("/api/"+VERSION_STR+"/text/delete/", {"id":self.id2}) + logging.debug("OnServerGlobalTest.test_everything delete2 : " + repr(delete.content)) +