def test_register_hook_already_registered(self):
        hook = APIExtraDataAccessHook(
            self.extension,
            self.resource,
            [
                (('public',), ExtraDataAccessLevel.ACCESS_STATE_PUBLIC)
            ])

        with self.assertRaises(AlreadyRegisteredError):
            hook.resource.extra_data_access_callbacks.register(
                hook.get_extra_data_state)

        self.assertNotEqual(set(),
                            set(self.resource.extra_data_access_callbacks))
Testing hook registration with already registered callback
dataset/ETHPy150Open reviewboard/reviewboard/reviewboard/extensions/tests.py/APIExtraDataAccessHookTests.test_register_hook_already_registered