def test_thread_sort(self): setRoles(self.portal, TEST_USER_ID, ('Manager',)) ws = helpers.create_workspace(self.portal, 'ws1', title=u"Workspace 1") t1 = helpers.publish_post(helpers.create_task( ws, 't1', title=u"Task 1", deadline=datetime.now() + timedelta(1))) p1 = helpers.publish_post(helpers.create_post( ws, 'p1', title=u"Post 1", creation_date=DateTime() - 3)) t2 = helpers.publish_post(helpers.create_task( ws, 't2', title=u"Task 2", deadline=datetime.now() - timedelta(4))) t3 = helpers.publish_post(helpers.create_task( ws, 't3', title=u"Task 3", deadline=datetime.now() - timedelta(2))) p2 = helpers.publish_post(helpers.create_post( ws, 'p2', title=u"Post 2", creation_date=DateTime() - 1)) r1 = helpers.create_reply( p2, 'r1', title=u"Reply 1", creation_date=DateTime() - 1) p3 = helpers.publish_post(helpers.create_post( ws, 'p3', title=u"Post 3", creation_date=DateTime())) r2 = helpers.create_reply( p2, 'r2', title=u"Reply 2", creation_date=DateTime()) r3 = helpers.create_reply( p2, 'r3', title=u"Reply 3", creation_date=DateTime() + 1) conversation = ws.unrestrictedTraverse('@@conversation') post_brains = conversation.brains result = [] for post_brain in post_brains: post = post_brain.getObject() result.append(post.id) thread = post.unrestrictedTraverse('@@thread') for reply_brain in thread.replies: result.append(reply_brain.getId) expected = [t1, p3, p2, r1, r2, r3, t3, p1, t2] expected = [x.id for x in expected] self.assertEqual(result, expected)
def setUp(self): setRoles(self.portal, TEST_USER_ID, ('Manager',)) self.ws = helpers.create_workspace(self.portal, 'ws', title=u"Workspace") in_four_days = datetime.now() + timedelta(4) self.task = helpers.create_task(self.ws, 't', title=u"Turbo Task", deadline=in_four_days) setRoles(self.portal, TEST_USER_ID, ())
def test_task_thread_sort(self): in_two_days = datetime.now() + timedelta(2) t1 = self.task t2 = helpers.create_task( self.ws, 't2', title=u"Taskation", deadline=in_two_days) self.assertGreater(IDateSort(t1), IDateSort(t2)) in_six_days = datetime.now() + timedelta(6) t2.deadline = in_six_days self.assertLess(IDateSort(t1), IDateSort(t2))
def test_task_creation(self): t = helpers.create_task(self.ws, 'task-1', title=u"Task 1") self.assertTrue('task-1' in self.ws) self.assertEqual(t, self.ws['task-1'])