本文整理汇总了Python中django.http.request.HttpRequest.META方法的典型用法代码示例。如果您正苦于以下问题:Python HttpRequest.META方法的具体用法?Python HttpRequest.META怎么用?Python HttpRequest.META使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.http.request.HttpRequest
的用法示例。
在下文中一共展示了HttpRequest.META方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_with_server_name
# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import META [as 别名]
def test_with_server_name(self):
request = HttpRequest()
request.META = {
'SERVER_NAME': 'example.com',
'SERVER_PORT': 80
}
self.assertEqual(Site.find_for_request(request), self.site)
示例2: test_with_x_forwarded_host
# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import META [as 别名]
def test_with_x_forwarded_host(self):
with self.settings(USE_X_FORWARDED_HOST=True):
request = HttpRequest()
request.META = {'HTTP_X_FORWARDED_HOST': 'example.com', 'SERVER_PORT': 80}
self.assertEqual(Site.find_for_request(request), self.site)
示例3: test_with_host
# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import META [as 别名]
def test_with_host(self):
request = HttpRequest()
request.META = {'HTTP_HOST': 'example.com', 'SERVER_PORT': 80}
self.assertEqual(Site.find_for_request(request), self.site)
示例4: test_with_unknown_host
# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import META [as 别名]
def test_with_unknown_host(self):
request = HttpRequest()
request.META = {'HTTP_HOST': 'unknown.com', 'SERVER_PORT': 80}
self.assertEqual(Site.find_for_request(request), self.default_site)
示例5: test_with_server_name
# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import META [as 别名]
def test_with_server_name(self):
request = HttpRequest()
request.META = {"SERVER_NAME": "example.com", "SERVER_PORT": 80}
self.assertEqual(Site.find_for_request(request), self.site)
示例6: test_with_x_forwarded_host
# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import META [as 别名]
def test_with_x_forwarded_host(self):
with self.settings(USE_X_FORWARDED_HOST=True):
request = HttpRequest()
request.META = {"HTTP_X_FORWARDED_HOST": "example.com"}
self.assertEqual(Site.find_for_request(request), self.site)
示例7: test_with_unknown_host
# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import META [as 别名]
def test_with_unknown_host(self):
request = HttpRequest()
request.META = {"HTTP_HOST": "unknown.com"}
self.assertEqual(Site.find_for_request(request), self.default_site)
示例8: test_with_host
# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import META [as 别名]
def test_with_host(self):
request = HttpRequest()
request.META = {"HTTP_HOST": "example.com"}
self.assertEqual(Site.find_for_request(request), self.site)
示例9: test_token_fail__mismatched
# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import META [as 别名]
def test_token_fail__mismatched(self):
request = HttpRequest()
request.META = {'HTTP_TOKEN': 'Banana'}
response = function_for_testing(request, 'echome')
self.assertEqual(response.status_code, 400)
self.assertEqual(response.content, 'Token is required/mismatched.')
示例10: test_token_success
# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import META [as 别名]
def test_token_success(self):
request = HttpRequest()
request.META = {'HTTP_TOKEN': 'oTbCmV71i2Lg5wQMSsPEFKGJ0Banana'}
result = function_for_testing(request, 'echome')
self.assertEqual(result, 'echome')
示例11: test_send_verification_email
# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import META [as 别名]
def test_send_verification_email(self, send):
req = HttpRequest()
req.META = {"HTTP_HOST": "toto.com"}
self.presta.send_verification_email(req)
self.assertTrue(send.called)
self.assertEqual(Key.objects.filter(claimed_by=self.presta.user, claimed=None).count(), 1)