本文整理汇总了Python中bzt.jmx.JMX._get_http_request方法的典型用法代码示例。如果您正苦于以下问题:Python JMX._get_http_request方法的具体用法?Python JMX._get_http_request怎么用?Python JMX._get_http_request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bzt.jmx.JMX
的用法示例。
在下文中一共展示了JMX._get_http_request方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: compile_http_request
# 需要导入模块: from bzt.jmx import JMX [as 别名]
# 或者: from bzt.jmx.JMX import _get_http_request [as 别名]
def compile_http_request(self, request):
"""
:type request: HierarchicHTTPRequest
:return:
"""
timeout = request.priority_option('timeout')
if timeout is not None:
timeout = self.smart_time(timeout)
content_type = self._get_merged_ci_headers(request, 'content-type')
if content_type == 'application/json' and isinstance(request.body, (dict, list)):
body = json.dumps(request.body)
else:
body = request.body
use_random_host_ip = request.priority_option('random-source-ip', default=False)
host_ips = get_host_ips(filter_loopbacks=True) if use_random_host_ip else []
http = JMX._get_http_request(request.url, request.label, request.method, timeout, body,
request.priority_option('keepalive', default=True),
request.upload_files, request.content_encoding,
request.priority_option('follow-redirects', default=True),
use_random_host_ip, host_ips)
children = etree.Element("hashTree")
if request.headers:
children.append(JMX._get_header_mgr(request.headers))
children.append(etree.Element("hashTree"))
self.__add_think_time(children, request)
self.__add_assertions(children, request)
if timeout is not None:
children.append(JMX._get_dur_assertion(timeout))
children.append(etree.Element("hashTree"))
self.__add_extractors(children, request)
self.__add_jsr_elements(children, request)
return [http, children]
示例2: test_no_port
# 需要导入模块: from bzt.jmx import JMX [as 别名]
# 或者: from bzt.jmx.JMX import _get_http_request [as 别名]
def test_no_port(self):
obj = JMX()
res = obj._get_http_request("http://hostname", "label", "method", 0, {}, True)
self.assertEqual("", res.find(".//stringProp[@name='HTTPSampler.path']").text)
self.assertEqual("hostname", res.find(".//stringProp[@name='HTTPSampler.domain']").text)
self.assertEqual("", res.find(".//stringProp[@name='HTTPSampler.port']").text)
示例3: test_jmx_unicode_checkmark
# 需要导入模块: from bzt.jmx import JMX [as 别名]
# 或者: from bzt.jmx.JMX import _get_http_request [as 别名]
def test_jmx_unicode_checkmark(self):
obj = JMX()
res = obj._get_http_request("url", "label", "method", 0, {"param": u"✓"}, True)
prop = res.find(".//stringProp[@name='Argument.value']")
self.assertNotEqual("BINARY", prop.text)
self.assertEqual(u"✓", prop.text)
示例4: test_variable_hostname
# 需要导入模块: from bzt.jmx import JMX [as 别名]
# 或者: from bzt.jmx.JMX import _get_http_request [as 别名]
def test_variable_hostname(self):
obj = JMX()
res = obj._get_http_request("http://${hostName}:${Port}/${Path}", "label", "method", 0, {}, True)
self.assertEqual("/${Path}", res.find(".//stringProp[@name='HTTPSampler.path']").text)
self.assertEqual("${hostName}", res.find(".//stringProp[@name='HTTPSampler.domain']").text)
self.assertEqual("${Port}", res.find(".//stringProp[@name='HTTPSampler.port']").text)
示例5: test_source_ips_multiple
# 需要导入模块: from bzt.jmx import JMX [as 别名]
# 或者: from bzt.jmx.JMX import _get_http_request [as 别名]
def test_source_ips_multiple(self):
obj = JMX()
res = obj._get_http_request("/", "label", "method", 0, {}, True,
use_random_host_ip=True, host_ips=["192.168.1.1", "192.168.1.2"])
self.assertEqual("${__chooseRandom(192.168.1.1,192.168.1.2,randomAddr)}",
res.find(".//stringProp[@name='HTTPSampler.ipSource']").text)