cubicweb/web/test/unittest_views_xmlrss.py
author Denis Laxalde <denis.laxalde@logilab.fr>
Thu, 21 Mar 2019 14:33:54 +0100
changeset 12530 9d88e1177c35
parent 11057 0b59724cb3f2
permissions -rw-r--r--
Remove Twisted web server Twisted web server is not used anymore and has been superseded by pyramid many years ago. Furthermore, our usage is not compatible with Python 3. So we drop the "etwist" sub-package. As a consequence, "all-in-one" configuration type gets dropped as it was Twisted-specific. We resurrect it in cubicweb/pyramid/config.py by only keeping options used by the "pyramid". Similarly, we introduce a AllInOneCreateHandler in cubicweb/pyramid/pyramidctl.py that is basically the one that lived in cubicweb/etwist/twctl.py and is used to create the "all-in-one" instance. Added a TODO here about "pyramid.ini" that could be generated at the end of bootstrap() method. In cubicweb/devtools/httptest.py, CubicWebServerTC is now equivalent to CubicWebWsgiTC and the latter is dropped.

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()