[rtags] Allow to 'derive' rtags
Since some releases, rtags (structure underlying uicfg) have selector and may be
copied using something like:
new_rtags = deepcopy(original_rtags)
new_rtags.__module__ = __name__
new_rtags.__select__ = custom_selector
The problem is that starting from that, both rtags wil diverge and changes in
original_rtags won't be considered, while we usually want to set a few specific
rules only in new_rtags. To fix this problem, this cset introduces the notion of
"derivated/parent" rtag, eg:
new_rtags = original_rtags.derive(__name__, custom_selector)
Beside easier copying, when using the above method changes in original_rtags
which are not overriden by new_rtags will be considered since it only hold its
specific rules but look among its parent chain for non-found keys.
Along the way, flake8 unittest_rtags.
Closes #16164880
from cubicweb.devtools.testlib import CubicWebTC
from cubicweb.web.views.xmlrss import SERIALIZERS
class EntityXMLViewTC(CubicWebTC):
"""see also cw.sobjects.test.unittest_parsers"""
def test(self):
rels = ['tags-object', 'in_group-subject',
'in_state-subject', 'use_email-subject']
with self.admin_access.web_request(relation=rels) as req:
self.assertMultiLineEqual(
req.user.view('xml'),
'''\
<CWUser eid="6" cwuri="http://testing.fr/cubicweb/6" cwsource="system">
<creation_date>%(cdate)s</creation_date>
<firstname/>
<last_login_time/>
<login>admin</login>
<modification_date>%(mdate)s</modification_date>
<surname/>
<upassword/>
<tags role="object">
</tags>
<in_group role="subject">
<CWGroup eid="%(group_eid)s" cwuri="http://testing.fr/cubicweb/%(group_eid)s"/>
</in_group>
<in_state role="subject">
<State eid="%(state_eid)s" cwuri="http://testing.fr/cubicweb/%(state_eid)s" name="activated"/>
</in_state>
<use_email role="subject">
</use_email>
</CWUser>
''' % {'cdate': SERIALIZERS['Datetime'](req.user.creation_date),
'mdate': SERIALIZERS['Datetime'](req.user.modification_date),
'state_eid': req.user.in_state[0].eid,
'group_eid': req.user.in_group[0].eid})
if __name__ == '__main__':
from logilab.common.testlib import unittest_main
unittest_main()