How to use the pyats.datastructures.logic.Or 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 / robot-pkg / src / genie / libs / robot / GenieRobot.py View on Github external
def genie_run_verification_alias_context(self, name, device, alias,
                                                 context):
        '''Call any verification defined in the verification datafile
           on device using a specific alias with a context (cli, xml, yang, ...)
        '''
        if not self.loaded_yamls:
            self.builtin.fail("Could not load the yaml files - Make sure you "
                              "have an uut device")

        # Set the variables to find the verification
        self.testscript.verification_uids = Or(name+'$')
        self.testscript.verification_groups = None
        self.testscript.verifications = deepcopy(self.verification_datafile)
        self.testscript.triggers = None

        # Modify the parameters to include context
        if name in self.testscript.verifications:
            # Add new parameters named context
            # No need to revert, as a deepcopy was taken, and after discovery
            # nothing is done with the datafiles after
            if 'devices' in self.testscript.verifications[name]:
                # For each device add context
                for dev in self.testscript.verifications[name]['devices']:
                    # To shorten the variable
                    verf = self.testscript.verifications[name]
                    if 'devices_attributes' not in verf or\
                        verf['devices_attributes'][dev] == 'None':
github CiscoTestAutomation / genielibs / pkgs / robot-pkg / src / genie / libs / robot / GenieRobot.py View on Github external
def genie_run_trigger_alias_context(self, name, device, alias, context):
        '''Call any trigger defined in the trigger datafile on device
        using a specific alias with a context (cli, xml, yang, ...)
        '''

        if not self.loaded_yamls:
            self.builtin.fail("Could not load the yaml files - Make sure you "
                              "have an uut device")

        # Set the variables to find the trigger
        device_handle = self._search_device(device)

        self.testscript.trigger_uids = Or(name+'$')
        self.testscript.trigger_groups = None
        self.testscript.triggers = deepcopy(self.trigger_datafile)
        self.testscript.verifications = None

        # Modify the parameters to include context
        self._add_abstraction_datafiles(datafile=self.testscript.triggers,
                                        name=name,
                                        context=context,
                                        device=device_handle)


        self._run_genie_trigger_verification(name=name, alias=alias,
                                                 device=device, context=context)
github CiscoDevNet / pyats-sample-scripts / comprehensive / job / example_job.py View on Github external
uids = And('.*Testcase.*', Not('ExampleTestcase')))

    #**************************************
    #* Run by Groups
    #*
    #*  use 'groups' feature to specify which testcase groups should run.
    #*  'groups' accepts a callable argument. In this example, we'll also be
    #*  using datastructure.logic classes.
    #*

    #
    # eg, only run testcases in group_A and group_C
    #
    run(testscript= os.path.join(script_path, 'variant_example.py'),
        runtime = runtime,
        groups = Or('group_A', 'group_C'))