pyramid_cubicweb/tests/test_entities.py
author Christophe de Vienne <christophe@unlish.com>
Tue, 09 Jun 2015 11:34:17 +0200
changeset 11596 1f2570f1d72a
permissions -rw-r--r--
[routes] Add a 'cwentities' route with traversal The route uses a factory that produces ETypeResource and EntityResource as a context. A 'delete' view serve as a test and demonstration. The module being experimental, it has to be explicitely included.

from __future__ import absolute_import

from . import PyramidCWTest


class EntitiesTest(PyramidCWTest):
    def includeme(self, config):
        config.include('pyramid_cubicweb.entities')

    def test_delete(self):
        with self.admin_access.repo_cnx() as cnx:
            cnx.create_entity('CWGroup', name=u'tmp')
            cnx.commit()

        self.login()
        res = self.webapp.delete('/cwgroup/tmp')
        self.assertEqual(res.status_int, 204)

        with self.admin_access.repo_cnx() as cnx:
            self.assertEqual(cnx.find('CWGroup', name=u'tmp').rowcount, 0)