def test_collection_dict_api(self): """ Making sure noone messes up dict-like behavior of our collection We expect "in", ".get()" and other dict-appropriate fns to work. """ def handler(*args, **kw): return [args, kw] collection = JSONPRCCollection(method_name=handler) self.assertEqual( collection['method_name'], handler ) self.assertEqual( collection.get('method_name'), handler ) collection['another_method_name'] = handler self.assertEqual( collection['another_method_name'], handler ) self.assertEqual( collection.get('another_method_name'), handler )
def test_collection_register_function(self): def handler(*args, **kw): return [args, kw] collection = JSONPRCCollection() collection.register_function(handler) # if no name specified, register_function takes name from obj self.assertEqual(collection.get('handler'), handler) collection.register_function(handler, "another.name") # if no name specified, register_function takes name from obj self.assertEqual(collection.get('another.name'), handler)
def test_collection_dict_api(self): """ Making sure noone messes up dict-like behavior of our collection We expect "in", ".get()" and other dict-appropriate fns to work. """ def handler(*args, **kw): return [args, kw] collection = JSONPRCCollection(method_name=handler) self.assertEqual(collection['method_name'], handler) self.assertEqual(collection.get('method_name'), handler) collection['another_method_name'] = handler self.assertEqual(collection['another_method_name'], handler) self.assertEqual(collection.get('another_method_name'), handler)
def test_collection_register_function(self): def handler(*args, **kw): return [args, kw] collection = JSONPRCCollection() collection.register_function(handler) # if no name specified, register_function takes name from obj self.assertEqual( collection.get('handler'), handler ) collection.register_function(handler, "another.name") # if no name specified, register_function takes name from obj self.assertEqual( collection.get('another.name'), handler )