How to use register_filter_options method in avocado

Best Python code snippet using avocado_python

assets.py

Source:assets.py Github

copy

Full Screen

...257 """Add the subparser for the assets action.258 :param parser: The Avocado command line application parser259 :type parser: :class:`avocado.core.parser.ArgumentParser`260 """261 def register_filter_options(subparser, section):262 help_msg = (263 "Apply action based on a size filter (comparison "264 "operator + value) in bytes. Ex '>20', '<=200'. "265 "Supported operators: " + ", ".join(SUPPORTED_OPERATORS)266 )267 settings.register_option(268 section=section,269 key="size_filter",270 help_msg=help_msg,271 default=None,272 metavar="FILTER",273 key_type=str,274 long_arg="--by-size-filter",275 parser=subparser,276 )277 help_msg = "How old (in days) should Avocado look for assets?"278 settings.register_option(279 section=section,280 key="days",281 help_msg=help_msg,282 default=None,283 key_type=int,284 metavar="DAYS",285 long_arg="--by-days",286 parser=subparser,287 )288 help_msg = (289 "Filter will be based on a overall system limit "290 "threshold in bytes (with assets ordered by last "291 "access) or with a suffix unit. Valid suffixes are: "292 )293 help_msg += ",".join(DataSize.MULTIPLIERS.keys())294 settings.register_option(295 section=section,296 key="overall_limit",297 help_msg=help_msg,298 default=None,299 key_type=str,300 metavar="LIMIT",301 long_arg="--by-overall-limit",302 parser=subparser,303 )304 parser = super().configure(parser)305 subcommands = parser.add_subparsers(dest="assets_subcommand")306 subcommands.required = True307 fetch_subcommand_parser = subcommands.add_parser(308 "fetch",309 help="Fetch assets from test source or config file if it's not"310 " already in the cache",311 )312 help_msg = "Path to avocado instrumented test"313 settings.register_option(314 section="assets.fetch",315 key="references",316 help_msg=help_msg,317 default=[],318 metavar="AVOCADO_INSTRUMENTED",319 key_type=list,320 nargs="+",321 parser=fetch_subcommand_parser,322 positional_arg=True,323 )324 help_msg = "always return success for the fetch command."325 settings.register_option(326 section="assets.fetch",327 key="ignore_errors",328 help_msg=help_msg,329 default=False,330 key_type=bool,331 parser=fetch_subcommand_parser,332 long_arg="--ignore-errors",333 )334 help_msg = "Timeout to be used when download an asset."335 settings.register_option(336 section="assets.fetch",337 key="timeout",338 help_msg=help_msg,339 default=300,340 key_type=int,341 metavar="TIMEOUT",342 parser=fetch_subcommand_parser,343 long_arg="--timeout",344 )345 register_subcommand_parser = subcommands.add_parser(346 "register", help="Register an asset directly to the cacche"347 )348 help_msg = "Unique name to associate with this asset."349 settings.register_option(350 section="assets.register",351 key="name",352 help_msg=help_msg,353 default=None,354 key_type=str,355 parser=register_subcommand_parser,356 positional_arg=True,357 )358 help_msg = "Path to asset that you would like to register manually."359 settings.register_option(360 section="assets.register",361 key="url",362 help_msg=help_msg,363 default=None,364 key_type=str,365 parser=register_subcommand_parser,366 positional_arg=True,367 )368 help_msg = "SHA1 hash of this asset."369 settings.register_option(370 section="assets.register",371 key="sha1_hash",372 help_msg=help_msg,373 default=None,374 key_type=str,375 metavar="SHA1",376 long_arg="--hash",377 parser=register_subcommand_parser,378 )379 purge_subcommand_parser = subcommands.add_parser(380 "purge", help="Removes assets cached locally."381 )382 register_filter_options(purge_subcommand_parser, "assets.purge")383 help_msg = "List all cached assets."384 list_subcommand_parser = subcommands.add_parser("list", help=help_msg)385 register_filter_options(list_subcommand_parser, "assets.list")386 def handle_purge(self, config):387 days = config.get("assets.purge.days")388 size_filter = config.get("assets.purge.size_filter")389 overall_limit = config.get("assets.purge.overall_limit")390 if self._count_filter_args(config) != 1:391 msg = (392 "You should choose --by-size-filter or --by-days. "393 "For help, run: avocado assets purge --help"394 )395 LOG_UI.error(msg)396 return exit_codes.AVOCADO_FAIL397 cache_dirs = config.get("datadir.paths.cache_dirs")398 try:399 if days is not None:...

Full Screen

Full Screen

data_models.py

Source:data_models.py Github

copy

Full Screen

...67class ParameterOptions(BaseModel):68 pass69# --------------- Filter Option structs ----------70available_filter_options = {}71def register_filter_options(cls):72 available_filter_options.update(73 {cls.__name__.replace("FilterOptions", "Task"): cls}74 )75 return cls76@register_filter_options77class FactorialsFilterOptions(BaseModel):78 min_fact_val: float = Field(..., ge=0)79@register_filter_options80class ObservationWindowFilterOptions(BaseModel):81 min_window_duration_hours: float = Field(..., ge=0)82 max_window_delay_hours: float = Field(..., ge=0)83 window_selection: str84@register_filter_options85class ParameterFilterOptions(BaseModel):...

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 avocado 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