How to use the pyats.aetest.subsection function in pyats

To help you get started, we’ve selected a few pyats examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CiscoTestAutomation / genielibs / pkgs / sdk-pkg / src / genie / libs / sdk / libs / abstracted_libs / subsection.py View on Github external
@aetest.subsection
def save_bootvar(self, testbed):
    """Check boot information and save bootvar to startup-config

       Args:
           testbed (`obj`): Testbed object

       Returns:
           None

       Raises:
           pyATS Results
    """

    # Create Summary
    summary = Summary(title='Summary', width=90)
github CiscoDevNet / pyats-sample-scripts / comprehensive / base_example.py View on Github external
    @aetest.subsection
    def self_is_self(self):
        '''Self is always self within the same section

        reading and assessing a value set in previous subsection.
        '''

        # acces a value stored from a_simple_subsection:
        assert self.value_stored_from_simple_subsection is 'awesome'
github CiscoTestAutomation / genielibs / pkgs / sdk-pkg / src / genie / libs / sdk / libs / abstracted_libs / iosxe / subsection.py View on Github external
@aetest.subsection
def check_xe_sanity_device_ready(self, testbed, steps,
                                 max_time=60, interval=10):
    """Check redudancy status, critial processes status and chassis properties

       Args:
           testbed (`obj`): Testbed object
           steps (`obj`): aetest steps object

       Returns:
           None

       Raises:
           pyATS Results
    """
    log.info(banner('Check redudancy status,\n'
                    'critial processes status,\n'
github CiscoDevNet / pyats-sample-scripts / comprehensive / base_example.py View on Github external
    @aetest.subsection
    def print_testbed_information(self, testbed):
        if not testbed or not testbed.devices:
            logger.warning('no testbed was provided to script launch')
        else:
            logger.info('Testbed Name: %s' % testbed.name)
            for device in testbed:
                logger.info('    Device: %s' % device.name)
                for intf in device:
                    logger.info('        Interface: %s' % intf.name)
                    if intf.link:
                        logger.info('            Link: %s' % intf.link.name)
                    else:
                        logger.info('            Link: none')

            # if providing topology information, this is a good place to check
            # that the required information exists.
github CiscoTestAutomation / genielibs / pkgs / sdk-pkg / src / genie / libs / sdk / libs / abstracted_libs / subsection.py View on Github external
@aetest.subsection
def load_config_as_string(self, testbed, steps, configs, connect=False):
    if connect:
        for name in self.parent.mapping_data['devices']:
            dev = testbed.devices[name]
            # connect with console
            try:
                dev.connect(via='a')
            except Exception as e:
                self.failed(
                    'Cannot connect the console on {}'.format(
                        dev.name), from_exception=e)
    try:
        load_config_precessor(self, configs)
    except Exception as e:
        self.passx('Cannot Load configuration',
                   from_exception=e)
github CiscoDevNet / pyats-sample-scripts / comprehensive / base_example.py View on Github external
    @aetest.subsection
    def exception_driven_behavior_error(self):
        '''Exception Driven Behavior (Errored)
        
        In this example, we'll cause a python error.

        '''

        # call something that doesn't exist will certainly wreak havoc
        i_am_a_proc_that_does_not_exist('arguments for the win')
github CiscoDevNet / pyats-sample-scripts / comprehensive / variant_example.py View on Github external
    @aetest.subsection
    def using_parameters(self, **kwargs):
        '''demonstrating parameter overwriting

        base_example's CommonSetup also has the same 'using_parameters' section.
        This will overwrite it with our own, do extra stuff, then call the
        original one (class inheritance technique).
        '''

        # kwargs contains all parameters
        logger.info('Variant Parameter A: %s' % kwargs['variant_parameter_A'])
        logger.info('Variant Parameter B: %s' % kwargs['variant_parameter_B'])

        # objects are great: call the parent subsection that we defined
        # it's just a method - call it with the proper arguments it requires.
        super().using_parameters(testbed = kwargs['testbed'],
                                 parameter_A = kwargs['parameter_A'],
github CiscoDevNet / pyats-sample-scripts / comprehensive / base_example.py View on Github external
    @aetest.subsection
    def using_parameters(self, testbed, parameter_A, parameter_B):
        '''Demonstrating how to use parameters

        When this section is run, these parameters will be passed in by the
        test engine. If a referenced parameter doesn't exist, an exception is
        raised.

        Parameters:
            testbed: this is the testbed parameter. 'testbed' parameter
                     is provided to testscript automatically if Easypy
                     is launched with -testbed_file argument.
            parameter_A/B: custom parameters serving as examples.
        '''

        # log some information
        # note that parameter_A/B were set in the testscript parameters
github CiscoDevNet / pyats-sample-scripts / basic / basic_example_script.py View on Github external
    @aetest.subsection
    def subsection_2(self, section):
        '''
        if the special 'section' keyword argument is defined in the subsection
        method, the current running subsection will be passed in.
        '''
        log.info("inside %s" % (section))
github CiscoTestAutomation / genielibs / pkgs / sdk-pkg / src / genie / libs / sdk / libs / abstracted_libs / subsection.py View on Github external
@aetest.subsection
def learn_system_defaults(self, testbed):
    """Execute commands to learn default system information
       Args:
           testbed (`obj`): Testbed object

       Returns:
           None

       Raises:
           pyATS Results
    """

    # Get default memory location
    self.parent.default_file_system = {}

    # Create Summary