def test_mass_registering_from_an_object_works(self): call_history = [] class SijaxHandler(object): def callback_one(self, obj_response): call_history.append("one") def callback_two(self, obj_response): call_history.append("two") inst = Sijax() inst.register_object(SijaxHandler()) cls = inst.__class__ inst.set_data({ cls.PARAM_REQUEST: "callback_one", cls.PARAM_ARGS: '[]' }) self.assertTrue(inst.is_sijax_request) inst.process_request() inst.set_data({ cls.PARAM_REQUEST: "callback_two", cls.PARAM_ARGS: '[]' }) self.assertTrue(inst.is_sijax_request) inst.process_request() self.assertEqual(["one", "two"], call_history)
def test_mass_registering_from_a_class_works(self): call_history = [] class SijaxHandler(object): @staticmethod def callback_one(obj_response): call_history.append("one") @staticmethod def callback_two(obj_response): call_history.append("two") @classmethod def callback_three(cls, obj_response): call_history.append("three") inst = Sijax() inst.register_object(SijaxHandler) cls = inst.__class__ inst.set_data({cls.PARAM_REQUEST: "callback_one", cls.PARAM_ARGS: '[]'}) self.assertTrue(inst.is_sijax_request) inst.process_request() inst.set_data({cls.PARAM_REQUEST: "callback_two", cls.PARAM_ARGS: '[]'}) self.assertTrue(inst.is_sijax_request) inst.process_request() inst.set_data({cls.PARAM_REQUEST: "callback_three", cls.PARAM_ARGS: '[]'}) self.assertTrue(inst.is_sijax_request) inst.process_request() self.assertEqual(["one", "two", "three"], call_history)