Beispiel #1
0
    def tearDown(self):
        """
        Restore the viewunit state to where it was before the tests
        """
        super(HookTest, self).tearDown()

        config.set_app(self._old_app)
        config.set_session_user_setter(self._old_session_hook)
        config.set_db_select_hook(self._old_db_hook)
Beispiel #2
0
    def test_db_hook(self):
        config.set_app(app)

        try:
            self.run_view('/', expect_db_has=[('tables', {'foo': 1})])
            ok_(False, "Expected AssertionError without session hook")
        except AssertionError:
            pass

        # Huge hack: Return a tuple no matter the query -- it's just being
        # len()ed anyway
        def db_select(_sql, _params):
            return [(1,)]

        config.set_db_select_hook(db_select)
        self.run_view('/', expect_db_has=[('tables', {'foo': 1})])