author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Fri, 01 Jul 2011 18:44:03 +0200 | |
changeset 7612 | bfd4ee0d43ac |
parent 6340 | 470d8e828fda |
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:
4491
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:
4491
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:
4491
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:
4491
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:
4491
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:
4491
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:
4491
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:
4491
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:
4491
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:
4491
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:
4491
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:
4491
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:
4491
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:
4491
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:
4491
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:
4491
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:
1739
diff
changeset
|
18 |
""" |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1739
diff
changeset
|
19 |
|
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1739
diff
changeset
|
20 |
""" |
1284 | 21 |
from logilab.common.testlib import TestCase, unittest_main |
2369
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
22 |
from cubicweb.rtags import RelationTags, RelationTagsSet, RelationTagsDict |
1284 | 23 |
|
24 |
class RelationTagsTC(TestCase): |
|
1533 | 25 |
|
1284 | 26 |
def test_rtags_expansion(self): |
27 |
rtags = RelationTags() |
|
1739 | 28 |
rtags.tag_subject_of(('Societe', 'travaille', '*'), 'primary') |
29 |
rtags.tag_subject_of(('*', 'evaluee', '*'), 'secondary') |
|
30 |
rtags.tag_object_of(('*', 'tags', '*'), 'generated') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
31 |
self.assertEqual(rtags.get('Note', 'evaluee', '*', 'subject'), |
1721
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
32 |
'secondary') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
33 |
self.assertEqual(rtags.get('Societe', 'travaille', '*', 'subject'), |
1721
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
34 |
'primary') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
35 |
self.assertEqual(rtags.get('Note', 'travaille', '*', 'subject'), |
1721
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
36 |
None) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
37 |
self.assertEqual(rtags.get('Note', 'tags', '*', 'subject'), |
1721
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
38 |
None) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
39 |
self.assertEqual(rtags.get('*', 'tags', 'Note', 'object'), |
1721
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
40 |
'generated') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
41 |
self.assertEqual(rtags.get('Tag', 'tags', '*', 'object'), |
1721
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
42 |
'generated') |
1533 | 43 |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
44 |
# self.assertEqual(rtags.rtag('evaluee', 'Note', 'subject'), set(('secondary', 'link'))) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
45 |
# self.assertEqual(rtags.is_inlined('evaluee', 'Note', 'subject'), False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
46 |
# self.assertEqual(rtags.rtag('evaluee', 'Personne', 'subject'), set(('secondary', 'link'))) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
47 |
# self.assertEqual(rtags.is_inlined('evaluee', 'Personne', 'subject'), False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
48 |
# self.assertEqual(rtags.rtag('ecrit_par', 'Note', 'object'), set(('inlineview', 'link'))) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
49 |
# self.assertEqual(rtags.is_inlined('ecrit_par', 'Note', 'object'), True) |
1284 | 50 |
# class Personne2(Personne): |
51 |
# id = 'Personne' |
|
52 |
# __rtags__ = { |
|
53 |
# ('evaluee', 'Note', 'subject') : set(('inlineview',)), |
|
54 |
# } |
|
4491
a0f48c31b58a
kill register_appobject_class method, simplifying autoregistration. Update test accordingly (test which manually registers object should also properly call there __register__ method). Drop the disable-appobjects config file entry: no one used it since its introduction years ago.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
55 |
# self.vreg.register(Personne2) |
1284 | 56 |
# rtags = Personne2.rtags |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
57 |
# self.assertEqual(rtags.rtag('evaluee', 'Note', 'subject'), set(('inlineview', 'link'))) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
58 |
# self.assertEqual(rtags.is_inlined('evaluee', 'Note', 'subject'), True) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
59 |
# self.assertEqual(rtags.rtag('evaluee', 'Personne', 'subject'), set(('secondary', 'link'))) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
60 |
# self.assertEqual(rtags.is_inlined('evaluee', 'Personne', 'subject'), False) |
1533 | 61 |
|
62 |
||
63 |
def test_rtagset_expansion(self): |
|
64 |
rtags = RelationTagsSet() |
|
1739 | 65 |
rtags.tag_subject_of(('Societe', 'travaille', '*'), 'primary') |
66 |
rtags.tag_subject_of(('*', 'travaille', '*'), 'secondary') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
67 |
self.assertEqual(rtags.get('Societe', 'travaille', '*', 'subject'), |
1721
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
68 |
set(('primary', 'secondary'))) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
69 |
self.assertEqual(rtags.get('Note', 'travaille', '*', 'subject'), |
1721
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
70 |
set(('secondary',))) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
71 |
self.assertEqual(rtags.get('Note', 'tags', "*", 'subject'), |
1721
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
72 |
set()) |
1284 | 73 |
|
2369
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
74 |
def test_rtagdict_expansion(self): |
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
75 |
rtags = RelationTagsDict() |
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
76 |
rtags.tag_subject_of(('Societe', 'travaille', '*'), |
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
77 |
{'key1': 'val1', 'key2': 'val1'}) |
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
78 |
rtags.tag_subject_of(('*', 'travaille', '*'), |
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
79 |
{'key1': 'val0', 'key3': 'val0'}) |
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
80 |
rtags.tag_subject_of(('Societe', 'travaille', '*'), |
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
81 |
{'key2': 'val2'}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
82 |
self.assertEqual(rtags.get('Societe', 'travaille', '*', 'subject'), |
2369
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
83 |
{'key1': 'val1', 'key2': 'val2', 'key3': 'val0'}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
84 |
self.assertEqual(rtags.get('Note', 'travaille', '*', 'subject'), |
2369
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
85 |
{'key1': 'val0', 'key3': 'val0'}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
86 |
self.assertEqual(rtags.get('Note', 'tags', "*", 'subject'), |
2369
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
87 |
{}) |
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
88 |
|
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
89 |
rtags.setdefault(('Societe', 'travaille', '*', 'subject'), 'key1', 'val4') |
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
90 |
rtags.setdefault(('Societe', 'travaille', '*', 'subject'), 'key4', 'val4') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
91 |
self.assertEqual(rtags.get('Societe', 'travaille', '*', 'subject'), |
2369
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
92 |
{'key1': 'val1', 'key2': 'val2', 'key3': 'val0', 'key4': 'val4'}) |
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
93 |
|
1284 | 94 |
if __name__ == '__main__': |
95 |
unittest_main() |