author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Thu, 11 Jun 2009 19:04:20 +0200 | |
branch | stable |
changeset 2100 | 89b825cdec74 |
parent 1977 | 606923dff11b |
child 2369 | 5a2b8ed266ca |
permissions | -rw-r--r-- |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1739
diff
changeset
|
1 |
""" |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1739
diff
changeset
|
2 |
|
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1739
diff
changeset
|
3 |
:organization: Logilab |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1739
diff
changeset
|
4 |
: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:
1739
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:
1739
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:
1739
diff
changeset
|
7 |
""" |
1284 | 8 |
from logilab.common.testlib import TestCase, unittest_main |
1533 | 9 |
from cubicweb.rtags import RelationTags, RelationTagsSet |
1284 | 10 |
|
11 |
class RelationTagsTC(TestCase): |
|
1533 | 12 |
|
1284 | 13 |
def test_rtags_expansion(self): |
14 |
rtags = RelationTags() |
|
1739 | 15 |
rtags.tag_subject_of(('Societe', 'travaille', '*'), 'primary') |
16 |
rtags.tag_subject_of(('*', 'evaluee', '*'), 'secondary') |
|
17 |
rtags.tag_object_of(('*', 'tags', '*'), 'generated') |
|
1721
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
18 |
self.assertEquals(rtags.get('Note', 'evaluee', '*', 'subject'), |
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
19 |
'secondary') |
1739 | 20 |
self.assertEquals(rtags.get('Societe', 'travaille', '*', 'subject'), |
1721
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
21 |
'primary') |
1739 | 22 |
self.assertEquals(rtags.get('Note', 'travaille', '*', 'subject'), |
1721
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
23 |
None) |
1739 | 24 |
self.assertEquals(rtags.get('Note', 'tags', '*', 'subject'), |
1721
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
25 |
None) |
1739 | 26 |
self.assertEquals(rtags.get('*', 'tags', 'Note', 'object'), |
1721
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
27 |
'generated') |
1739 | 28 |
self.assertEquals(rtags.get('Tag', 'tags', '*', 'object'), |
1721
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
29 |
'generated') |
1533 | 30 |
|
1284 | 31 |
# self.assertEquals(rtags.rtag('evaluee', 'Note', 'subject'), set(('secondary', 'link'))) |
32 |
# self.assertEquals(rtags.is_inlined('evaluee', 'Note', 'subject'), False) |
|
33 |
# self.assertEquals(rtags.rtag('evaluee', 'Personne', 'subject'), set(('secondary', 'link'))) |
|
34 |
# self.assertEquals(rtags.is_inlined('evaluee', 'Personne', 'subject'), False) |
|
35 |
# self.assertEquals(rtags.rtag('ecrit_par', 'Note', 'object'), set(('inlineview', 'link'))) |
|
36 |
# self.assertEquals(rtags.is_inlined('ecrit_par', 'Note', 'object'), True) |
|
37 |
# class Personne2(Personne): |
|
38 |
# id = 'Personne' |
|
39 |
# __rtags__ = { |
|
40 |
# ('evaluee', 'Note', 'subject') : set(('inlineview',)), |
|
41 |
# } |
|
42 |
# self.vreg.register_vobject_class(Personne2) |
|
43 |
# rtags = Personne2.rtags |
|
44 |
# self.assertEquals(rtags.rtag('evaluee', 'Note', 'subject'), set(('inlineview', 'link'))) |
|
45 |
# self.assertEquals(rtags.is_inlined('evaluee', 'Note', 'subject'), True) |
|
46 |
# self.assertEquals(rtags.rtag('evaluee', 'Personne', 'subject'), set(('secondary', 'link'))) |
|
1533 | 47 |
# self.assertEquals(rtags.is_inlined('evaluee', 'Personne', 'subject'), False) |
48 |
||
49 |
||
50 |
def test_rtagset_expansion(self): |
|
51 |
rtags = RelationTagsSet() |
|
1739 | 52 |
rtags.tag_subject_of(('Societe', 'travaille', '*'), 'primary') |
53 |
rtags.tag_subject_of(('*', 'travaille', '*'), 'secondary') |
|
54 |
self.assertEquals(rtags.get('Societe', 'travaille', '*', 'subject'), |
|
1721
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
55 |
set(('primary', 'secondary'))) |
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
56 |
self.assertEquals(rtags.get('Societe', 'travaille', '*', 'subject'), |
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
57 |
set(('primary', 'secondary'))) |
1739 | 58 |
self.assertEquals(rtags.get('Note', 'travaille', '*', 'subject'), |
1721
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
59 |
set(('secondary',))) |
1739 | 60 |
self.assertEquals(rtags.get('Note', 'tags', "*", 'subject'), |
1721
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
61 |
set()) |
1284 | 62 |
|
63 |
if __name__ == '__main__': |
|
64 |
unittest_main() |