当前位置: 首页>>代码示例>>Python>>正文


Python RequestFactory.API方法代码示例

本文整理汇总了Python中test_utils.RequestFactory.API方法的典型用法代码示例。如果您正苦于以下问题:Python RequestFactory.API方法的具体用法?Python RequestFactory.API怎么用?Python RequestFactory.API使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在test_utils.RequestFactory的用法示例。


在下文中一共展示了RequestFactory.API方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_request

# 需要导入模块: from test_utils import RequestFactory [as 别名]
# 或者: from test_utils.RequestFactory import API [as 别名]
 def get_request(self, data=None):
     if data is None:
         data = {}
     request = RequestFactory().get("/", data)
     request.REGION = mkt.regions.RESTOFWORLD
     request.API = True
     return request
开发者ID:BIGGANI,项目名称:zamboni,代码行数:9,代码来源:test_serializers.py

示例2: test_fail

# 需要导入模块: from test_utils import RequestFactory [as 别名]
# 或者: from test_utils.RequestFactory import API [as 别名]
 def test_fail(self):
     url = absolutify(reverse('app-list'))
     url, auth_header = self._oauth_request_info(
         url, client_key=self.access.key,
         client_secret="none")
     auth = authentication.RestOAuthAuthentication()
     req = RequestFactory().get(
         url, HTTP_HOST='testserver',
         HTTP_AUTHORIZATION=auth_header)
     req.API = True
     RestOAuthMiddleware().process_request(req)
     assert not auth.authenticate(Request(req))
     assert not hasattr(req, 'user')
开发者ID:anushbmx,项目名称:zamboni,代码行数:15,代码来源:test_oauth.py

示例3: test_bad_access_token

# 需要导入模块: from test_utils import RequestFactory [as 别名]
# 或者: from test_utils.RequestFactory import API [as 别名]
 def test_bad_access_token(self):
     url = absolutify(reverse('app-list'))
     Token.generate_new(ACCESS_TOKEN, creds=self.access, user=self.user2)
     url, auth_header = self._oauth_request_info(
         url, client_key=self.access.key,
         client_secret=self.access.secret, resource_owner_key=generate(),
         resource_owner_secret=generate())
     auth = authentication.RestOAuthAuthentication()
     req = RequestFactory().get(
         url, HTTP_HOST='testserver',
         HTTP_AUTHORIZATION=auth_header)
     req.API = True
     RestOAuthMiddleware().process_request(req)
     assert not auth.authenticate(Request(req))
开发者ID:Dreadchild,项目名称:zamboni,代码行数:16,代码来源:test_oauth.py

示例4: test_success

# 需要导入模块: from test_utils import RequestFactory [as 别名]
# 或者: from test_utils.RequestFactory import API [as 别名]
 def test_success(self):
     url = absolutify(reverse('app-list'))
     url, auth_header = self._oauth_request_info(
         url, client_key=self.access.key,
         client_secret=self.access.secret)
     auth = authentication.RestOAuthAuthentication()
     req = RequestFactory().get(
         url, HTTP_HOST='testserver',
         HTTP_AUTHORIZATION=auth_header)
     req.API = True
     req.user = AnonymousUser()
     RestOAuthMiddleware().process_request(req)
     ok_(auth.authenticate(Request(req)))
     ok_(req.user.is_authenticated())
     eq_(req.user, self.user)
开发者ID:kylewu,项目名称:zamboni,代码行数:17,代码来源:test_oauth.py

示例5: test_use_access_token

# 需要导入模块: from test_utils import RequestFactory [as 别名]
# 或者: from test_utils.RequestFactory import API [as 别名]
 def test_use_access_token(self):
     url = absolutify(reverse('app-list'))
     t = Token.generate_new(ACCESS_TOKEN, creds=self.access,
                            user=self.user2)
     url, auth_header = self._oauth_request_info(
         url, client_key=self.access.key, client_secret=self.access.secret,
         resource_owner_key=t.key, resource_owner_secret=t.secret)
     auth = authentication.RestOAuthAuthentication()
     req = RequestFactory().get(
         url, HTTP_HOST='testserver',
         HTTP_AUTHORIZATION=auth_header)
     req.API = True
     req.user = AnonymousUser()
     RestOAuthMiddleware().process_request(req)
     ok_(auth.authenticate(Request(req)))
     ok_(req.user.is_authenticated())
     eq_(req.user, self.user2)
开发者ID:kylewu,项目名称:zamboni,代码行数:19,代码来源:test_oauth.py

示例6: get_request

# 需要导入模块: from test_utils import RequestFactory [as 别名]
# 或者: from test_utils.RequestFactory import API [as 别名]
 def get_request(self, query_string):
     request = RequestFactory().get('/', query_string)
     request.REGION = mkt.regions.WORLDWIDE
     request.API = True
     return request
开发者ID:hardikj,项目名称:zamboni,代码行数:7,代码来源:test_serializers.py

示例7: test_no_api_version

# 需要导入模块: from test_utils import RequestFactory [as 别名]
# 或者: from test_utils.RequestFactory import API [as 别名]
 def test_no_api_version(self):
     req = RequestFactory().get('/api/v2/')
     req.API = True
     res = self.api_version_middleware.process_response(req, HttpResponse())
     eq_(self.header(res, 'API-Version'), '2')
     eq_(self.header(res, 'API-Status'), None)
开发者ID:JaredKerim-Mozilla,项目名称:zamboni,代码行数:8,代码来源:test_middleware.py

示例8: test_session_not_used_api

# 需要导入模块: from test_utils import RequestFactory [as 别名]
# 或者: from test_utils.RequestFactory import API [as 别名]
 def test_session_not_used_api(self, process_request):
     req = RequestFactory().get('/')
     req.API = True
     NoVarySessionMiddleware().process_request(req)
     assert not process_request.called
开发者ID:MorrisJobke,项目名称:zamboni,代码行数:7,代码来源:test_middleware.py


注:本文中的test_utils.RequestFactory.API方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。