Example #1
0
    def test_additionMethod(self):
        app = Application()
        app.settings = {
            'additionMethod': self.generateMock('name')[1]
        }

        app.additionMethod()
        self.assertMock('name', app)
Example #2
0
    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))
Example #3
0
    def test_make_settings(self):
        settings = SettingsMock(self)
        app = Application()
        app.modules = {
            'settings': settings,
        }
        app.make_settings()

        settings.assertMethod('make_settings')
Example #4
0
    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)
Example #5
0
    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)
Example #6
0
    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)
Example #7
0
    def test_initQtApp(self, qtapp):
        app = Application()
        app.initQtApp()

        qtapp.assert_called_once_with(sys.argv)
        self.assertEqual(qtapp.return_value, app.qtApp)
Example #8
0
    def test_set_debug(self):
        app = Application()
        app.set_debug(True)

        self.assertEqual(True, app.debug)
Example #9
0
    def test_close(self):
        app = Application()
        app.close()

        self.assertFalse(app.running)