web/test/unittest_views_xmlrss.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 09 Sep 2015 08:32:49 +0200
changeset 10637 a8b33789b982
parent 9828 ad0d461ae18b
child 10245 7d21c6ac47a3
permissions -rw-r--r--
[autoform] fix appearance of link to add inlined creation form On entity creation, if there are some local permissions on the relation, we have no way of checking them since neither the subject nor the object of the relation exists yet. In such a case, we should add the link by default, for consistency (see other places where we use `may_have_permission`). Closes #6711900

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">
  <login>admin</login>
  <upassword/>
  <firstname/>
  <surname/>
  <last_login_time/>
  <creation_date>%(cdate)s</creation_date>
  <modification_date>%(mdate)s</modification_date>
  <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()