Example #1
0
    def test_sh_addons(self):
        lines = ['#!/bin/bash\n\n', 'A=$((1+1))']
        filename = todo.CONFIG['TODO_ACTIONS_DIR'] + '/addnums'
        if not os.path.exists(filename):
            with open(filename, 'w+') as fd:
                fd.writelines(lines)
        os.chmod(filename, 0700)

        args = ['addnums']
        self.assertEqual(todo.execute_commands(args), 0)
        os.unlink(filename)
        self.assertEqual(todo.execute_commands(args), 1)
Example #2
0
    def test_sh_addons(self):
        lines = ['#!/bin/bash\n\n', 'A=$((1+1))']
        filename = todo.CONFIG['TODO_ACTIONS_DIR'] + '/addnums'
        if not os.path.exists(filename):
            with open(filename, 'w+') as fd:
                fd.writelines(lines)
        os.chmod(filename, 0700)

        args = ['addnums']
        self.assertEqual(todo.execute_commands(args), 0)
        os.unlink(filename)
        self.assertEqual(todo.execute_commands(args), 1)
Example #3
0
    def test_py_addons(self):
        lines = ['def addp():\n', '\tpass', '\n\n',
            'commands = {"addp": (False, addp)}\n']
        filename = todo.CONFIG['TODO_ACTIONS_DIR'] + '/addp.py'
        if not os.path.exists(filename):
            with open(filename, 'w+') as fd:
                fd.writelines(lines)

        todo.CONFIG['ACTIONS'] = 'addp'
        commands = todo.commands.copy()
        todo.load_actions()

        args = ['addp', '']
        self.assertEqual(todo.execute_commands(args), 0)
        os.unlink(filename)
        os.unlink(filename + 'c')
        todo.CONFIG['ACTIONS'] = ''
        todo.commands = commands.copy()
        self.assertEqual(todo.execute_commands(args), 1)
Example #4
0
    def test_py_addons(self):
        lines = [
            'def addp():\n', '\tpass', '\n\n',
            'commands = {"addp": (False, addp)}\n'
        ]
        filename = todo.CONFIG['TODO_ACTIONS_DIR'] + '/addp.py'
        if not os.path.exists(filename):
            with open(filename, 'w+') as fd:
                fd.writelines(lines)

        todo.CONFIG['ACTIONS'] = 'addp'
        commands = todo.commands.copy()
        todo.load_actions()

        args = ['addp', '']
        self.assertEqual(todo.execute_commands(args), 0)
        os.unlink(filename)
        os.unlink(filename + 'c')
        todo.CONFIG['ACTIONS'] = ''
        todo.commands = commands.copy()
        self.assertEqual(todo.execute_commands(args), 1)
Example #5
0
 def test_noaddons(self):
     bad_args = ['addp', 'foo']
     good_args = ['add', 'foo']
     self.assertEqual(todo.execute_commands(bad_args), 1)
     self.assertEqual(todo.execute_commands(good_args), 0)
Example #6
0
 def test_noaddons(self):
     bad_args = ['addp', 'foo']
     good_args = ['add', 'foo']
     self.assertEqual(todo.execute_commands(bad_args), 1)
     self.assertEqual(todo.execute_commands(good_args), 0)