cubicweb/web/test/unittest_views_cwsources.py
author Denis Laxalde <denis.laxalde@logilab.fr>
Mon, 26 Sep 2016 18:20:53 +0200
changeset 11685 6c263b8091d3
parent 11138 78c8e64f3cef
child 11756 60fed6272771
permissions -rw-r--r--
[pkg] Declare extras (optional) dependencies This is primary to extract "pyramid" dependencies out of install_requires as they are actually optional. Along the way, resurrect all things in __pkginfo__.__recommends__ which were not used at all and convert them into extra_requires. It appears that __depends__ and __recommends__ in __pkginfo__.py are not useful so drop them and inline dependencies as install_requires/extra_requires in setup function call. For pyramid tests to continue working, add respective dependencies to test-misc.txt requirements file.

from logilab.common import tempattr
from cubicweb.devtools.testlib import CubicWebTC


class SynchronizeSourceTC(CubicWebTC):
    def test_synchronize_view(self):
        with self.admin_access.web_request(vid='cw.source-sync') as req:
            source = req.create_entity('CWSource', name=u'ext', type=u'datafeed',
                                       parser=u'cw.entityxml')
            req.cnx.commit()

            self.threads = 0

            def threaded_task(func):
                self.threads += 1

            with tempattr(req.cnx.repo, 'threaded_task', threaded_task):
                path, args = self.expect_redirect_handle_request(
                    req, path=source.rest_path())
                self.assertEqual(self.threads, 1)
                self.assertTrue(path.startswith('cwdataimport/'))


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