Beispiel #1
0
    def test_task_tag_order(self):
        tag = Tag(Tag.TargetType.USER, "Test", Tag.Action.ASSIGN, 5)
        tag2 = Tag(Tag.TargetType.GROUP, "Test2", Tag.Action.NOTIFY, 15)
        task = Task("abcd @Test abc !Test2 his and", [tag, tag2], [])

        self.assertEqual("abcd <span class=\"assign\">@Test</span> abc <span class=\"categorize\">!Test2</span> his and",
            task.decorate())
Beispiel #2
0
    def test_task_completed_tag_decoration(self):
        tag = Tag(Tag.TargetType.USER, "Test", Tag.Action.ASSIGN, 0)
        tag2 = Tag(Tag.TargetType.GROUP, "Test2", Tag.Action.NOTIFY, 10, True)
        task = Task("@Test abc !Test2 his and", [tag, tag2], [])

        self.assertEqual("<span class=\"assign\">@Test</span> abc <span class=\"notify completed\">!Test2</span> his and",
            task.decorate())
Beispiel #3
0
    def test_tag_parsing_type_validation(self):
        # Test valid JSON
        self.assertIsInstance(Task.from_json({
            "description": "",
            "tags": [],
            "files": []
        }), Task)

        # Test task description type validation
        self.assertRaises(InvalidJSONException, Task.from_json, {
            "description": 0,
            "tags": [],
            "files": []
        })

        # Test task tags type validation
        self.assertRaises(InvalidJSONException, Task.from_json, {
            "description": "",
            "tags": "",
            "files": []
        })

        # Test task files type validation
        self.assertRaises(InvalidJSONException, Task.from_json, {
            "description": "",
            "tags": [],
            "files": ""
        })
Beispiel #4
0
 def launch_task(self, task, params, name, description, priority, *args, **kwargs):
     rq_job = current_app.task_queues[priority].enqueue_call(func=task, args=params, *args, **kwargs)
     task = Task(id=rq_job.get_id(), name=name, description=description, user_id=self.id)
     db.session.add(task)
     return task