Exemplo n.º 1
0
    def test_composition(self):
        arbitrary_serialized_data = {
            'depends':
            ','.join([
                str(uuid.uuid4()),
                str(uuid.uuid4()),
            ]),
            'description':
            '&open;Something important',
            'due': (datetime.datetime.now().replace(tzinfo=pytz.UTC) +
                    datetime.timedelta(hours=1)).strftime('%Y%m%dT%H%M%SZ'),
            'tags': ['one', 'two', 'three'],
            'urgency':
            10,
            'uuid':
            str(uuid.uuid4()),
        }
        task = Task(arbitrary_serialized_data)
        expected_result = arbitrary_serialized_data

        after_composition = Task(
            Task(Task(arbitrary_serialized_data).serialized()).serialized()
        ).serialized()

        self.assertEqual(after_composition, expected_result)
Exemplo n.º 2
0
    def test_deserialize(self):
        arbitrary_depends_uuids = [uuid.uuid4(), uuid.uuid4()]
        arbitrary_description = '[one'
        arbitrary_due_date = (
            datetime.datetime.now().replace(tzinfo=pytz.UTC) +
            datetime.timedelta(hours=1))
        arbitrary_tags = [
            'one',
            'two',
        ]
        arbitrary_urgency = 10
        arbitrary_uuid = uuid.uuid4()

        serialized = {
            'depends': ','.join([str(u) for u in arbitrary_depends_uuids]),
            'description': arbitrary_description.replace('[', '&open;'),
            'due': arbitrary_due_date.strftime('%Y%m%dT%H%M%SZ'),
            'tags': arbitrary_tags,
            'urgency': arbitrary_urgency,
            'uuid': str(arbitrary_uuid)
        }
        task = Task(serialized)

        self.assertEqual(task['depends'], arbitrary_depends_uuids)
        self.assertEqual(task['description'], arbitrary_description)
        # Loss of milliseconds when converting to string
        self.assertAlmostEqual(task['due'],
                               arbitrary_due_date,
                               delta=datetime.timedelta(seconds=1))
        self.assertEqual(task['tags'], arbitrary_tags)
        self.assertEqual(task['urgency'], arbitrary_urgency)
        self.assertEqual(task['uuid'], arbitrary_uuid)
Exemplo n.º 3
0
 def setUp(self):
     self.task = Task({
         'uuid':
         str(uuid.uuid4()),
         'description':
         'Something important',
         'due': (datetime.datetime.now().replace(tzinfo=pytz.UTC) +
                 datetime.timedelta(hours=1)).strftime('%Y%m%dT%H%M%SZ'),
         'tags': ['one', 'two', 'three'],
     })
Exemplo n.º 4
0
def test_example_hook():
    test_task = Task({
        "status": "pending",
        "description": "Fix tw-98765",
        "tags": ["in"],
        "modified": "20181015T054805Z",
        "entry": "20181015T054805Z",
        "uuid": "cee8cefa-0b9d-432c-a7da-cd68f50466bf"
    })

    example_hook.main(test_task)

    assert test_task[
        'description'] == "Fix https://github.com/GothenburgBitFactory/taskwarrior/issues/tw-98765"
Exemplo n.º 5
0
def test_inbox_tag_hook_add():
    test_task = Task({
        "description": "test task 1",
        "status": "pending",
        "tags": ["tag1", "tag2"],
        "modified": "20181015T054805Z",
        "entry": "20181015T054805Z",
        "uuid": "cee8cefa-0b9d-432c-a7da-cd68f50466bf"
    })

    inbox_tag_hook.main(test_task)

    assert test_task['description'] == "test task 1"
    assert test_task['tags'] == ["tag1", "tag2", "in"]
Exemplo n.º 6
0
 def _get_task_object(self, obj):
     if self._marshal:
         return Task(obj, udas=self.config.get_udas())
     return obj
Exemplo n.º 7
0
 def test_append_when_absent_but_with_tags(self):
     self.task = Task({'uuid': str(uuid.uuid4()), 'description': 'Test'})
     self.task['tags'].append('awesome')
     self.assertEqual(self.task['tags'], ['awesome'])