Esempio n. 1
0
 def setUp(self):
     self.taskdata = tempfile.mkdtemp()
     taskrc = os.path.join(os.path.dirname(__file__), 'data/empty.taskrc')
     self.taskwarrior = TaskWarrior(
         config_filename=taskrc,
         config_overrides={'data.location': self.taskdata})
     # Just a sanity check to make sure that after the setup, the list of
     # tasks is empty, otherwise we are probably using the current user's
     # TASKDATA and we should not continue.
     assert self.taskwarrior.load_tasks() == {
         'completed': [],
         'pending': []
     }
Esempio n. 2
0
 def test_load_config(self):
     expected = {
         'data': {
             'location': '~/.task'
         },
         'alpha': {
             'one': 'yes',
             'two': '2',
         },
         'beta': {
             'one': 'FALSE',
         },
         'gamma': {
             'one': 'TRUE',
         },
         'uda': {
             'a': {
                 'type': 'numeric',
                 'label': 'Alpha',
             },
             'b': {
                 'type': 'string',
                 'label': 'Beta',
                 'values': 'Strontium-90,Hydrogen-3',
             }
         }
     }
     config = TaskWarrior.load_config(self.path_to_taskrc)
     self.assertEqual(config, expected)
Esempio n. 3
0
class TestTaskWarrior(object):
    def setUp(self):
        self.taskdata = tempfile.mkdtemp()
        taskrc = os.path.join(os.path.dirname(__file__), 'data/empty.taskrc')
        self.taskwarrior = TaskWarrior(
            config_filename=taskrc,
            config_overrides={'data.location': self.taskdata})
        # Just a sanity check to make sure that after the setup, the list of
        # tasks is empty, otherwise we are probably using the current user's
        # TASKDATA and we should not continue.
        assert self.taskwarrior.load_tasks() == {
            'completed': [],
            'pending': []
        }

    def tearDown(self):
        # Remove the directory after the test
        shutil.rmtree(self.taskdata)

    def test_add_task_foobar(self):
        """ Add a task with description 'foobar' and checks that the task is
        indeed created """
        self.taskwarrior.task_add("foobar")
        tasks = self.taskwarrior.load_tasks()
        assert len(tasks['pending']) == 1
        assert tasks['pending'][0]['description'] == 'foobar'

    def test_add_task_null_char(self):
        """ Try adding a task where the description contains a NULL character
        (0x00). This should not fail but instead simply add a task with the
        same description minus the NULL character """
        self.taskwarrior.task_add("foo\x00bar")
        tasks = self.taskwarrior.load_tasks()
        assert len(tasks['pending']) == 1
        assert tasks['pending'][0]['description'] == 'foobar'
Esempio n. 4
0
class TestTaskWarrior(object):
    def setUp(self):
        self.taskdata = tempfile.mkdtemp()
        taskrc = os.path.join(os.path.dirname(__file__), 'data/empty.taskrc')
        self.taskwarrior = TaskWarrior(
            config_filename=taskrc,
            config_overrides={'data.location': self.taskdata})
        # Just a sanity check to make sure that after the setup, the list of
        # tasks is empty, otherwise we are probably using the current user's
        # TASKDATA and we should not continue.
        assert self.taskwarrior.load_tasks() == {'completed': [], 'pending': []}

    def tearDown(self):
        # Remove the directory after the test
        shutil.rmtree(self.taskdata)

    def test_add_task_foobar(self):
        """ Add a task with description 'foobar' and checks that the task is
        indeed created """
        self.taskwarrior.task_add("foobar")
        tasks = self.taskwarrior.load_tasks()
        assert len(tasks['pending']) == 1
        assert tasks['pending'][0]['description'] == 'foobar'

    def test_add_task_null_char(self):
        """ Try adding a task where the description contains a NULL character
        (0x00). This should not fail but instead simply add a task with the
        same description minus the NULL character """
        self.taskwarrior.task_add("foo\x00bar")
        tasks = self.taskwarrior.load_tasks()
        assert len(tasks['pending']) == 1
        assert tasks['pending'][0]['description'] == 'foobar'
Esempio n. 5
0
 def setUp(self):
     self.taskdata = tempfile.mkdtemp()
     taskrc = os.path.join(os.path.dirname(__file__), 'data/empty.taskrc')
     self.taskwarrior = TaskWarrior(
         config_filename=taskrc,
         config_overrides={'data.location': self.taskdata})
     # Just a sanity check to make sure that after the setup, the list of
     # tasks is empty, otherwise we are probably using the current user's
     # TASKDATA and we should not continue.
     assert self.taskwarrior.load_tasks() == {'completed': [], 'pending': []}