def test_edit_comment(self): self.generate_fixture_user_manager() self.generate_fixture_user_cg_artist() user = persons_service.get_person_raw(self.user["id"]) user_cg_artist = \ persons_service.get_person_raw(self.user_cg_artist["id"]) user_manager = \ persons_service.get_person_raw(self.user_manager["id"]) self.project.team = [self.person, user, user_cg_artist, user_manager] self.project.save() self.generate_fixture_task() path = "/actions/tasks/%s/comment/" % self.task.id data = { "task_status_id": self.wip_status_id, "comment": "comment test @John Doe" } comment = self.post(path, data) notifications = notifications_service.get_last_notifications("mention") self.assertEqual(len(notifications), 1) path = "/data/comments/%s" % comment["id"] data = {"text": "comment test @John Did2 @John Did3"} comment = self.put(path, data) notifications = notifications_service.get_last_notifications("mention") self.assertEqual(len(notifications), 2)
def test_comment_task(self): self.project_id = self.project.id self.generate_fixture_user_manager() self.generate_fixture_user_cg_artist() user_cg_artist = persons_service.get_person_raw( self.user_cg_artist["id"] ) user_manager = persons_service.get_person_raw(self.user_manager["id"]) self.project.team = [self.person, user_cg_artist, user_manager] self.project.save() self.generate_fixture_task() path = "/actions/tasks/%s/comment/" % self.task.id data = { "task_status_id": self.wip_status_id, "comment": "comment test", } comment = self.post(path, data) self.assertEqual(comment["text"], data["comment"]) self.assertEqual( comment["person"]["first_name"], self.user["first_name"] ) self.assertEqual(comment["task_status"]["short_name"], "wip") tasks = self.get("/data/tasks") self.assertEqual(len(tasks), 1) self.assertEqual(tasks[0]["task_status_id"], str(self.wip_status_id)) self.assertIsNotNone(tasks[0]["last_comment_date"]) comments = self.get("/data/comments/") self.assertEqual(len(comments), 1) self.assertEqual(comments[0]["text"], data["comment"]) self.assertEqual(comments[0]["person_id"], self.user["id"]) notifications = notifications_service.get_last_notifications("comment") self.assertEqual(len(notifications), 1) notifications = notifications_service.get_last_notifications("mention") self.assertEqual(len(notifications), 0) data = { "task_status_id": self.wip_status_id, "comment": "comment test @John Did2", } comment = self.post(path, data) notifications = notifications_service.get_last_notifications("comment") self.assertEqual(len(notifications), 2) notifications = notifications_service.get_last_notifications("mention") self.assertEqual(len(notifications), 1) news_list = news_service.get_last_news_for_project(self.project_id) self.assertEqual(len(news_list["data"]), 2)
def test_task_assign(self): self.generate_fixture_task() person_id = str(self.person.id) task_id = str(self.task.id) data = {"person_id": person_id} self.put("/actions/tasks/%s/assign" % task_id, data, 200) task = self.get("data/tasks/%s" % task_id) self.assertEqual(task["assignees"][0], person_id) notifications = notifications_service.get_last_notifications( "assignation") self.assertEqual(len(notifications), 1) self.assertEqual(str(notifications[0]["person_id"]), person_id)
def test_multiple_task_assign(self): self.generate_fixture_task() self.generate_fixture_shot_task() task_id = str(self.task.id) shot_task_id = str(self.shot_task.id) person_id = str(self.person.id) data = {"task_ids": [task_id, shot_task_id]} self.put("/actions/persons/%s/assign" % person_id, data) task = tasks_service.get_task_with_relations(task_id) self.assertEqual(len(task["assignees"]), 1) task = tasks_service.get_task_with_relations(shot_task_id) self.assertEqual(len(task["assignees"]), 1) notifications = notifications_service.get_last_notifications() self.assertEqual(len(notifications), 2)