cubicweb/devtools/test/unittest_qunit.py
author Philippe Pepiot <ph@itsalwaysdns.eu>
Tue, 31 Mar 2020 19:15:03 +0200
changeset 12957 0c973204033a
parent 12824 bc623a3e44e9
permissions -rw-r--r--
[server] prevent returning closed cursor to the database pool In since c8c6ad8 init_repository use repo.internal_cnx() instead of repo.system_source.get_connection() so it use the pool and we should not close cursors from the pool before returning it back. Otherwise we may have "connection already closed" error. This bug only trigger when connection-pool-size = 1. Since we are moving to use a dynamic pooler we need to get this fixed. This does not occur with sqlite since the connection wrapper instantiate new cursor everytime, but this occur with other databases.

from unittest import SkipTest

from cubicweb.devtools import qunit


def js(name):
    return '/static/js_examples/' + name


class QUnitTestCaseTC(qunit.QUnitTestCase):

    timeout_error = SkipTest
    all_js_tests = (
        (js('test_simple_success.js'),),
        (js('test_with_dep.js'), (js('dep_1.js'),)),
        (js('test_with_ordered_deps.js'), (js('dep_1.js'), js('deps_2.js'),)),
    )

    def test_simple_failure(self):
        js_tests = list(self._test_qunit(js('test_simple_failure.js')))
        self.assertEqual(len(js_tests), 3)
        test_1, test_2, test_3 = js_tests
        self.assertRaises(self.failureException, test_1[1], *test_1[2:])
        self.assertRaises(self.failureException, test_2[1], *test_2[2:])
        test_3[1](*test_3[2:])


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