def test_statictime_get_info_for(self): frozen_time = datetime(1950, 7, 31, 17, 30) wftool = api.portal.get_tool("portal_workflow") statictime = StaticTime(modified=frozen_time) statictime.start() doc1 = self.create_document("doc1") api.content.transition(doc1, "publish") history = wftool.getInfoFor(doc1, "review_history") fake_datetimes = list(map(itemgetter("time"), history)) self.assertEqual( fake_datetimes, [DateTime("1950/07/31 17:30:00 UTC"), DateTime("1950/07/31 18:30:00 UTC")], ) statictime.stop() doc2 = self.create_document("doc2") api.content.transition(doc2, "publish") history = wftool.getInfoFor(doc2, "review_history") real_datetimes = list(map(itemgetter("time"), history)) for ts in real_datetimes: self.assert_roughly_now(ts) self.assert_of_same_type(fake_datetimes, real_datetimes)
def test_statictime_wc_created(self): frozen_time = datetime(1950, 7, 31, 13, 45) statictime = StaticTime(created=frozen_time) statictime.start() doc1 = self.create_document("doc1") policy = ICheckinCheckoutPolicy(doc1) policy.checkout(self.portal) baseline, working_copy = WorkingCopyInfo(doc1).get_working_copy_info() self.assertEqual(json_compatible(frozen_time), working_copy["created"]) statictime.stop()
def test_statictime_dxcontent_modified(self): frozen_time = datetime(1950, 7, 31, 17, 30) statictime = StaticTime(modified=frozen_time) statictime.start() doc1 = self.create_document("doc1") self.assertEqual(DateTime(frozen_time), doc1.modification_date) fake_datetimes = [doc1.modification_date] statictime.stop() doc2 = self.create_document("doc2") self.assert_roughly_now(doc2.modification_date) real_datetimes = [doc2.modification_date] self.assert_of_same_type(fake_datetimes, real_datetimes)
def test_statictime_comment_modified(self): frozen_time = datetime(1950, 7, 31, 17, 30) statictime = StaticTime(modified=frozen_time) statictime.start() doc1 = self.create_document("doc1") comments = self.create_comments(doc1) self.assertEqual(frozen_time, comments[0].modification_date) fake_datetimes = [comments[0].modification_date] statictime.stop() doc2 = self.create_document("doc2") comments = self.create_comments(doc2) self.assert_roughly_now(comments[0].modification_date) real_datetimes = [comments[0].modification_date] self.assert_of_same_type(fake_datetimes, real_datetimes)
def test_statictime_lockinfo(self): frozen_time = datetime(1950, 7, 31, 17, 30) statictime = StaticTime(modified=frozen_time) doc1 = self.create_document("doc1") alsoProvides(doc1, ITTWLockable) lockable = ILockable(doc1) lockable.lock() statictime.start() lock_infos = lockable.lock_info() self.assertEqual(1, len(lock_infos)) self.assertEqual(-612858600.0, lock_infos[0]["time"]) fake_datetimes = [lock_infos[0]["time"]] statictime.stop() lock_infos = lockable.lock_info() self.assertEqual(1, len(lock_infos)) self.assert_roughly_now(lock_infos[0]["time"]) real_datetimes = [lock_infos[0]["time"]] self.assert_of_same_type(fake_datetimes, real_datetimes)
def test_statictime_full_history(self): frozen_time = datetime(1950, 7, 31, 17, 30) statictime = StaticTime(modified=frozen_time) statictime.start() doc1 = self.create_document("doc1") doc1.setTitle("Current version") api.content.transition(doc1, "publish") viewlet = ContentHistoryViewlet(doc1, doc1.REQUEST, None) viewlet.update() history = viewlet.fullHistory() real_datetimes = list(map(itemgetter("time"), history)) self.assertEqual( real_datetimes, [ DateTime("1950/07/31 17:30:00 UTC"), -612855000.0, DateTime("1950/07/31 19:30:00 UTC"), ], ) statictime.stop() doc2 = self.create_document("doc2") doc2.setTitle("Current version") api.content.transition(doc2, "publish") viewlet = ContentHistoryViewlet(doc2, doc2.REQUEST, None) viewlet.update() history = viewlet.fullHistory() fake_datetimes = list(map(itemgetter("time"), history)) for ts in fake_datetimes: self.assert_roughly_now(ts) self.assert_of_same_type(fake_datetimes, real_datetimes)