1 # copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
1 # copyright 2003-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
3 # |
3 # |
4 # This file is part of CubicWeb. |
4 # This file is part of CubicWeb. |
5 # |
5 # |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
13 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
13 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
14 # details. |
14 # details. |
15 # |
15 # |
16 # You should have received a copy of the GNU Lesser General Public License along |
16 # You should have received a copy of the GNU Lesser General Public License along |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
18 """ |
|
19 |
18 |
20 """ |
19 import unittest |
21 from logilab.common.testlib import TestCase, unittest_main |
20 |
22 from cubicweb.rtags import RelationTags, RelationTagsSet, RelationTagsDict |
21 from cubicweb.rtags import RelationTags, RelationTagsSet, RelationTagsDict |
23 |
22 |
24 class RelationTagsTC(TestCase): |
23 class RelationTagsTC(unittest.TestCase): |
25 |
24 |
26 def test_rtags_expansion(self): |
25 def test_rtags_expansion(self): |
27 rtags = RelationTags() |
26 rtags = RelationTags() |
28 rtags.tag_subject_of(('Societe', 'travaille', '*'), 'primary') |
27 rtags.tag_subject_of(('Societe', 'travaille', '*'), 'primary') |
29 rtags.tag_subject_of(('*', 'evaluee', '*'), 'secondary') |
28 rtags.tag_subject_of(('*', 'evaluee', '*'), 'secondary') |
90 rtags.setdefault(('Societe', 'travaille', '*', 'subject'), 'key4', 'val4') |
89 rtags.setdefault(('Societe', 'travaille', '*', 'subject'), 'key4', 'val4') |
91 self.assertEqual(rtags.get('Societe', 'travaille', '*', 'subject'), |
90 self.assertEqual(rtags.get('Societe', 'travaille', '*', 'subject'), |
92 {'key1': 'val1', 'key2': 'val2', 'key3': 'val0', 'key4': 'val4'}) |
91 {'key1': 'val1', 'key2': 'val2', 'key3': 'val0', 'key4': 'val4'}) |
93 |
92 |
94 if __name__ == '__main__': |
93 if __name__ == '__main__': |
95 unittest_main() |
94 unittest.main() |