Best Python code snippet using lisa_python
platform.py
Source:platform.py  
...282                self.__node_runbook_type(), type_name=type(self).type_name()283            )284            if not os.path.exists(node_runbook.disk_img):285                raise LisaException(f"file does not exist: {node_runbook.disk_img}")286            node = environment.create_node_from_requirement(node_space)287            self._configure_node(288                node,289                i,290                node_space,291                node_runbook,292                vm_name_prefix,293            )294    def _configure_node(295        self,296        node: Node,297        node_idx: int,298        node_space: schema.NodeSpace,299        node_runbook: BaseLibvirtNodeSchema,300        vm_name_prefix: str,...environment.py
Source:environment.py  
...249            parent_logger=self.log,250        )251        self.nodes.append(node)252        return node253    def create_node_from_requirement(254        self,255        node_requirement: schema.NodeSpace,256    ) -> Node:257        min_requirement = cast(258            schema.Capability,259            node_requirement.generate_min_capability(node_requirement),260        )261        assert isinstance(min_requirement.node_count, int), (262            f"must be int after generate_min_capability, "263            f"actual: {min_requirement.node_count}"264        )265        # node count should be expanded in platform already266        assert min_requirement.node_count == 1, f"actual: {min_requirement.node_count}"267        mock_runbook = schema.RemoteNode(...test_platform.py
Source:test_platform.py  
...77            raise LisaException("mock deploy failed")78        if self._mock_runbook.return_prepared and environment.runbook.nodes_requirement:79            requirements = environment.runbook.nodes_requirement80            for node_space in requirements:81                environment.create_node_from_requirement(node_requirement=node_space)82        for node in environment.nodes.list():83            node._is_initialized = True84        self.test_data.deployed_envs.append(environment.name)85        if self._mock_runbook.deployed_status not in [86            EnvironmentStatus.Deployed,87            EnvironmentStatus.Connected,88        ]:89            raise LisaException(90                f"expected status is {self._mock_runbook.deployed_status}, "91                f"deployment should be failed"92            )93    def _delete_environment(self, environment: Environment, log: Logger) -> None:94        self.test_data.deleted_envs.append(environment.name)95        self.delete_called = True...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!!
