How to use _get_or_create_feature_settings method in lisa

Best Python code snippet using lisa_python

schema.py

Source:schema.py Github

copy

Full Screen

...839 ):840 # The requirement features are ignored, if cap doesn't have it.841 value.features = search_space.SetSpace[FeatureSettings](is_allow_set=True)842 for original_cap_feature in capability.features:843 capability_feature = self._get_or_create_feature_settings(844 original_cap_feature845 )846 requirement_feature = (847 self._find_feature_by_type(capability_feature.type, self.features)848 or capability_feature849 )850 current_feature = getattr(requirement_feature, method_name)(851 capability_feature852 )853 value.features.add(current_feature)854 elif method_name == search_space.RequirementMethod.intersect and (855 capability.features or self.features856 ):857 # This is a hack to work with lisa_runner. The capability features858 # are joined case req and runbook req. Here just take the results859 # from capability.860 value.features = capability.features861 if (862 capability.excluded_features863 and method_name == search_space.RequirementMethod.generate_min_capability864 ):865 # TODO: the min value for excluded feature is not clear. It may need866 # to be improved with real scenarios.867 value.excluded_features = search_space.SetSpace[FeatureSettings](868 is_allow_set=True869 )870 for original_cap_feature in capability.excluded_features:871 capability_feature = self._get_or_create_feature_settings(872 original_cap_feature873 )874 requirement_feature = (875 self._find_feature_by_type(876 capability_feature.type, self.excluded_features877 )878 or capability_feature879 )880 current_feature = getattr(requirement_feature, method_name)(881 capability_feature882 )883 value.excluded_features.add(current_feature)884 elif method_name == search_space.RequirementMethod.intersect and (885 capability.excluded_features or self.excluded_features886 ):887 # This is a hack to work with lisa_runner. The capability features888 # are joined case req and runbook req. Here just take the results889 # from capability.890 value.excluded_features = capability.excluded_features891 return value892 def _find_feature_by_type(893 self,894 find_type: str,895 features: Optional[search_space.SetSpace[Any]],896 ) -> Optional[FeatureSettings]:897 result: Optional[FeatureSettings] = None898 if not features:899 return result900 is_found = False901 for original_feature in features.items:902 feature = self._get_or_create_feature_settings(original_feature)903 if feature.type == find_type:904 is_found = True905 break906 if is_found:907 result = feature908 return result909 def _create_feature_settings_list(910 self, features: Optional[search_space.SetSpace[Any]]911 ) -> Optional[FeaturesSpace]:912 result: Optional[FeaturesSpace] = None913 if features is None:914 return result915 result = cast(916 FeaturesSpace,917 search_space.SetSpace[FeatureSettings](is_allow_set=features.is_allow_set),918 )919 for raw_feature in features.items:920 feature = self._get_or_create_feature_settings(raw_feature)921 result.add(feature)922 return result923 def _get_or_create_feature_settings(self, feature: Any) -> FeatureSettings:924 if isinstance(feature, str):925 feature_setting = FeatureSettings.create(feature)926 elif isinstance(feature, FeatureSettings):927 feature_setting = feature928 else:929 raise LisaException(930 f"unsupported type {type(feature)} found in features, "931 "only str and FeatureSettings supported."932 )933 return feature_setting934@dataclass_json()935@dataclass936class Capability(NodeSpace):937 type: str = constants.ENVIRONMENTS_NODES_REQUIREMENT...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful