Logo Search packages:      
Sourcecode: jockey version File versions  Download package

def ui::UITest::test_toggle_handler (   self  ) 

toggle_handler()

Definition at line 275 of file ui.py.

00275                                  :
        '''toggle_handler()'''

        open (os.path.join(OSLib.inst.handler_dir, 'h.py'), 'w').write(
            'import jockey.handlers' + sandbox.h_nochangemod)

        sys.argv = ['ui-test']
        ui = sandbox.TestUI()
        self.stop_capture()

        for h in ui.handlers:
            self.assert_(h.enabled())
            if h.can_change():
                no_change_h = h
            else:
                change_h = h
        assert no_change_h.can_change() != None
        assert change_h.can_change() == None

        # change an unchangeable handler
        # note: don't set a confirmation response, it shouldn't ask here
        self.assertEqual(ui.toggle_handler(no_change_h), False)
        self.assertEqual(ui.pop_error()[1], 'I must live')
        self.assertRaises(IndexError, ui.pop_error)

        # do not confirm change of handler
        ui.confirm_response = False
        self.assertEqual(ui.toggle_handler(change_h), False)
        self.assert_(change_h.enabled())
        self.assertRaises(IndexError, ui.pop_error)

        # confirm change of handler
        ui.confirm_response = True
        self.assertEqual(ui.toggle_handler(change_h), True)
        self.failIf(change_h.enabled())
        self.assertRaises(IndexError, ui.pop_error)

        # enable it again
        ui.confirm_response = True
        self.assertEqual(ui.toggle_handler(change_h), True)
        self.assert_(change_h.enabled())
        self.assertRaises(IndexError, ui.pop_error)

    def test_mode_any(self):


Generated by  Doxygen 1.6.0   Back to index