author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Fri, 17 Sep 2010 16:54:56 +0200 | |
branch | stable |
changeset 6282 | 556b1b1a2c5a |
parent 5424 | 8ecbcbff9777 |
permissions | -rw-r--r-- |
0 | 1 |
# -*- coding: utf-8 -*- |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
2 |
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
3 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
4 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
5 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
6 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
7 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
8 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
9 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
10 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
11 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
12 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
13 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
14 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
15 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
16 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
17 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
18 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
19 |
""" |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
20 |
|
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
21 |
""" |
0 | 22 |
from cubicweb.goa.testlib import * |
23 |
||
24 |
from cubicweb import Binary |
|
25 |
from cubicweb.goa.goaconfig import GAEConfiguration |
|
26 |
from cubicweb.server.utils import crypt_password |
|
27 |
||
28 |
from google.appengine.api.datastore_types import Text, Blob |
|
29 |
||
30 |
||
31 |
class Blog(db.Model): |
|
32 |
data = db.BlobProperty() |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
33 |
|
0 | 34 |
class DBTest(GAEBasedTC): |
35 |
config = GAEConfiguration('toto') |
|
36 |
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
|
37 |
|
0 | 38 |
MODEL_CLASSES = (Blog,) |
39 |
||
40 |
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
|
41 |
eprop = self.add_entity('CWProperty', pkey=u'ui.language', value=u'en') |
0 | 42 |
self.failUnless('s_for_user' in eprop._dbmodel) |
43 |
self.assertEquals(eprop._dbmodel['s_for_user'], None) |
|
44 |
||
45 |
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
|
46 |
euser = self.add_entity('CWUser', login=u'toto', upassword='toto') |
0 | 47 |
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
|
48 |
|
0 | 49 |
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
|
50 |
egroup = self.add_entity('CWGroup', name=u'toto') |
0 | 51 |
self.assertEquals(egroup.key().name(), 'key_toto') |
52 |
||
53 |
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
|
54 |
euser = self.add_entity('CWUser', login=u'toto', upassword='toto') |
0 | 55 |
self.failUnless(euser.upassword != 'toto', euser.upassword) |
56 |
self.assertEquals(crypt_password('toto', euser.upassword[:2]), euser.upassword) |
|
57 |
||
58 |
def test_long_text(self): |
|
59 |
# datastore string type is limited to 500 bytes |
|
60 |
text = u'e'*501 |
|
61 |
entity = self.add_entity('State', name=u'test', description=text) |
|
62 |
self.assertIsInstance(entity.description, unicode) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
63 |
self.failIf(isinstance(entity.description, Text)) |
0 | 64 |
self.assertEquals(entity.description, text) |
65 |
||
66 |
def test_long_accentued_text(self): |
|
67 |
# datastore string type is limited to 500 bytes |
|
68 |
text = u'é'*500 |
|
69 |
entity = self.add_entity('State', name=u'test', description=text) |
|
70 |
self.assertIsInstance(entity.description, unicode) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
71 |
self.failIf(isinstance(entity.description, Text)) |
0 | 72 |
self.assertEquals(entity.description, text) |
73 |
||
74 |
def test_blob(self): |
|
75 |
data = 'e'*501 |
|
76 |
entity = self.add_entity('Blog', data=data) |
|
77 |
self.assertIsInstance(entity.data, Binary) |
|
78 |
value = entity.data.getvalue() |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
79 |
self.failIf(isinstance(value, Blob)) |
0 | 80 |
self.assertEquals(value, data) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
81 |
|
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
82 |
|
0 | 83 |
if __name__ == '__main__': |
84 |
from logilab.common.testlib import unittest_main |
|
85 |
unittest_main() |