test_decorators.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:deb-python-oauth2client 作者: openstack 项目源码 文件源码
def test_specified_scopes(self, dictionary_storage_mock):
        request = self.factory.get('/test')
        request.session = mock.Mock()

        credentials_mock = mock.Mock(
            scopes=set(django.conf.settings.GOOGLE_OAUTH2_SCOPES))
        credentials_mock.has_scopes = mock.Mock(return_value=True)
        credentials_mock.is_valid = True
        dictionary_storage_mock.get.return_value = credentials_mock

        @decorators.oauth_enabled(scopes=['additional-scope'])
        def test_view(request):
            return http.HttpResponse('hello world')  # pragma: NO COVER

        response = test_view(request)
        self.assertEqual(response.status_code, http_client.OK)
        self.assertIsNotNone(request.oauth)
        self.assertFalse(request.oauth.has_credentials())
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号