示例#1
0
    def test_handle_action(self):
        dialog = StatusDialog()
        manager = ResourceStatusManager.get_instance()

        action = ResourceStatusAction(object(), 'foo', 'bar', lambda: None,
                                      threaded=False)
        with mock.patch.object(manager, 'handle_action') as handle_action:
            dialog._handle_action(action)
            self.assertCalledOnceWith(handle_action, action)
示例#2
0
    def test_handle_action(self):
        dialog = StatusDialog()
        manager = ResourceStatusManager.get_instance()

        action = ResourceStatusAction(object(),
                                      'foo',
                                      'bar',
                                      lambda: None,
                                      threaded=False)
        with mock.patch.object(manager, 'handle_action') as handle_action:
            dialog._handle_action(action)
            self.assertCalledOnceWith(handle_action, action)
示例#3
0
    def test_handle_action_threaded(self, ProgressDialog):
        ProgressDialog.return_value = mock.Mock()

        dialog = StatusDialog()
        manager = ResourceStatusManager.get_instance()

        action = ResourceStatusAction(Settable(label='baz'), 'foo', 'bar',
                                      lambda: None, threaded=True)
        with mock.patch.object(manager, 'handle_action') as handle_action:
            t = mock.Mock()
            t.is_alive.return_value = False

            handle_action.return_value = t
            dialog._handle_action(action)

            self.assertCalledOnceWith(handle_action, action)
            self.assertCalledOnceWith(
                ProgressDialog,
                'Executing "bar". This might take a while...', pulse=True)
示例#4
0
    def test_handle_action_threaded(self, ProgressDialog):
        ProgressDialog.return_value = mock.Mock()

        dialog = StatusDialog()
        manager = ResourceStatusManager.get_instance()

        action = ResourceStatusAction(Settable(label='baz'),
                                      'foo',
                                      'bar',
                                      lambda: None,
                                      threaded=True)
        with mock.patch.object(manager, 'handle_action') as handle_action:
            t = mock.Mock()
            t.is_alive.return_value = False

            handle_action.return_value = t
            dialog._handle_action(action)

            self.assertCalledOnceWith(handle_action, action)
            self.assertCalledOnceWith(
                ProgressDialog,
                'Executing "bar". This might take a while...',
                pulse=True)
示例#5
0
 def test_create(self):
     dialog = StatusDialog()
     self.check_dialog(dialog, 'dialog-status')