Exemplo n.º 1
0
    def test_collection_register_class(self):
        class A(object):
            def handler_one(self, *args, **kw):
                return [args, kw]

            def handler_two(self, *args, **kw):
                return [args, kw]

            def _should_not_be_found(self):
                pass

        collection = JSONPRCCollection()

        collection.register_class(A())

        # if no name specified, register_function takes name from obj
        self.assertEqual(set(collection.keys()),
                         {'A.handler_one', 'A.handler_two'})

        collection.register_class(A(), 'alternate_prefix')

        # if no name specified, register_function takes name from obj
        self.assertEqual(
            set(collection.keys()), {
                'A.handler_one', 'A.handler_two',
                'alternate_prefix.handler_one', 'alternate_prefix.handler_two'
            })
Exemplo n.º 2
0
    def test_collection_register_class(self):

        class A(object):

            def handler_one(self, *args, **kw):
                return [args, kw]

            def handler_two(self, *args, **kw):
                return [args, kw]

            def _should_not_be_found(self):
                pass

        collection = JSONPRCCollection()

        collection.register_class(A())

        # if no name specified, register_function takes name from obj
        self.assertEqual(
            set(collection.keys()),
            {'A.handler_one', 'A.handler_two'}
        )

        collection.register_class(A(), 'alternate_prefix')

        # if no name specified, register_function takes name from obj
        self.assertEqual(
            set(collection.keys()),
            {
                'A.handler_one', 'A.handler_two',
                'alternate_prefix.handler_one', 'alternate_prefix.handler_two'
            }
        )