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

    def testDoesNotRunIfUnset(self):
        vi_cmd_data = {'pre_every_motion': None}
        self.vi_run.do_pre_every_motion(vi_cmd_data, 0, 0)
        self.assertEqual(self.vi_run.view.run_command.call_count, 0)

    def testRunsAsExpectedIfSet(self):
        vi_cmd_data = {'pre_every_motion': ['foo', {'bar': 100}]}
        self.vi_run.do_pre_every_motion(vi_cmd_data, 100, 200)
        self.vi_run.view.run_command.assert_called_once_with(
            'foo', {
                'bar': 100,
                'current_iteration': 100,
                'total_iterations': 200
            })

    def testRunsAsExpectedIfMissingArgs(self):
        vi_cmd_data = {'pre_every_motion': ['foo']}
        self.vi_run.do_pre_every_motion(vi_cmd_data, 100, 200)
        self.vi_run.view.run_command.assert_called_once_with(
            'foo', {
                'current_iteration': 100,
                'total_iterations': 200
            })
Пример #2
0
class Test_do_pre_every_motion(unittest.TestCase):
    def setUp(self):
        self.vi_run = ViRunCommand(mock.Mock())

    def testDoesNotRunIfUnset(self):
        vi_cmd_data = {'pre_every_motion': None}
        self.vi_run.do_pre_every_motion(vi_cmd_data, 0, 0)
        self.assertEqual(self.vi_run.view.run_command.call_count, 0)

    def testRunsAsExpectedIfSet(self):
        vi_cmd_data = {'pre_every_motion': ['foo', {'bar': 100}]}
        self.vi_run.do_pre_every_motion(vi_cmd_data, 100, 200)
        self.vi_run.view.run_command.assert_called_once_with('foo', {'bar': 100, 'current_iteration': 100, 'total_iterations': 200})

    def testRunsAsExpectedIfMissingArgs(self):
        vi_cmd_data = {'pre_every_motion': ['foo']}
        self.vi_run.do_pre_every_motion(vi_cmd_data, 100, 200)
        self.vi_run.view.run_command.assert_called_once_with('foo', {'current_iteration': 100, 'total_iterations': 200})