def test_querying(self): soup = get_activity_soup() document = create(Builder('document')) soup.clear() with freeze(datetime(2010, 1, 1)): object_added(document) with freeze(datetime(2010, 1, 2)): object_changed(document) with freeze(datetime(2010, 1, 3)): object_changed(document) results = map(lambda record: (record.attrs['action'], record.attrs['date']), query_soup(Eq('action', 'changed'), sort_index='date', reverse=True)) self.assertEquals([('changed', DateTime('2010/01/03')), ('changed', DateTime('2010/01/02'))], results)
def test_changed_activity(self): document = create(Builder('document').titled('The Document')) with freeze(datetime(2010, 12, 25, 13, 30)): record_id = object_changed(document) record = get_activity_soup().get(record_id) self.assertEquals({'path': '/plone/the-document', 'allowed_roles_and_users': ['Anonymous'], 'uuid': 'testchangedactivity0000000000001', 'portal_type': 'Document', 'title': 'The Document', 'timestamp': 1293280200000L, 'action': 'changed', 'date': DateTime('2010/12/25 13:30:00'), 'actor': TEST_USER_ID}, dict(record.attrs))
def touch(obj): obj.setTitle(obj.Title() + '*') object_changed(obj) clock.forward(hours=1)
def make_object_changed_activity(context, event): if not aq_parent(aq_inner(context)): return object_changed(context)