Best Python code snippet using tempest_python
test.py
Source:test.py  
...588        """Clears creds if set"""589        if hasattr(cls, '_creds_provider'):590            cls._creds_provider.clear_creds()591    @staticmethod592    def _validation_resources_params_from_conf():593        return dict(594            keypair=(CONF.validation.auth_method.lower() == "keypair"),595            floating_ip=(CONF.validation.connect_method.lower() == "floating"),596            security_group=CONF.validation.security_group,597            security_group_rules=CONF.validation.security_group_rules,598            use_neutron=CONF.service_available.neutron,599            ethertype='IPv' + str(CONF.validation.ip_version_for_ssh),600            floating_network_id=CONF.network.public_network_id,601            floating_network_name=CONF.network.floating_network_name)602    @classmethod603    def get_class_validation_resources(cls, os_clients):604        """Provision validation resources according to configuration605        This is a wrapper around `create_validation_resources` from606        `tempest.common.validation_resources` that passes parameters from607        Tempest configuration. Only one instance of class level608        validation resources is managed by the helper, so If resources609        were already provisioned before, existing ones will be returned.610        Resources are returned as a dictionary. They are also scheduled for611        automatic cleanup during class teardown using612        `addClassResourcesCleanup`.613        If `CONF.validation.run_validation` is False no resource will be614        provisioned at all.615        @param os_clients: Clients to be used to provision the resources.616        """617        if not CONF.validation.run_validation:618            return619        if os_clients in cls._validation_resources:620            return cls._validation_resources[os_clients]621        if (CONF.validation.ip_version_for_ssh not in (4, 6) and622                CONF.service_available.neutron):623            msg = "Invalid IP version %s in ip_version_for_ssh. Use 4 or 6"624            raise lib_exc.InvalidConfiguration(625                msg % CONF.validation.ip_version_for_ssh)626        resources = vr.create_validation_resources(627            os_clients,628            **cls._validation_resources_params_from_conf())629        cls.addClassResourceCleanup(630            vr.clear_validation_resources, os_clients,631            use_neutron=CONF.service_available.neutron,632            **resources)633        cls._validation_resources[os_clients] = resources634        return resources635    def get_test_validation_resources(self, os_clients):636        """Returns a dict of validation resources according to configuration637        Initialise a validation resources fixture based on configuration.638        Start the fixture and returns the validation resources.639        If `CONF.validation.run_validation` is False no resource will be640        provisioned at all.641        @param os_clients: Clients to be used to provision the resources.642        """643        params = {}644        # Test will try to use the fixture, so for this to be useful645        # we must return a fixture. If validation is disabled though646        # we don't need to provision anything, which is the default647        # behavior for the fixture.648        if CONF.validation.run_validation:649            params = self._validation_resources_params_from_conf()650        validation = self.useFixture(651            vr.ValidationResourcesFixture(os_clients, **params))652        return validation.resources653    @classmethod654    def set_network_resources(cls, network=False, router=False, subnet=False,655                              dhcp=False):656        """Specify which network resources should be created657        The dynamic credentials provider by default provisions network658        resources for each user/project that is provisioned. This behavior659        can be altered using this method, which allows tests to define which660        specific network resources to be provisioned - none if no parameter661        is specified.662        This method is designed so that only the network resources set on the663        leaf class are honoured....Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
