Ejemplo n.º 1
0
 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'
Ejemplo n.º 2
0
 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'
Ejemplo n.º 3
0
 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'
Ejemplo n.º 4
0
 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'
Ejemplo n.º 5
0
 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()
Ejemplo n.º 6
0
 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'
Ejemplo n.º 7
0
 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'
Ejemplo n.º 8
0
 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'
Ejemplo n.º 9
0
 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'
Ejemplo n.º 10
0
 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'
Ejemplo n.º 11
0
 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'
Ejemplo n.º 12
0
 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'
Ejemplo n.º 13
0
 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'
Ejemplo n.º 14
0
 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'
Ejemplo n.º 15
0
 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'
Ejemplo n.º 16
0
 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()
Ejemplo n.º 17
0
 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'
Ejemplo n.º 18
0
 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
Ejemplo n.º 19
0
from jmeter_api.configs.http_cache_manager.elements import HTTPCacheManager
from jmeter_api.timers.constant_throughput_timer.elements import ConstantThroughputTimer
from jmeter_api.timers.constant_timer.elements import ConstantTimer
from jmeter_api.non_test_elements.test_plan.elements import TestPlan
from jmeter_api.controllers.loop_controller.elements import LoopController
from jmeter_api.test_fragment.elements import TestFragment
from jmeter_api.controllers.module_controller.elements import ModuleController
from jmeter_api.samplers.http_request.elements import HttpRequest
from jmeter_api.samplers.jsr223.elements import JSR223
from jmeter_api.thread_groups.common_thread_group.elements import CommonThreadGroup

if __name__ == "__main__":
    test_plan = TestPlan(name='NewTestPlan')
    test_plan.append(HTTPCacheManager(clear_each_iteration=True))
    test_plan.append(CommonThreadGroup(continue_forever=True, name='FirstThreadGroup')
                     .append(HttpRequest(host='www.google.com'))
                     .append(HttpRequest(host='www.google.com'))
                     .append(ConstantTimer(delay=1000))
                     )
    second_thread_group = CommonThreadGroup(
        continue_forever=True, name='SecondThreadGroup')
    for x in range(20):
        second_thread_group.append(HttpRequest(
            host='www.google.com', path=f'/new-{x}', name=f'NewSampler{x}'))
    second_thread_group.append(ConstantThroughputTimer(targ_throughput=10))
    test_plan.append(second_thread_group)

    test_fragment = TestFragment()
    lc = LoopController(loops=3, name='loop3')
    lc2 = LoopController(continue_forever=True)
    lc2.append(HttpRequest(host='www.google.com'))
Ejemplo n.º 20
0
 def test_parallel_downloads(self):
     with pytest.raises(TypeError):
         HttpRequest(parallel_downloads='5')
Ejemplo n.º 21
0
 def test_retrieve_all_emb_resources(self):
     with pytest.raises(TypeError):
         HttpRequest(retrieve_all_emb_resources='5')
Ejemplo n.º 22
0
 def test_response_timeout2(self):
     with pytest.raises(ValueError):
         HttpRequest(response_timeout=-1)
Ejemplo n.º 23
0
 def test_response_timeout(self):
     with pytest.raises(TypeError):
         HttpRequest(response_timeout='5')
Ejemplo n.º 24
0
 def test_connect_timeout2(self):
     with pytest.raises(ValueError):
         HttpRequest(connect_timeout=-1)
Ejemplo n.º 25
0
 def test_name(self):
     with pytest.raises(TypeError):
         HttpRequest(name=123)
Ejemplo n.º 26
0
 def test_connect_timeout(self):
     with pytest.raises(TypeError):
         HttpRequest(connect_timeout='5')
Ejemplo n.º 27
0
 def test_implementation(self):
     with pytest.raises(TypeError):
         HttpRequest(implementation='52')
Ejemplo n.º 28
0
 def test_browser_comp_headers(self):
     with pytest.raises(TypeError):
         HttpRequest(browser_comp_headers=-9)
Ejemplo n.º 29
0
 def test_do_multipart_post(self):
     with pytest.raises(TypeError):
         HttpRequest(do_multipart_post=5)
Ejemplo n.º 30
0
 def test_keep_alive(self):
     with pytest.raises(TypeError):
         HttpRequest(keep_alive=5)