コード例 #1
0
def main():
    global app, host, port
    app = create_app()
    host, port = app.config['HOST'], app.config['PORT']
    run_scheduler(app)
    ensure_indices(app)
    app.run(host=host, port=port)
コード例 #2
0
    def test_run_scheduler_starts_expire_sessions_job(self,
                                                      expire_sessions_mock,
                                                      scheduler_cls_mock):
        scheduler_mock = mock.MagicMock()
        scheduler_cls_mock.return_value = scheduler_mock

        run_scheduler(mock.sentinel.app)

        self.assertTrue(scheduler_mock.add_interval_job.called)
        args = scheduler_mock.add_interval_job.call_args
        self.assertEqual(len(args[0]), 1)
        self.assertEqual(len(args[1]), 1)
        func = args[0][0]
        secs = args[1]['seconds']

        func()
        expire_sessions_mock.assert_called_with(mock.sentinel.app)
        self.assertEqual(secs, EXPIRE_SESSION_EVERY)