def test_include_me(self):
        from pyramid_authsanity.policy import AuthServicePolicy
        self._makeOne({})
        self.config.commit()
        introspector = self.config.registry.introspector
        auth_policy = introspector.get('authentication policy', None)

        assert isinstance(auth_policy['policy'], AuthServicePolicy)

        with pytest.raises(ValueError):
            find_service_factory(self.config, IAuthSourceService)
    def test_include_me(self):
        from pyramid_authsanity.policy import AuthServicePolicy
        self._makeOne({})
        self.config.commit()
        introspector = self.config.registry.introspector
        auth_policy = introspector.get('authentication policy', None)

        assert isinstance(auth_policy['policy'], AuthServicePolicy)

        with pytest.raises(ValueError):
            find_service_factory(self.config, IAuthSourceService)
    def test_include_me_session(self):
        from pyramid_authsanity.policy import AuthServicePolicy
        settings = {'authsanity.source': 'session'}

        self._makeOne(settings)
        self.config.commit()
        introspector = self.config.registry.introspector
        auth_policy = introspector.get('authentication policy', None)

        assert isinstance(auth_policy['policy'], AuthServicePolicy)
        assert verifyClass(IAuthSourceService, find_service_factory(
            self.config, IAuthSourceService))
    def test_include_me_session(self):
        from pyramid_authsanity.policy import AuthServicePolicy
        settings = {'authsanity.source': 'session'}

        self._makeOne(settings)
        self.config.commit()
        introspector = self.config.registry.introspector
        auth_policy = introspector.get('authentication policy', None)

        assert isinstance(auth_policy['policy'], AuthServicePolicy)
        assert verifyClass(
            IAuthSourceService,
            find_service_factory(self.config, IAuthSourceService))