How to use the tasklib.task.Task function in tasklib

To help you get started, we’ve selected a few tasklib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github robgolding / tasklib / tasklib / tests.py View on Github external
def test_timezone_naive_date_using_init(self):
        t = Task(self.tw, description='test task', due=self.localdate_naive)
        self.assertEqual(t['due'], self.localtime_aware)
github robgolding / tasklib / tasklib / tests.py View on Github external
def test_deserializer_returning_empty_value_for_empty_string(self):
        # Test that any deserializer returns empty value when passed ''
        t = Task(self.tw)
        deserializers = [
            getattr(t, deserializer_name)
            for deserializer_name in filter(
                lambda x: x.startswith('deserialize_'),
                dir(t),
            )
        ]
        for deserializer in deserializers:
            self.assertTrue(deserializer('') in (None, [], set()))
github robgolding / tasklib / tasklib / tests.py View on Github external
def test_unicode_task(self):
        Task(self.tw, description='†åßk').save()
        self.tw.tasks.get()
github robgolding / tasklib / tasklib / tests.py View on Github external
def test_complete_completed_task(self):
        t = Task(self.tw, description='test task')
        t.save()
        t.done()

        self.assertRaises(Task.CompletedTask, t.done)
github robgolding / tasklib / tasklib / tests.py View on Github external
def test_return_all_from_failed_executed_command(self):
        Task(self.tw, description='test task', tags=['test']).save()
        out, err, rc = self.tw.execute_command(
            ['countinvalid'],
            return_all=True,
            allow_failure=False,
        )
        self.assertNotEqual(rc, 0)
github robgolding / tasklib / tasklib / tests.py View on Github external
def test_add_lazyuuidtaskset_to_dependency_lazyuuidtaskset(self):
        # Adds dependency as LazyUUIDTaskSet to task with one dependencies as LazyUUIDTaskSet
        t = Task(self.tw, description='test task')
        dependency1 = Task(self.tw, description='needs to be done first')
        dependency2 = Task(self.tw, description='needs to be done second')

        dependency1.save()
        dependency2.save()

        t['depends'] = LazyUUIDTaskSet(self.tw, [dependency1['uuid']])
        t.save()

        t['depends'] = LazyUUIDTaskSet(self.tw, [dependency2['uuid']]).union(t['depends'])
        t.save()

        self.assertEqual(t['depends'], LazyUUIDTaskSet(self.tw, [dependency1['uuid'], dependency2['uuid']]))
github robgolding / tasklib / tasklib / tests.py View on Github external
def test_serializers_returning_empty_string_for_none(self):
        # Test that any serializer returns '' when passed None
        t = Task(self.tw)
        serializers = [
            getattr(t, serializer_name)
            for serializer_name in filter(
                lambda x: x.startswith('serialize_'),
                dir(t),
            )
        ]
        for serializer in serializers:
            self.assertEqual(serializer(None), '')
github robgolding / tasklib / tasklib / tests.py View on Github external
def test_filter_for_task_with_space_in_project(self):
        task = Task(self.tw, description='test', project='random project')
        task.save()

        filtered_task = self.tw.tasks.get(project='random project')
        self.assertEqual(filtered_task['project'], 'random project')
github ogarcia / trellowarrior / trellowarrior / main.py View on Github external
def download_trello_card(project_name, list_name, trello_card, task_warrior, doing_list_name, done_list_name):
    """
    Download all contens of trello card creating new Task Warrior task

    :project_name: the name of project where the card is stored
    :list_name: the name of list where the card is stored
    :trello_card: a Trello Card object
    :task_warrior: Task Warrior object
    :doing_list_name: name of doing list to set task active
    :done_list_name: name of done list to set task done
    """
    new_tw_task = Task(task_warrior)
    new_tw_task['project'] = project_name
    new_tw_task['description'] = trello_card.name
    if trello_card.due_date:
        new_tw_task['due'] = trello_card.due_date
    new_tw_task['trelloid'] = trello_card.id
    new_tw_task['trellolistname'] = list_name
    new_tw_task.save()
    if list_name == doing_list_name:
        new_tw_task.start()
    if list_name == done_list_name:
        new_tw_task.done()