author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Wed, 24 Feb 2010 11:21:51 +0100 | |
branch | stable |
changeset 4687 | 082e66184f71 |
parent 4212 | ab6573088b4a |
child 5421 | 8167de96c523 |
permissions | -rw-r--r-- |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
1 |
"""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
|
2 |
|
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
3 |
:organization: Logilab |
4212
ab6573088b4a
update copyright: welcome 2010
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
4 |
:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
5 |
: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
|
6 |
: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
|
7 |
""" |
0 | 8 |
|
9 |
from logilab.common.testlib import TestCase, unittest_main |
|
10 |
||
11 |
from cubicweb.schema import Schema, EntitySchema |
|
12 |
||
13 |
import re |
|
14 |
from cubicweb.devtools.fill import ValueGenerator, _ValueGenerator |
|
15 |
||
16 |
ISODATE_SRE = re.compile('(?P<year>\d{4})-(?P<month>\d{2})-(?P<day>\d{2})$') |
|
17 |
||
18 |
||
19 |
class AutoExtendableTC(TestCase): |
|
20 |
||
21 |
def setUp(self): |
|
22 |
self.attrvalues = dir(_ValueGenerator) |
|
23 |
||
24 |
def tearDown(self): |
|
25 |
attrvalues = set(dir(_ValueGenerator)) |
|
26 |
for attrname in attrvalues - set(self.attrvalues): |
|
27 |
delattr(_ValueGenerator, attrname) |
|
28 |
||
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
29 |
|
0 | 30 |
def test_autoextend(self): |
31 |
self.failIf('generate_server' in dir(ValueGenerator)) |
|
32 |
class MyValueGenerator(ValueGenerator): |
|
33 |
def generate_server(self, index): |
|
34 |
return attrname |
|
35 |
self.failUnless('generate_server' in dir(ValueGenerator)) |
|
36 |
||
37 |
||
38 |
def test_bad_signature_detection(self): |
|
39 |
self.failIf('generate_server' in dir(ValueGenerator)) |
|
40 |
try: |
|
41 |
class MyValueGenerator(ValueGenerator): |
|
42 |
def generate_server(self): |
|
43 |
pass |
|
44 |
except TypeError: |
|
45 |
self.failIf('generate_server' in dir(ValueGenerator)) |
|
46 |
else: |
|
47 |
self.fail('TypeError not raised') |
|
48 |
||
49 |
||
50 |
def test_signature_extension(self): |
|
51 |
self.failIf('generate_server' in dir(ValueGenerator)) |
|
52 |
class MyValueGenerator(ValueGenerator): |
|
53 |
def generate_server(self, index, foo): |
|
54 |
pass |
|
55 |
self.failUnless('generate_server' in dir(ValueGenerator)) |
|
56 |
||
57 |
||
58 |
if __name__ == '__main__': |
|
59 |
unittest_main() |