Esempio n. 1
0
    def to_xml(self) -> str:
        element_root, xml_tree = super()._add_basics()

        for element in list(element_root):
            try:
                if element.attrib['name'] == 'ThreadGroup.on_sample_error':
                    element.text = self.on_sample_error.value
                elif element.attrib['name'] == 'ThreadGroup.num_threads':
                    element.text = str(self.num_threads)
                elif element.attrib['name'] == 'ThreadGroup.ramp_time':
                    element.text = str(self.ramp_time)
                elif element.attrib['name'] == 'ThreadGroup.scheduler':
                    element.text = str(self.is_sheduler_enable).lower()
                elif element.attrib['name'] == 'ThreadGroup.duration' and self.is_sheduler_enable:
                    element.text = self.sheduler_duration
                elif element.attrib['name'] == 'ThreadGroup.delay' and self.is_sheduler_enable:
                    element.text = self.sheduler_delay
                elif element.attrib['name'] == 'ThreadGroup.main_controller':
                    for main_controller_element in list(element):
                        if main_controller_element.attrib['name'] == 'LoopController.continue_forever':
                            main_controller_element.text = str(self.continue_forever).lower()
                        elif main_controller_element.attrib['name'] == 'LoopController.loops':
                            main_controller_element.text = str(self.loops)
            except KeyError:
                continue
        if self.delayed_start:
            el = Element("boolProp", attrib={"name": "ThreadGroup.delayedStart"})
            el.text = str(self.delayed_start).lower()
            element_root.append(el)
        content_root = xml_tree.find('hashTree')
        content_root.text = self._render_inner_elements()
        return tree_to_str(xml_tree)
Esempio n. 2
0
 def to_xml(self) -> str:
     element_root, xml_tree = super()._add_basics()
     for element in list(element_root):
         try:
             if element.attrib['name'] == 'Assertion.custom_message':
                 element.text = self.custom_message
             if element.attrib['name'] == 'Assertion.test_field':
                 element.text = self.test_field
             if element.attrib['name'] == 'Assertion.assume_success':
                 element.text = self.ignore_status
             if element.attrib['name'] == 'Assertion.test_type':
                 element.text = self.test_type
             if element.attrib['name'] == 'Asserion.test_strings':
                 for s in self.patterns:
                     el = Element("stringProp",
                                  attrib={"name": str(int(random() * 100))})
                     el.text = s
                     element.append(el)
         except KeyError:
             logging.error('Unable to set xml parameters')
     if not self.scope == Scope.MAIN.value:
         el = Element("stringProp", attrib={"name": "Sample.scope"})
         el.text = self.scope
         element_root.append(el)
         if self.scope == 'variable':
             el = Element("stringProp",
                          attrib={"name": "Assertion.variable"})
             el.text = self.variable
             element_root.append(el)
     return tree_to_str(xml_tree)
Esempio n. 3
0
    def to_xml(self) -> str:
        element_root, xml_tree = super()._add_basics()

        for element in list(element_root):
            try:
                if element.attrib['name'] == 'CounterConfig.name':
                    element.text = self.variable_name
                elif element.attrib['name'] == 'CounterConfig.format':
                    element.text = self.format_
                elif element.attrib['name'] == 'CounterConfig.start':
                    element.text = self.start
                elif element.attrib['name'] == 'CounterConfig.end':
                    element.text = self.end
                elif element.attrib['name'] == 'CounterConfig.incr':
                    element.text = self.incr
                elif element.attrib['name'] == 'CounterConfig.per_user':
                    element.text = str(self.per_user).lower()
            except KeyError:
                logging.error(
                    f'Unable to properly convert {self.__class__} to xml.')
        if self.per_user and self.reset_on_tg_iteration:
            el = Element(
                "boolProp",
                attrib={"name": 'CounterConfig.reset_on_tg_iteration'})
            el.text = str(self.reset_on_tg_iteration).lower()
            element_root.append(el)
        return tree_to_str(xml_tree)
Esempio n. 4
0
    def to_xml(self) -> str:
        xml_tree: Optional[Element] = super().get_template()
        element_root = xml_tree.find(self.root_element_name)
        element_root.attrib['name'] = self.name

        for element in list(element_root):
            try:
                if element.attrib['name'] == 'Argument.name':
                    element.text = self.name
                elif element.attrib['name'] == 'Argument.value':
                    element.text = self.value
                elif element.attrib['name'] == 'Argument.metadata':
                    element.text = self.metadata
                elif element.attrib['name'] == 'HTTPArgument.always_encode':
                    element.text = self.encode
                elif element.attrib['name'] == 'HTTPArgument.use_equals':
                    element.text = self.use_equals
            except KeyError:
                logging.error(
                    f'Unable to properly convert {self.__class__} to xml.')
        if not self.content_type == 'text/plain':
            el = Element('stringProp',
                         attrib={'name': 'HTTPArgument.content_type'})
            el.text = self.content_type
            element_root.append(el)
        return tree_to_str(xml_tree)
Esempio n. 5
0
    def to_xml(self) -> str:
        """
        Set all parameters in xml and convert it to the string.
        :return: xml in string format
        """
        # default name and stuff setup
        element_root, xml_tree = super()._add_basics()
        for element in list(element_root):
            try:
                if element.attrib[
                        'name'] == 'BeanShellSampler.resetInterpreter':
                    element.text = self.resetInterpreter
                elif element.attrib['name'] == 'BeanShellSampler.filename':
                    element.text = self.filename
                elif element.attrib['name'] == 'BeanShellSampler.parameters':
                    element.text = self.parameters
                elif element.attrib['name'] == 'BeanShellSampler.query':
                    element.text = self.query
            except KeyError:
                logging.error('Unable to set xml parameters')

        # render inner renderable elements

        if len(self) == 1:
            content_root = xml_tree.find('hashTree')
            content_root.text = self._render_inner_elements().replace(
                '<hashTree />', '')
        elif len(self) > 1:
            content_root = xml_tree.find('hashTree')
            content_root.text = self._render_inner_elements()
        return tree_to_str(xml_tree)
Esempio n. 6
0
    def to_xml(self) -> str:
        element_root, xml_tree = super()._add_basics()

        for element in list(element_root):
            try:
                if element.attrib['name'] == 'delimiter':
                    element.text = self.delimiter
                elif element.attrib['name'] == 'fileEncoding':
                    element.text = self.file_encoding.value
                elif element.attrib['name'] == 'filename':
                    element.text = self.filename
                elif element.attrib['name'] == 'ignoreFirstLine':
                    element.text = str(self.ignore_first_line).lower()
                elif element.attrib['name'] == 'randomOrder':
                    element.text = str(self.random_order).lower()
                elif element.attrib['name'] == 'rewindOnTheEndOfList':
                    element.text = str(self.recycle).lower()
                elif element.attrib['name'] == 'independentListPerThread':
                    element.text = str(self.independent_per_thread).lower()
                elif element.attrib['name'] == 'variableNames':
                    element.text = self.variable_names
            except KeyError:
                logging.error(
                    f'Unable to properly convert {self.__class__} to xml.')
        return tree_to_str(xml_tree)
Esempio n. 7
0
    def to_xml(self) -> str:
        xml_tree: Optional[Element] = super().get_template()
        element_root = xml_tree.find(self.root_element_name)
        element_root.attrib['name'] = self.name
        element_root.attrib['testname'] = self.name

        for element in list(element_root):
            try:
                if element.attrib['name'] == 'Cookie.value':
                    element.text = self.value
                elif element.attrib['name'] == 'Cookie.domain':
                    element.text = self.domain
                elif element.attrib['name'] == 'Cookie.path':
                    element.text = self.path
                elif element.attrib['name'] == 'Cookie.secure':
                    element.text = self.secure
                elif element.attrib['name'] == 'Cookie.expires':
                    element.text = self.expires
                elif element.attrib['name'] == 'Cookie.path_specified':
                    element.text = self.path_specified
                elif element.attrib['name'] == 'Cookie.domain_specified':
                    element.text = self.domain_specified
            except KeyError:
                logging.error(
                    f'Unable to properly convert {self.__class__} to xml.')
        return tree_to_str(xml_tree)
Esempio n. 8
0
    def to_xml(self) -> str:
        element_root, xml_tree = super()._add_basics()

        for element in list(element_root):
            try:
                if element.attrib['name'] == 'delimiter':
                    element.text = self.delimiter
                elif element.attrib['name'] == 'fileEncoding':
                    element.text = self.file_encoding.value
                elif element.attrib['name'] == 'filename':
                    element.text = self.file_path
                elif element.attrib['name'] == 'ignoreFirstLine':
                    element.text = str(self.ignore_first_line).lower()
                elif element.attrib['name'] == 'quotedData':
                    element.text = str(self.quoted_data).lower()
                elif element.attrib['name'] == 'recycle':
                    element.text = str(self.recycle).lower()
                elif element.attrib['name'] == 'shareMode':
                    element.text = self.share_mode.value
                elif element.attrib['name'] == 'stopThread':
                    element.text = str(self.stop_thread).lower()
                elif element.attrib['name'] == 'variableNames':
                    element.text = self.variable_names
            except KeyError:
                logging.error(
                    f'Unable to properly convert {self.__class__} to xml.')
        return tree_to_str(xml_tree)
Esempio n. 9
0
    def to_xml(self) -> str:
        element_root, xml_tree = super()._add_basics()

        for element in list(element_root):
            try:
                if element.attrib['name'] == 'ThreadGroup.on_sample_error':
                    element.text = self.on_sample_error.value
                elif element.attrib['name'] == 'ultimatethreadgroupdata':
                    for row in self.schedule:
                        el = Element(
                            "collectionProp",
                            attrib={"name": str(int(random() * 10000000000))})
                        for field in ("thread_count", "delay", "startup",
                                      "hold", "shotdown"):
                            sub_el = Element(
                                "stringProp",
                                attrib={"name": str(int(random() * 100000))})
                            sub_el.text = str(row[field])
                            el.append(sub_el)
                        element.append(el)
            except KeyError:
                continue
        content_root = xml_tree.find('hashTree')
        content_root.text = self._render_inner_elements()
        return tree_to_str(xml_tree)
Esempio n. 10
0
    def to_xml(self) -> str:
        element_root, xml_tree = super()._add_basics()

        for element in list(element_root):
            try:
                if element.tag == 'FloatProperty':
                    for el in element:
                        if el.tag == 'value':
                            if self.throughputMode == ThroughputMode.PERCENT:
                                el.text = str(self.throughput)
                            else:
                                el.text = str(float(1))
                elif element.attrib['name'] == 'ThroughputController.style':
                    if self.throughputMode == ThroughputMode.TOTAL:
                        element.text = "0"
                    else:
                        element.text = "1"
                elif element.attrib[
                        'name'] == 'ThroughputController.perThread':
                    element.text = str(self.perThread)
                elif element.attrib[
                        'name'] == 'ThroughputController.maxThroughput':
                    if self.throughputMode == ThroughputMode.TOTAL:
                        element.text = str(self.throughput)
                    else:
                        element.text = "1"
            except KeyError:
                continue

        content_root = xml_tree.find('hashTree')
        content_root.text = self._render_inner_elements()
        return tree_to_str(xml_tree)
Esempio n. 11
0
    def to_xml(self) -> str:
        element_root, xml_tree = super()._add_basics()
        for element in list(element_root):
            try:
                if element.attrib['name'] == 'cacheKey':
                    element.text = self.cache_key
                elif element.attrib['name'] == 'filename':
                    element.text = self.filename
                elif element.attrib['name'] == 'parameters':
                    element.text = self.parameters
                elif element.attrib['name'] == 'script':
                    element.text = self.script
                elif element.attrib['name'] == 'scriptLanguage':
                    element.text = self.script_language.value
            except KeyError:
                logging.error('Unable to set xml parameters')

        # render inner renderable elements

        if len(self) == 1:
            content_root = xml_tree.find('hashTree')
            content_root.text = self._render_inner_elements().replace(
                '<hashTree />', '')
        elif len(self) > 1:
            content_root = xml_tree.find('hashTree')
            content_root.text = self._render_inner_elements()
        return tree_to_str(xml_tree)
Esempio n. 12
0
    def to_xml(self) -> str:
        element_root, xml_tree = super()._add_basics()

        for element in list(element_root):
            try:
                if element.attrib['name'] == 'ThreadGroup.on_sample_error':
                    element.text = self.on_sample_error.value
                elif element.attrib['name'] == 'ThreadGroup.num_threads':
                    element.text = str(self.num_threads)
                elif element.attrib['name'] == 'Threads initial delay':
                    element.text = str(self.initial_delay)
                elif element.attrib['name'] == 'Start users count':
                    element.text = str(self.start_users_count)
                elif element.attrib['name'] == 'Start users count burst':
                    element.text = str(self.start_users_count_burst)
                elif element.attrib['name'] == 'Start users period':
                    element.text = str(self.start_users_period)
                elif element.attrib['name'] == 'Stop users count':
                    element.text = str(self.stop_users_count)
                elif element.attrib['name'] == 'Stop users period':
                    element.text = str(self.stop_users_period)
                elif element.attrib['name'] == 'flighttime':
                    element.text = str(self.hold)
                elif element.attrib['name'] == 'rampUp':
                    element.text = str(self.ramp_up)
            except KeyError:
                continue
        content_root = xml_tree.find('hashTree')
        content_root.text = self._render_inner_elements()
        return tree_to_str(xml_tree)
Esempio n. 13
0
    def to_xml(self) -> str:
        element_root, xml_tree = super()._add_basics()

        for element in list(element_root):
            try:
                if element.attrib['name'] == 'ThreadGroup.on_sample_error':
                    element.text = self.on_sample_error.value
                elif element.attrib['name'] == 'Schedule':
                    for row in self.schedule:
                        el = Element(
                            "collectionProp",
                            attrib={"name": str(int(random() * 10000000000))})
                        for field in ("start", "end", "duration"):
                            sub_el = Element(
                                "stringProp",
                                attrib={"name": str(int(random() * 100000))})
                            sub_el.text = str(row[field])
                            el.append(sub_el)
                        element.append(el)
                elif element.attrib['name'] == 'LogFilename':
                    element.text = self.log_filename
                elif element.attrib['name'] == 'Unit':
                    element.text = self.unit.value
                elif element.attrib['name'] == 'Iterations':
                    element.text = self.iterations
                elif element.attrib['name'] == 'ConcurrencyLimit':
                    element.text = self.concurrency_limit
            except KeyError:
                continue
        content_root = xml_tree.find('hashTree')
        content_root.text = self._render_inner_elements()
        return tree_to_str(xml_tree)
Esempio n. 14
0
    def to_xml(self) -> str:
        element_root, xml_tree = super()._add_basics()

        for element in list(element_root):
            try:
                if element.attrib['name'] == 'TestPlan.comments':
                    element.text = self.comments
                elif element.attrib['name'] == 'ThreadGroup.on_sample_error':
                    element.text = self.on_sample_error.value
                elif element.attrib['name'] == 'ThreadGroup.num_threads':
                    element.text = str(self.num_threads)
                elif element.attrib['name'] == 'ThreadGroup.ramp_time':
                    element.text = str(self.ramp_time)
                elif element.attrib['name'] == 'ThreadGroup.scheduler':
                    element.text = str(self.is_sheduler_enable).lower()
                elif element.attrib['name'] == 'ThreadGroup.duration':
                    element.text = str(self.sheduler_duration)
                elif element.attrib['name'] == 'ThreadGroup.delay':
                    element.text = str(self.sheduler_delay)
                elif element.attrib['name'] == 'ThreadGroup.main_controller':
                    for main_controller_element in list(element):
                        if main_controller_element.attrib['name'] == 'LoopController.continue_forever':
                            main_controller_element.text = str(
                                self.continue_forever)
                        elif main_controller_element.attrib['name'] == 'LoopController.loops':
                            main_controller_element.text = str(self.loops)
            except KeyError:
                continue

        content_root = xml_tree.find('hashTree')
        content_root.text = self._render_inner_elements()
        return tree_to_str(xml_tree)
Esempio n. 15
0
 def to_xml(self) -> str:
     element_root, xml_tree = super()._add_basics()
     for element in list(element_root):
         try:
             if element.attrib['name'] == 'JSONPostProcessor.referenceNames':
                 element.text = self.referenceNames
             elif element.attrib['name'] == 'JSONPostProcessor.jsonPathExprs':
                 element.text = self.jsonPathExprs
             elif element.attrib['name'] == 'JSONPostProcessor.match_numbers':
                 element.text = self.match_numbers
         except KeyError:
             logging.error(f'Unable to render XML')
     if not self.defaultValues is None:
         el = Element("stringProp", attrib={"name":"JSONPostProcessor.defaultValues"})
         el.text = self.defaultValues
         element_root.append(el)
     if self.compute_concat:
         el = Element("boolProp", attrib={"name":"JSONPostProcessor.compute_concat"})
         el.text = self.compute_concat
         element_root.append(el)
     if not self.scope == Scope.MAIN.value:
         el = Element("stringProp", attrib={"name":"Sample.scope"})
         el.text = self.scope
         element_root.append(el)
         if self.scope == 'variable':
             el = Element("stringProp", attrib={"name":"Scope.variable"})
             el.text = self.variable
             element_root.append(el)
     return tree_to_str(xml_tree)
Esempio n. 16
0
    def to_xml(self) -> str:
        element_root, xml_tree = super()._add_basics()

        for element in list(element_root):
            try:
                if element.attrib['name'] == 'ThreadGroup.on_sample_error':
                    element.text = self.on_sample_error.value
                elif element.attrib['name'] == 'TargetLevel':
                    element.text = self.target_rate
                elif element.attrib['name'] == 'RampUp':
                    element.text = self.ramp_up
                elif element.attrib['name'] == 'Steps':
                    element.text = self.steps
                elif element.attrib['name'] == 'Hold':
                    element.text = self.hold
                elif element.attrib['name'] == 'LogFilename':
                    element.text = self.log_filename
                elif element.attrib['name'] == 'Unit':
                    element.text = self.unit.value
                elif element.attrib['name'] == 'Iterations':
                    element.text = self.iterations
                elif element.attrib['name'] == 'ConcurrencyLimit':
                    element.text = self.concurrency_limit
            except KeyError:
                continue
        content_root = xml_tree.find('hashTree')
        content_root.text = self._render_inner_elements()
        return tree_to_str(xml_tree)
Esempio n. 17
0
    def to_xml(self) -> str:
        """
        Set all parameters in xml and convert it to the string.
        :return: xml in string format
        """
        # default name and stuff setup
        element_root, xml_tree = super()._add_basics()

        for element in list(element_root):
            try:
                if element.attrib['name'] == 'displayJMeterProperties':
                    element.text = self.display_props
                elif element.attrib['name'] == 'displayJMeterVariables':
                    element.text = self.display_vars
                elif element.attrib['name'] == 'displaySystemProperties':
                    element.text = self.display_sys_props
            except KeyError:
                logging.error('Unable to set xml parameters')

        # render inner renderable elements
        if len(self) == 1:
            content_root = xml_tree.find('hashTree')
            content_root.text = self._render_inner_elements().replace(
                '<hashTree />', '')
        elif len(self) > 1:
            content_root = xml_tree.find('hashTree')
            content_root.text = self._render_inner_elements()
        return tree_to_str(xml_tree)
Esempio n. 18
0
    def to_xml(self) -> str:
        xml_tree: Optional[Element] = super().get_template()
        element_root = xml_tree.find(self.root_element_name)
        element_root.attrib['name'] = self.username

        for element in list(element_root):
            try:
                if element.attrib['name'] == 'Authorization.url':
                    element.text = self.url
                elif element.attrib['name'] == 'Authorization.username':
                    element.text = self.username
                elif element.attrib['name'] == 'Authorization.password':
                    element.text = self.password
                elif element.attrib['name'] == 'Authorization.domain':
                    element.text = self.domain
                elif element.attrib['name'] == 'Authorization.realm':
                    element.text = self.realm
            except KeyError:
                logging.error(
                    f'Unable to properly convert {self.__class__} to xml.')
        if not self.mechanism is AuthMechanism.BASIC:
            el = Element('stringProp',
                         attrib={'name': 'Authorization.mechanism'})
            el.text = str(self.mechanism.value)
            element_root.append(el)
        return tree_to_str(xml_tree)
Esempio n. 19
0
    def to_xml(self) -> str:
        element_root, xml_tree = super()._add_basics()

        for element in list(element_root):
            try:
                if element.attrib['name'] == 'IncludeController.includepath':
                    element.text = str(self.includePath)
            except KeyError:
                continue
        return tree_to_str(xml_tree)
Esempio n. 20
0
 def to_xml(self) -> str:
     """
     Set all parameters in xml and convert it to the string.
     :return: xml in string format
     """
     # default name and stuff setup
     element_root, xml_tree = super()._add_basics()
     element_root = element_root.find('elementProp')
     element_root = element_root.find('collectionProp')
     for element in list(element_root):
         try:
             if element.attrib['name'] == 'influxdbUrl':
                 for elem in list(element):
                     if elem.attrib[
                             'name'] == 'Argument.value' and self.influx_db_url:
                         elem.text = self.influx_db_url
             elif element.attrib['name'] == 'application':
                 for elem in list(element):
                     if elem.attrib[
                             'name'] == 'Argument.value' and self.application:
                         elem.text = self.application
             elif element.attrib['name'] == 'measurement':
                 for elem in list(element):
                     if elem.attrib[
                             'name'] == 'Argument.value' and self.measurement:
                         elem.text = self.application
             elif element.attrib['name'] == 'summaryOnly':
                 for elem in list(element):
                     if elem.attrib['name'] == 'Argument.value':
                         elem.text = str(self.summary_only).lower()
             elif element.attrib['name'] == 'samplersRegex':
                 for elem in list(element):
                     if elem.attrib[
                             'name'] == 'Argument.value' and self.samplers_regexp:
                         elem.text = self.samplers_regexp
             elif element.attrib['name'] == 'percentiles':
                 for elem in list(element):
                     if elem.attrib[
                             'name'] == 'Argument.value' and self.percentiles:
                         elem.text = self.percentiles
             elif element.attrib['name'] == 'testTitle':
                 for elem in list(element):
                     if elem.attrib[
                             'name'] == 'Argument.value' and self.test_title:
                         elem.text = self.test_title
             elif element.attrib['name'] == 'eventTags':
                 for elem in list(element):
                     if elem.attrib[
                             'name'] == 'Argument.value' and self.event_tags:
                         elem.text = self.event_tags
         except Exception:
             raise Exception(
                 f'Unable to render xml from {type(self).__class__}')
     return tree_to_str(xml_tree, hashtree=True)
Esempio n. 21
0
    def to_xml(self) -> str:
        element_root, xml_tree = super()._add_basics()

        for element in list(element_root):
            try:
                if element.attrib['name'] == 'HeaderManager.headers':
                    element.text = ''
                    for arg in self.headers:
                        element.text += arg.to_xml()
            except KeyError:
                logging.error(
                    f'Unable to properly convert {self.__class__} to xml.')
        return tree_to_str(xml_tree)
Esempio n. 22
0
 def to_xml(self) -> str:
     element_root, xml_tree = super()._add_basics()
     for element in list(element_root):
         try:
             if element.attrib['name'] == 'DurationAssertion.duration':
                 element.text = self.duration
         except KeyError:
             logging.error('Unable to set xml parameters')
     if not self.scope == Scope.MAIN.value:
         el = Element("stringProp", attrib={"name": "Sample.scope"})
         el.text = self.scope
         element_root.append(el)
     return tree_to_str(xml_tree)
Esempio n. 23
0
    def to_xml(self) -> str:
        element_root, xml_tree = super()._add_basics()

        for element in list(element_root):
            try:
                if element.attrib['name'] == 'InterleaveControl.style':
                    element.text = str(self.ignoreSubControllers)
            except KeyError:
                continue

        content_root = xml_tree.find('hashTree')
        content_root.text = self._render_inner_elements()
        return tree_to_str(xml_tree)
Esempio n. 24
0
    def to_xml(self) -> str:
        element_root, xml_tree = super()._add_basics()

        for element in list(element_root):
            try:
                if element.attrib['name'] == 'WhileController.condition':
                    element.text = str(self.condition)
            except KeyError:
                continue

        content_root = xml_tree.find('hashTree')
        content_root.text = self._render_inner_elements()
        return tree_to_str(xml_tree)
Esempio n. 25
0
    def to_xml(self) -> str:
        element_root, xml_tree = super()._add_basics()
        flag = True
        for element in list(element_root):
            try:
                if element.attrib['name'] == 'TestPlan.comments':
                    element.text = self.comments
                elif element.attrib['name'] == 'RegexExtractor.useHeaders':
                    element.text = self.field_to_check
                elif element.attrib['name'] == 'RegexExtractor.refname':
                    element.text = self.var_name
                elif element.attrib['name'] == 'RegexExtractor.regex':
                    element.text = self.regexp
                elif element.attrib['name'] == 'RegexExtractor.template':
                    if self.template is None:
                        element.text = ''
                    else:
                        element.text = str(self.template)
                elif element.attrib['name'] == 'RegexExtractor.default':
                    element.text = self.default_val
                elif element.attrib['name'] == 'RegexExtractor.match_number':
                    if self.match_no is None:
                        element.text = ''
                    else:
                        element.text = str(self.match_no)

                if flag:
                    if self.scope in [
                            Scope.MAIN_AND_SUB.value, Scope.SUB.value
                    ]:
                        scope_elem = SubElement(element_root, 'stringProp')
                        scope_elem.set('name', 'Sample.scope')
                        scope_elem.text = self.scope
                    elif self.scope != '':
                        scope_elem = SubElement(element_root, 'stringProp')
                        scope_elem.set('name', 'Sample.scope')
                        scope_elem.text = 'variable'
                        scope_elem = SubElement(element_root, 'stringProp')
                        scope_elem.set('name', 'Scope.variable')
                        scope_elem.text = self.scope

                    if self.default_val == 'empty':
                        element = SubElement(element_root, 'boolProp')
                        element.set('name',
                                    'RegexExtractor.default_empty_value')
                        element.text = 'true'
                    flag = False
            except KeyError:
                logging.error(f'Unable to render XML')
        return tree_to_str(xml_tree)
Esempio n. 26
0
    def to_xml(self) -> str:
        element_root, xml_tree = super()._add_basics()

        for element in list(element_root):
            try:
                if element.attrib['name'] == 'clearEachIteration':
                    element.text = str(self.clear_each_iteration).lower()
                elif element.attrib['name'] == 'useExpires':
                    element.text = str(self.use_cache_control).lower()
                elif element.attrib['name'] == 'maxSize':
                    element.text = str(self.max_elements_in_cache)
            except KeyError:
                logging.error(
                    f'Unable to properly convert {self.__class__} to xml.')
        return tree_to_str(xml_tree)
Esempio n. 27
0
    def to_xml(self):

        xml_tree = self.get_template()

        for element in list(xml_tree):
            element.set('name', self.file_path)
            for el in list(element):
                if el.attrib['name'] == 'File.path':
                    el.text = self.file_path
                elif el.attrib['name'] == 'File.paramname':
                    el.text = self.param_name
                elif el.attrib['name'] == 'File.mimetype':
                    el.text = self.mime_type

        return tree_to_str(xml_tree)
Esempio n. 28
0
 def to_xml(self) -> str:
     """
     Set all parameters in xml and convert it to the string.
     :return: xml in string format
     """
     element_root, xml_tree = super()._add_basics()
     for element in list(element_root):
         try:
             if element.attrib['name'] == 'TestPlan.comments':
                 element.text = self.comments
             elif element.attrib['name'] == 'ConstantTimer.delay':
                 element.text = str(self.delay)
         except KeyError:
             continue
     return tree_to_str(xml_tree)
Esempio n. 29
0
    def to_xml(self) -> str:
        xml_tree: Optional[Element] = super().get_template()
        element_root = xml_tree.find(self.root_element_name)
        element_root.attrib['name'] = self.name

        for element in list(element_root):
            try:
                if element.attrib['name'] == 'Header.name':
                    element.text = self.name
                elif element.attrib['name'] == 'Header.value':
                    element.text = self.value
            except KeyError:
                logging.error(
                    f'Unable to properly convert {self.__class__} to xml.')
        return tree_to_str(xml_tree)
Esempio n. 30
0
    def to_xml(self) -> str:
        element_root, xml_tree = super()._add_basics()

        for element in list(element_root):
            try:
                if element.attrib['name'] == 'ModuleController.node_path':
                    names = self.node_path.split('/')
                    for name in names:
                        el = Element(
                            "stringProp",
                            attrib={"name": str(int(random() * 10000000000))})
                        el.text = str(name)
                        element.append(el)
            except KeyError:
                continue
        return tree_to_str(xml_tree)