def test_additionMethod(self): app = Application() app.settings = { 'additionMethod': self.generateMock('name')[1] } app.additionMethod() self.assertMock('name', app)
def test_createMainWindow(self): from bluebaker.topwindow import TopWindow app = Application() app.settings = { 'top window title': 'my top window title', } app.createTopWindow() self.assertEqual(TopWindow, type(app.main))
def test_make_settings(self): settings = SettingsMock(self) app = Application() app.modules = { 'settings': settings, } app.make_settings() settings.assertMethod('make_settings')
def test_mainloop(self): app = Application() qtApp = QtAppMock(app) with nested( patch.object(app, 'qtApp', qtApp), patch.object(app, 'sleep'), ): app.mainloop() self.assertEqual(4, qtApp._processEvents) self.assertTrue(qtApp._hasPendingEvents)
def test_run(self): def mockup(self): self._mainloop = True app = Application() with nested( patch.object(app, 'createTopWindow'), patch.object(Application, 'mainloop', mockup), patch('bluebaker.app.info'), ) as (createTopWindow, mainloop, info): app.run() info.assert_called_once_with(' === Program ended ===') self.assertTrue(app._mainloop)
def test_run_KeyboardInterrupt(self): def side_effect(): raise KeyboardInterrupt() def mockup(self): self._mainloop = True app = Application() app._mainloop = False with nested( patch.object(app, 'createTopWindow', side_effect=side_effect), patch.object(Application, 'mainloop', mockup), patch('bluebaker.app.info'), ) as (createTopWindow, mainloop, info): app.run() info.assert_called_with(' === Program ended ===') self.assertFalse(app._mainloop)
def test_initQtApp(self, qtapp): app = Application() app.initQtApp() qtapp.assert_called_once_with(sys.argv) self.assertEqual(qtapp.return_value, app.qtApp)
def test_set_debug(self): app = Application() app.set_debug(True) self.assertEqual(True, app.debug)
def test_close(self): app = Application() app.close() self.assertFalse(app.running)