cubicweb/web/test/unittest_views_cwsources.py
author Florent Cayré <florent.cayre@logilab.fr>
Wed, 04 May 2016 17:07:41 +0200
changeset 11240 1694e6e9ff94
parent 11138 78c8e64f3cef
child 11756 60fed6272771
permissions -rw-r--r--
[forms] Fix edition of TZDatetime attributes Parse the submitted web form values into a timezone-aware datetime (by default, UTC) when such an attribute is edited. This is done using an automatically-selected (by `web.formfield.guess_field`) field named `TZDatetimeField`. Closes #12666598.

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