Best Python code snippet using robotframework-pageobjects_python
base.py
Source:base.py
...256 ==================================257 以ä¸æ¯è¯åå½æ°258 ==================================259 """260 def get_some_property(self, is_prior, property, func):261 a = self.prior_car_id_set if is_prior else self.all_car_id_set262 b = [getattr(self.car_dict[i], property) for i in a]263 return func(b)264 def get_all_time_period(self):265 return Data.time_round266 def get_prior_time_period(self):267 return self.get_some_property(is_prior=True, property='finished_time', func=max) - \268 self.get_some_property(is_prior=True, property='plan_time', func=min)269 def get_all_scheduled_cnt(self):270 return sum(car.get_life_span() for car in self.car_dict.values())271 def get_prior_scheduled_cnt(self):272 return sum(car.get_life_span() for car in self.car_dict.values() if car.priority)273 def get_cars_cnt_ratio(self):274 return round(self.CARS_CNT / self.PRIOR_CARS_CNT, 5)275 def get_speed_ratio(self):276 numerator = round(self.get_some_property(False, 'speed', max) / self.get_some_property(False, 'speed', min), 5)277 denominator = round(self.get_some_property(True, 'speed', max) / self.get_some_property(True, 'speed', min), 5)278 return round(numerator / denominator, 5)279 def get_plan_time_ratio(self):280 numerator = round(281 self.get_some_property(False, 'plan_time', max) / self.get_some_property(False, 'plan_time', min), 5)282 denominator = round(283 self.get_some_property(True, 'plan_time', max) / self.get_some_property(True, 'plan_time', min), 5)284 return round(numerator / denominator, 5)285 def get_from_distributed_ratio(self):286 numerator = self.get_some_property(False, 'from_cross_id', lambda x: len(set(x)))287 denominator = self.get_some_property(True, 'from_cross_id', lambda x: len(set(x)))288 return round(numerator / denominator, 5)289 def get_to_distributed_ratio(self):290 numerator = self.get_some_property(False, 'to_cross_id', lambda x: len(set(x)))291 denominator = self.get_some_property(True, 'to_cross_id', lambda x: len(set(x)))292 return round(numerator / denominator, 5)293 def get_factor_from_weights_list(self, weights_list):294 return sum(i * j for i, j in zip(295 [self.get_cars_cnt_ratio(), self.get_speed_ratio(), self.get_plan_time_ratio(),296 self.get_from_distributed_ratio(), self.get_to_distributed_ratio()],297 weights_list298 ))299 def get_factor_a(self):300 return self.get_factor_from_weights_list([.05, .2375, .2375, .2375, .2375])301 def get_factor_b(self):302 return self.get_factor_from_weights_list([.8, .05, .05, .05, .05])303 def get_final_time_round(self):304 return int(round(self.get_factor_a() * self.get_prior_time_period() + self.get_all_time_period(), 0))305 def get_final_schedule_time(self):...
prioritization_rules.py
Source:prioritization_rules.py
...109 -------110 >>> class MyRule(ScaffoldMinFilterRule):111 ...112 ... def get_property(self, child, parent):113 ... prop = get_some_property(parent)114 ... return prop115 ...116 ... @property117 ... def name(self):118 ... return 'my min conditional rule'119 """120 def filter(self, child, parents):121 """Filter a set of parent scaffolds using a minimum property value.122 Parameters123 ----------124 child : scaffoldgraph.core.Scaffold125 The child scaffold from which the parent scaffolds were obtained.126 parents : iterable127 An iterable of all parent scaffolds generated by a fragmenter.128 """129 props = [self.get_property(child, s) for s in parents]130 min_val = min(props)131 return list(compress(parents, [True if p == min_val else False for p in props]))132 @abstractmethod133 def get_property(self, child, parent):134 """Return a property value for a child/parent scaffold.135 Subclasses should implement this method.136 Parameters137 ----------138 child : scaffoldgraph.core.Scaffold139 The child scaffold from which the parent scaffolds were obtained.140 parent : scaffoldgraph.core.Scaffold141 A parent scaffold.142 """143 raise NotImplementedError()144class ScaffoldMaxFilterRule(BaseScaffoldFilterRule):145 """Abstract base class for defining rules for scaffold prioritization146 based on a maximum property value.147 Subclasses should implement the ``get_property`` method, where a property value148 is returned for a particular input scaffold. Scaffolds with a property value149 equal to the maximum property value will be retained. Subclasses should also150 implement the ``name`` property.151 Example152 -------153 >>> class MyRule(ScaffoldMaxFilterRule):154 ...155 ... def get_property(self, child, parent):156 ... prop = get_some_property(parent)157 ... return prop158 ...159 ... @property160 ... def name(self):161 ... return 'my min conditional rule'162 """163 def filter(self, child, parents):164 """Filter a set of parent scaffolds using a maximum property value.165 Parameters166 ----------167 child : scaffoldgraph.core.Scaffold168 The child scaffold from which the parent scaffolds were obtained.169 parents : iterable170 An iterable of all parent scaffolds generated by a fragmenter....
result_component.py
Source:result_component.py
...39 components = {AdvancedOptionTogglerComponent: "dom=jQuery('#advanced-options')"}40class HomePage(Page):41 components = {SearchComponent: "id=search-form"}42 uri = "/site/index.html"43 def get_some_property(self):44 return self.search.some_property45class HomePageWithDOMAdvancedToggler(Page):46 components = {SearchComponentWithDOMAdvancedToggler: "id=search-form"}47 uri = "/site/index.html"48class BodyComponent(Component):49 pass50class ParaComponent(Component):51 pass52class TwoComponentsPage(Page):53 components = {BodyComponent: "css=body", ParaComponent: "css=p"}54 uri = "/site/index.html"55class TwoComponentsSubPage(TwoComponentsPage):...
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!!