cubicweb/hooks/test/unittest_syncsources.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 12 Apr 2017 16:07:25 +0200
branch3.25
changeset 12152 f34d18d0603f
child 12153 0ff0aff4413d
permissions -rw-r--r--
[sources] Check sources configuration is fine on creation/modification Reintroduce usage of 'source.check_config' which had almost disappeared, as well as tests for the currently detected errors. Part of the system source specific checking done in syncsources reimplemented in a specific check_config implementation. Tests are dispatched among ldap / datafeed and syncsources tests but are not strictly correctly located (notably syncsources tests behaviour of the native source's check_config). The system source url checking part which disappears from syncsources will be reintroduced in a follow-up.

# copyright 2017 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
#
# CubicWeb 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.
#
# CubicWeb 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 CubicWeb.  If not, see <http://www.gnu.org/licenses/>.

from cubicweb import ValidationError
from cubicweb.devtools.testlib import CubicWebTC


class SyncSourcesTC(CubicWebTC):

    def test_cant_add_config_system_source(self):
        with self.admin_access.cnx() as cnx:
            source = cnx.find('CWSource').one()

            with self.assertRaises(ValidationError):
                source.cw_set(config=u'whatever')


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