author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Tue, 13 Sep 2011 15:40:06 +0200 | |
branch | stable |
changeset 7782 | 40a49f4350a5 |
parent 5424 | 8ecbcbff9777 |
child 7791 | 31bb51ea5485 |
permissions | -rw-r--r-- |
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
|
1 |
# 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
|
2 |
# 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
|
3 |
# |
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 |
# 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
|
5 |
# |
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 |
# 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
|
7 |
# 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
|
8 |
# 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
|
9 |
# 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
|
10 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
11 |
# 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
|
12 |
# 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
|
13 |
# 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
|
14 |
# 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
|
15 |
# |
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 |
# 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
|
17 |
# 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
|
18 |
"""unit tests for cubicweb.devtools.fill module |
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 |
""" |
0 | 21 |
|
22 |
from logilab.common.testlib import TestCase, unittest_main |
|
23 |
||
24 |
from cubicweb.schema import Schema, EntitySchema |
|
25 |
||
26 |
import re |
|
27 |
from cubicweb.devtools.fill import ValueGenerator, _ValueGenerator |
|
28 |
||
29 |
ISODATE_SRE = re.compile('(?P<year>\d{4})-(?P<month>\d{2})-(?P<day>\d{2})$') |
|
30 |
||
31 |
||
32 |
class AutoExtendableTC(TestCase): |
|
33 |
||
34 |
def setUp(self): |
|
35 |
self.attrvalues = dir(_ValueGenerator) |
|
36 |
||
37 |
def tearDown(self): |
|
38 |
attrvalues = set(dir(_ValueGenerator)) |
|
39 |
for attrname in attrvalues - set(self.attrvalues): |
|
40 |
delattr(_ValueGenerator, attrname) |
|
41 |
||
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
42 |
|
0 | 43 |
def test_autoextend(self): |
44 |
self.failIf('generate_server' in dir(ValueGenerator)) |
|
45 |
class MyValueGenerator(ValueGenerator): |
|
46 |
def generate_server(self, index): |
|
47 |
return attrname |
|
48 |
self.failUnless('generate_server' in dir(ValueGenerator)) |
|
49 |
||
50 |
||
51 |
def test_bad_signature_detection(self): |
|
52 |
self.failIf('generate_server' in dir(ValueGenerator)) |
|
53 |
try: |
|
54 |
class MyValueGenerator(ValueGenerator): |
|
55 |
def generate_server(self): |
|
56 |
pass |
|
57 |
except TypeError: |
|
58 |
self.failIf('generate_server' in dir(ValueGenerator)) |
|
59 |
else: |
|
60 |
self.fail('TypeError not raised') |
|
61 |
||
62 |
||
63 |
def test_signature_extension(self): |
|
64 |
self.failIf('generate_server' in dir(ValueGenerator)) |
|
65 |
class MyValueGenerator(ValueGenerator): |
|
66 |
def generate_server(self, index, foo): |
|
67 |
pass |
|
68 |
self.failUnless('generate_server' in dir(ValueGenerator)) |
|
69 |
||
70 |
||
71 |
if __name__ == '__main__': |
|
72 |
unittest_main() |