def test_main_works(self): main.make_app().AndReturn(self.fake_app) jobs = [self.mox.CreateMock(PeriodicJob), self.mox.CreateMock(PeriodicJob)] main.setup_logging(self.fake_app) main.check_connection(self.fake_app).AndReturn(True) main.instances_jobs.jobs_factory(self.fake_app).AndReturn(jobs) self.fake_app.run(use_reloader=False, host='127.0.0.1', port=42) jobs[0].cancel().AndRaise(RuntimeError('ignore me')) jobs[1].cancel() self.mox.ReplayAll() main.main()
def test_main_works(self): main.make_app().AndReturn(self.fake_app) jobs = [ self.mox.CreateMock(PeriodicJob), self.mox.CreateMock(PeriodicJob) ] main.setup_logging(self.fake_app) main.check_connection(self.fake_app).AndReturn(True) main.instances_jobs.jobs_factory(self.fake_app).AndReturn(jobs) self.fake_app.run(use_reloader=False, host='127.0.0.1', port=42) jobs[0].cancel().AndRaise(RuntimeError('ignore me')) jobs[1].cancel() self.mox.ReplayAll() main.main()
def test_main_check_failed(self): main.make_app().AndReturn(self.fake_app) main.setup_logging(self.fake_app) main.check_connection(self.fake_app).AndReturn(False) self.mox.ReplayAll() self.assertRaises(SystemExit, main.main)
def test_check_connection_fail(self): self.mox.StubOutWithMock(main.auth, 'api_client_set') main.auth.api_client_set().AndRaise(RuntimeError('catch_me')) self.mox.ReplayAll() self.assertEquals(False, main.check_connection(self.app))
def test_check_connection_ok(self): self.mox.StubOutWithMock(main.auth, 'api_client_set') main.auth.api_client_set() self.mox.ReplayAll() self.assertEquals(True, main.check_connection(self.app))