def test_parallel_downloads(self): element = HttpRequest(parallel_downloads=True) rendered_doc = element.to_xml().replace('<hashTree />', '') parsed_doc = xmltodict.parse(rendered_doc) for tag in parsed_doc['HTTPSamplerProxy']['boolProp']: if tag['@name'] == 'HTTPSampler.concurrentDwn': assert tag['#text'] == 'true'
def test_parallel_downloads_no2(self): element = HttpRequest(parallel_downloads_no=None) rendered_doc = element.to_xml().replace('<hashTree />', '') parsed_doc = xmltodict.parse(rendered_doc) for tag in parsed_doc['HTTPSamplerProxy']['stringProp']: if tag['@name'] == 'HTTPSampler.concurrentPool': assert '#text' not in tag.keys()
def test_response_timeout(self): element = HttpRequest(response_timeout=321) rendered_doc = element.to_xml().replace('<hashTree />', '') parsed_doc = xmltodict.parse(rendered_doc) for tag in parsed_doc['HTTPSamplerProxy']['stringProp']: if tag['@name'] == 'HTTPSampler.response_timeout': assert tag['#text'] == '321'
def test_retrieve_all_emb_resources(self): element = HttpRequest(retrieve_all_emb_resources=True) rendered_doc = element.to_xml().replace('<hashTree />', '') parsed_doc = xmltodict.parse(rendered_doc) for tag in parsed_doc['HTTPSamplerProxy']['boolProp']: if tag['@name'] == 'HTTPSampler.image_parser': assert tag['#text'] == 'true'
def test_browser_comp_headers(self): element = HttpRequest(browser_comp_headers=True) rendered_doc = element.to_xml().replace('<hashTree />', '') parsed_doc = xmltodict.parse(rendered_doc) for tag in parsed_doc['HTTPSamplerProxy']['boolProp']: if tag['@name'] == 'HTTPSampler.BROWSER_COMPATIBLE_MULTIPART': assert tag['#text'] == 'true'
def test_comments(self): element = HttpRequest(comments='My http') rendered_doc = element.to_xml().replace('<hashTree />', '') parsed_doc = xmltodict.parse(rendered_doc) for tag in parsed_doc['HTTPSamplerProxy']['stringProp']: if tag['@name'] == 'TestPlan.comments': assert tag['#text'] == 'My http'
def test_keep_alive(self): element = HttpRequest(keep_alive=False) rendered_doc = element.to_xml().replace('<hashTree />', '') parsed_doc = xmltodict.parse(rendered_doc) for tag in parsed_doc['HTTPSamplerProxy']['boolProp']: if tag['@name'] == 'HTTPSampler.use_keepalive': assert tag['#text'] == 'false'
def test_source_address(self): element = HttpRequest(source_address='test_source') rendered_doc = element.to_xml().replace('<hashTree />', '') parsed_doc = xmltodict.parse(rendered_doc) for tag in parsed_doc['HTTPSamplerProxy']['stringProp']: if tag['@name'] == 'HTTPSampler.ipSource': assert tag['#text'] == 'test_source'
def test_content_encoding(self): element = HttpRequest(content_encoding='utf-8') rendered_doc = element.to_xml().replace('<hashTree />', '') parsed_doc = xmltodict.parse(rendered_doc) for tag in parsed_doc['HTTPSamplerProxy']['stringProp']: if tag['@name'] == 'HTTPSampler.contentEncoding': assert tag['#text'] == 'utf-8'
def test_auto_redirect(self): element = HttpRequest(auto_redirect=True) rendered_doc = element.to_xml().replace('<hashTree />', '') parsed_doc = xmltodict.parse(rendered_doc) for tag in parsed_doc['HTTPSamplerProxy']['boolProp']: if tag['@name'] == 'HTTPSampler.auto_redirects': assert tag['#text'] == 'true'
def test_method(self): element = HttpRequest(method=Method.HEAD) rendered_doc = element.to_xml().replace('<hashTree />', '') parsed_doc = xmltodict.parse(rendered_doc) for tag in parsed_doc['HTTPSamplerProxy']['stringProp']: if tag['@name'] == 'HTTPSampler.method': assert tag['#text'] == 'HEAD'
def test_host(self): element = HttpRequest(host='localhost') rendered_doc = element.to_xml().replace('<hashTree />', '') parsed_doc = xmltodict.parse(rendered_doc) for tag in parsed_doc['HTTPSamplerProxy']['stringProp']: if tag['@name'] == 'HTTPSampler.domain': assert tag['#text'] == 'localhost'
def test_proxy_password(self): element = HttpRequest(proxy_password='******') rendered_doc = element.to_xml().replace('<hashTree />', '') parsed_doc = xmltodict.parse(rendered_doc) for tag in parsed_doc['HTTPSamplerProxy']['stringProp']: if tag['@name'] == 'HTTPSampler.proxyPass': assert tag['#text'] == 'pass'
def test_url_must_match(self): element = HttpRequest(url_must_match='url_match') rendered_doc = element.to_xml().replace('<hashTree />', '') parsed_doc = xmltodict.parse(rendered_doc) for tag in parsed_doc['HTTPSamplerProxy']['stringProp']: if tag['@name'] == 'HTTPSampler.embedded_url_re': assert tag['#text'] == 'url_match'
def test_do_multipart_post(self): element = HttpRequest(do_multipart_post=True) rendered_doc = element.to_xml().replace('<hashTree />', '') parsed_doc = xmltodict.parse(rendered_doc) for tag in parsed_doc['HTTPSamplerProxy']['boolProp']: if tag['@name'] == 'HTTPSampler.DO_MULTIPART_POST': assert tag['#text'] == 'true'
def test_proxy_port2(self): element = HttpRequest(proxy_port=None) rendered_doc = element.to_xml().replace('<hashTree />', '') parsed_doc = xmltodict.parse(rendered_doc) for tag in parsed_doc['HTTPSamplerProxy']['stringProp']: if tag['@name'] == 'HTTPSampler.proxyPort': assert '#text' not in tag.keys()
def test_implementation(self): element = HttpRequest(implementation=Implement.JAVA) rendered_doc = element.to_xml().replace('<hashTree />', '') parsed_doc = xmltodict.parse(rendered_doc) for tag in parsed_doc['HTTPSamplerProxy']['stringProp']: if tag['@name'] == 'HTTPSampler.implementation': assert tag['#text'] == 'Java'
def test_hashtree_contain(self): element = HttpRequest(name='My http', host='localhost', path='/', method=Method.POST, comments='My comments', is_enabled=False) rendered_doc = element.to_xml() assert '<hashTree />' in rendered_doc
def test_is_enabled(self): element = HttpRequest(is_enabled=False) rendered_doc = element.to_xml().replace('<hashTree />', '') parsed_doc = xmltodict.parse(rendered_doc) assert parsed_doc['HTTPSamplerProxy']['@enabled'] == 'false'
def test_name(self): element = HttpRequest(name='My http') rendered_doc = element.to_xml().replace('<hashTree />', '') parsed_doc = xmltodict.parse(rendered_doc) assert parsed_doc['HTTPSamplerProxy']['@testname'] == 'My http'
def test_source_type(self): element = HttpRequest(source_type=Source.IPV4) rendered_doc = element.to_xml().replace('<hashTree />', '') parsed_doc = xmltodict.parse(rendered_doc) assert parsed_doc['HTTPSamplerProxy']['intProp']['#text'] == '2'