def test_max_elements_in_cache(self): element = HTTPCacheManager(clear_each_iteration=False, use_cache_control=True, max_elements_in_cache=100) rendered_doc = tag_wrapper(element.to_xml(), 'result') parsed_doc = xmltodict.parse(rendered_doc) assert parsed_doc['result']['CacheManager']['intProp']['#text'] == '100'
def test_includes_elements_get_size(self): thread_group = CommonThreadGroup(continue_forever=True) elements_list = [ HTTPCacheManager(), HTTPCacheManager(), HTTPCacheManager() ] for element in elements_list: thread_group.append(element) assert len(thread_group) == 3
def test_includes_elements_test_render(self): thread_group = CommonThreadGroup(continue_forever=True) elements_list = [ HTTPCacheManager(), HTTPCacheManager(), HTTPCacheManager() ] for element in elements_list: thread_group.append(element) xml_data = thread_group._render_inner_elements() assert len(re.findall('element_type', xml_data)) == 3
def test_check_forbidden_symbols(self): thread_group = CommonThreadGroup(continue_forever=True) elements_list = [ HTTPCacheManager(), HTTPCacheManager(), HTTPCacheManager() ] for element in elements_list: thread_group.append(element) xml_data = thread_group._render_inner_elements() assert "<" not in xml_data assert ">" not in xml_data
def test_check(self): with pytest.raises(TypeError): HTTPCacheManager(clear_each_iteration="False")
def test_positive(self): cache_manager = HTTPCacheManager(max_elements_in_cache=100) assert cache_manager.max_elements_in_cache == 100
def test_check2(self): with pytest.raises(TypeError): HTTPCacheManager(max_elements_in_cache="120")
def test_positive(self): cache_manager = HTTPCacheManager(use_cache_control=False) assert cache_manager.use_cache_control is False
def test_check2(self): with pytest.raises(TypeError): HTTPCacheManager(use_cache_control=12345)
def test_check(self): with pytest.raises(TypeError): HTTPCacheManager(use_cache_control="False")
def test_positive(self): cache_manager = HTTPCacheManager(clear_each_iteration=True) assert cache_manager.clear_each_iteration is True
def test_check2(self): with pytest.raises(TypeError): HTTPCacheManager(clear_each_iteration=123456)
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'))