author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Wed, 23 Sep 2009 11:03:14 +0200 | |
changeset 3402 | 434946bb5356 |
parent 1977 | 606923dff11b |
child 4212 | ab6573088b4a |
permissions | -rw-r--r-- |
0 | 1 |
# -*- coding: utf-8 -*- |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
2 |
""" |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
3 |
|
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
4 |
:organization: Logilab |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
5 |
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
6 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
7 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
8 |
""" |
0 | 9 |
from cubicweb.goa.testlib import * |
10 |
||
11 |
from cubicweb import Binary |
|
12 |
from cubicweb.goa.goaconfig import GAEConfiguration |
|
13 |
from cubicweb.server.utils import crypt_password |
|
14 |
||
15 |
from google.appengine.api.datastore_types import Text, Blob |
|
16 |
||
17 |
||
18 |
class Blog(db.Model): |
|
19 |
data = db.BlobProperty() |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
20 |
|
0 | 21 |
class DBTest(GAEBasedTC): |
22 |
config = GAEConfiguration('toto') |
|
23 |
config.global_set_option('use-google-auth', False) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
24 |
|
0 | 25 |
MODEL_CLASSES = (Blog,) |
26 |
||
27 |
def test_set_none_relation(self): |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
28 |
eprop = self.add_entity('CWProperty', pkey=u'ui.language', value=u'en') |
0 | 29 |
self.failUnless('s_for_user' in eprop._dbmodel) |
30 |
self.assertEquals(eprop._dbmodel['s_for_user'], None) |
|
31 |
||
32 |
def test_euser_key(self): |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
33 |
euser = self.add_entity('CWUser', login=u'toto', upassword='toto') |
0 | 34 |
self.assertEquals(euser.key().name(), 'key_toto') |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
35 |
|
0 | 36 |
def test_egroup_key(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
37 |
egroup = self.add_entity('CWGroup', name=u'toto') |
0 | 38 |
self.assertEquals(egroup.key().name(), 'key_toto') |
39 |
||
40 |
def test_password_encryption(self): |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
41 |
euser = self.add_entity('CWUser', login=u'toto', upassword='toto') |
0 | 42 |
self.failUnless(euser.upassword != 'toto', euser.upassword) |
43 |
self.assertEquals(crypt_password('toto', euser.upassword[:2]), euser.upassword) |
|
44 |
||
45 |
def test_long_text(self): |
|
46 |
# datastore string type is limited to 500 bytes |
|
47 |
text = u'e'*501 |
|
48 |
entity = self.add_entity('State', name=u'test', description=text) |
|
49 |
self.assertIsInstance(entity.description, unicode) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
50 |
self.failIf(isinstance(entity.description, Text)) |
0 | 51 |
self.assertEquals(entity.description, text) |
52 |
||
53 |
def test_long_accentued_text(self): |
|
54 |
# datastore string type is limited to 500 bytes |
|
55 |
text = u'é'*500 |
|
56 |
entity = self.add_entity('State', name=u'test', description=text) |
|
57 |
self.assertIsInstance(entity.description, unicode) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
58 |
self.failIf(isinstance(entity.description, Text)) |
0 | 59 |
self.assertEquals(entity.description, text) |
60 |
||
61 |
def test_blob(self): |
|
62 |
data = 'e'*501 |
|
63 |
entity = self.add_entity('Blog', data=data) |
|
64 |
self.assertIsInstance(entity.data, Binary) |
|
65 |
value = entity.data.getvalue() |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
66 |
self.failIf(isinstance(value, Blob)) |
0 | 67 |
self.assertEquals(value, data) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
68 |
|
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
69 |
|
0 | 70 |
if __name__ == '__main__': |
71 |
from logilab.common.testlib import unittest_main |
|
72 |
unittest_main() |