Пример #1
0
class Test_do_whole_motion(unittest.TestCase):
    def setUp(self):
        self.vi_run = ViRunCommand(mock.Mock())

    def testAbortsIfMustRepeatAction(self):
        vi_cmd_data = {'_repeat_action': True}
        with mock.patch.object(self.vi_run, 'do_pre_motion') as dprem:
            self.vi_run.do_whole_motion(vi_cmd_data)
            self.assertEqual(dprem.call_count, 0)

    def testCallsAllSteps(self):
        vi_cmd_data = {
            '_repeat_action': False,
            'count': 1,
            'last_motion': False,
        }

        with mock.patch.object(self.vi_run, 'reorient_caret') as rec, \
             mock.patch.object(self.vi_run, 'do_pre_motion') as dprm, \
             mock.patch.object(self.vi_run, 'do_pre_every_motion') as dprem, \
             mock.patch.object(self.vi_run, 'do_motion') as dm, \
             mock.patch.object(self.vi_run, 'do_post_every_motion') as dpostem, \
             mock.patch.object(self.vi_run, 'do_last_motion') as dlm, \
             mock.patch.object(self.vi_run, 'do_post_motion') as dpostm, \
             mock.patch.object(self.vi_run, 'reposition_caret') as repc, \
             mock.patch.object(self.vi_run, 'add_to_jump_list') as addtjl:

            self.vi_run.do_whole_motion(vi_cmd_data)

            self.assertEqual(rec.call_count, 1)
            self.assertEqual(dprm.call_count, 1)
            self.assertEqual(dprem.call_count, 1)
            self.assertEqual(dm.call_count, 1)
            self.assertEqual(dpostem.call_count, 1)
            self.assertEqual(dlm.call_count, 0)
            self.assertEqual(dpostm.call_count, 1)
            self.assertEqual(repc.call_count, 1)
            self.assertEqual(addtjl.call_count, 1)

    def testCallsAllStepsNeededIfLastMotionPresent(self):
        vi_cmd_data = {
            '_repeat_action': False,
            'count': 1,
            'last_motion': '_whatever',
        }

        with mock.patch.object(self.vi_run, 'reorient_caret') as rec, \
             mock.patch.object(self.vi_run, 'do_pre_motion') as dprm, \
             mock.patch.object(self.vi_run, 'do_pre_every_motion') as dprem, \
             mock.patch.object(self.vi_run, 'do_motion') as dm, \
             mock.patch.object(self.vi_run, 'do_post_every_motion') as dpostem, \
             mock.patch.object(self.vi_run, 'do_last_motion') as dlm, \
             mock.patch.object(self.vi_run, 'do_post_motion') as dpostm, \
             mock.patch.object(self.vi_run, 'reposition_caret') as repc, \
             mock.patch.object(self.vi_run, 'add_to_jump_list') as addtjl:

            self.vi_run.do_whole_motion(vi_cmd_data)

            self.assertEqual(rec.call_count, 1)
            self.assertEqual(dprm.call_count, 1)
            self.assertEqual(dprem.call_count, 1)
            self.assertEqual(dm.call_count, 0)
            self.assertEqual(dpostem.call_count, 0)
            self.assertEqual(dlm.call_count, 1)
            self.assertEqual(dpostm.call_count, 1)
            self.assertEqual(repc.call_count, 1)
            self.assertEqual(addtjl.call_count, 1)
Пример #2
0
class Test_do_whole_motion(unittest.TestCase):
    def setUp(self):
        self.vi_run = ViRunCommand(mock.Mock())

    def testAbortsIfMustRepeatAction(self):
        vi_cmd_data = { '_repeat_action': True}
        with mock.patch.object(self.vi_run, 'do_pre_motion') as dprem:
            self.vi_run.do_whole_motion(vi_cmd_data)
            self.assertEqual(dprem.call_count, 0)

    def testCallsAllSteps(self):
        vi_cmd_data = { '_repeat_action': False,
                        'count': 1,
                        'last_motion': False,
                      }

        with mock.patch.object(self.vi_run, 'reorient_caret') as rec, \
             mock.patch.object(self.vi_run, 'do_pre_motion') as dprm, \
             mock.patch.object(self.vi_run, 'do_pre_every_motion') as dprem, \
             mock.patch.object(self.vi_run, 'do_motion') as dm, \
             mock.patch.object(self.vi_run, 'do_post_every_motion') as dpostem, \
             mock.patch.object(self.vi_run, 'do_last_motion') as dlm, \
             mock.patch.object(self.vi_run, 'do_post_motion') as dpostm, \
             mock.patch.object(self.vi_run, 'reposition_caret') as repc, \
             mock.patch.object(self.vi_run, 'add_to_jump_list') as addtjl:

            self.vi_run.do_whole_motion(vi_cmd_data)

            self.assertEqual(rec.call_count, 1)
            self.assertEqual(dprm.call_count, 1)
            self.assertEqual(dprem.call_count, 1)
            self.assertEqual(dm.call_count, 1)
            self.assertEqual(dpostem.call_count, 1)
            self.assertEqual(dlm.call_count, 0)
            self.assertEqual(dpostm.call_count, 1)
            self.assertEqual(repc.call_count, 1)
            self.assertEqual(addtjl.call_count, 1)

    def testCallsAllStepsNeededIfLastMotionPresent(self):
        vi_cmd_data = { '_repeat_action': False,
                        'count': 1,
                        'last_motion': '_whatever',
                      }

        with mock.patch.object(self.vi_run, 'reorient_caret') as rec, \
             mock.patch.object(self.vi_run, 'do_pre_motion') as dprm, \
             mock.patch.object(self.vi_run, 'do_pre_every_motion') as dprem, \
             mock.patch.object(self.vi_run, 'do_motion') as dm, \
             mock.patch.object(self.vi_run, 'do_post_every_motion') as dpostem, \
             mock.patch.object(self.vi_run, 'do_last_motion') as dlm, \
             mock.patch.object(self.vi_run, 'do_post_motion') as dpostm, \
             mock.patch.object(self.vi_run, 'reposition_caret') as repc, \
             mock.patch.object(self.vi_run, 'add_to_jump_list') as addtjl:

            self.vi_run.do_whole_motion(vi_cmd_data)

            self.assertEqual(rec.call_count, 1)
            self.assertEqual(dprm.call_count, 1)
            self.assertEqual(dprem.call_count, 1)
            self.assertEqual(dm.call_count, 0)
            self.assertEqual(dpostem.call_count, 0)
            self.assertEqual(dlm.call_count, 1)
            self.assertEqual(dpostm.call_count, 1)
            self.assertEqual(repc.call_count, 1)
            self.assertEqual(addtjl.call_count, 1)