def init_event_handlers(): """ Add in hooks to the Service, Collection and Entry classes to enable Events. """ events.add_event_handlers(Service) events.add_event_handlers(Collection) events.add_event_handlers(Entry)
import unittest class Entry(object): def get(self, headers, body = None): return ({}, "foo") def put_media(self, headers, body = None): return ({'status': '200'}, "bar") class Service(object): def get(self, headers, body = None): return ({'status': '200'}, "baz") add_event_handlers(Entry) add_event_handlers(Service) class Test(unittest.TestCase): def setUp(self): self.any_called = False self.pre_called = False self.pre_headers = {} self.pre_body = "" self.pre_attribs = set() self.post_called = False self.post_headers = {} self.post_body = "" self.post_attribs = set() self.count = 0 clear()