test/test_management.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 09 Mar 2017 17:33:13 +0100
changeset 217 5a0cebef1a8e
parent 176 e1f4c31c2414
child 221 5a5ff6803bc8
permissions -rw-r--r--
[schema] Implement security for top level types (ArchiveTransfer, ArchiveUnit, AuthorityRecord and ConceptScheme). For now, we only need to setup ConceptScheme compound security since it's not done yet by the skos cube, while it is in eac and seda cubes. We need to follow a change in the seda cube to get tests to green. Closes #16684441

# copyright 2017 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr -- mailto:contact@logilab.fr
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 2.1 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from cubicweb.devtools.testlib import CubicWebTC
from cubicweb.web.views import actions


class ActionTC(CubicWebTC):

    def test_management(self):
        with self.admin_access.cnx() as cnx:
            at = cnx.create_entity('SEDAArchiveTransfer', title=u'hop')
            self.create_user(cnx, 'user')
            cnx.commit()

        with self.admin_access.web_request() as req:
            rset = req.entity_from_eid(at.eid).as_rset()
            actionsdict = self.pactionsdict(req, rset)
            self.assertIn(actions.ManagePermissionsAction, actionsdict['moreactions'])

        with self.new_access('user').web_request() as req:
            rset = req.entity_from_eid(at.eid).as_rset()
            actionsdict = self.pactionsdict(req, rset)
            self.assertNotIn(actions.ManagePermissionsAction, actionsdict['moreactions'])


if __name__ == '__main__':
    import unittest
    unittest.main()