How to use get_default_koji_tag method in autotest

Best Python code snippet using autotest_python Github


Full Screen

...411 Sets the default tag that will be used412 '''413 global DEFAULT_KOJI_TAG414 DEFAULT_KOJI_TAG = tag415def get_default_koji_tag():416 return DEFAULT_KOJI_TAG417class KojiPkgSpec(object):418 '''419 A package specification syntax parser for Koji420 This holds information on either tag or build, and packages to be fetched421 from koji and possibly installed (features external do this class).422 New objects can be created either by providing information in the textual423 format or by using the actual parameters for tag, build, package and sub-424 packages. The textual format is useful for command line interfaces and425 configuration files, while using parameters is better for using this in426 a programatic fashion.427 The following sets of examples are interchangeable. Specifying all packages428 part of build number 1000:429 >>> from kvm_utils import KojiPkgSpec430 >>> pkg = KojiPkgSpec('1000')431 >>> pkg = KojiPkgSpec(build=1000)432 Specifying only a subset of packages of build number 1000:433 >>> pkg = KojiPkgSpec('1000:kernel,kernel-devel')434 >>> pkg = KojiPkgSpec(build=1000,435 subpackages=['kernel', 'kernel-devel'])436 Specifying the latest build for the 'kernel' package tagged with 'dist-f14':437 >>> pkg = KojiPkgSpec('dist-f14:kernel')438 >>> pkg = KojiPkgSpec(tag='dist-f14', package='kernel')439 Specifying the 'kernel' package using the default tag:440 >>> kvm_utils.set_default_koji_tag('dist-f14')441 >>> pkg = KojiPkgSpec('kernel')442 >>> pkg = KojiPkgSpec(package='kernel')443 Specifying the 'kernel' package using the default tag:444 >>> kvm_utils.set_default_koji_tag('dist-f14')445 >>> pkg = KojiPkgSpec('kernel')446 >>> pkg = KojiPkgSpec(package='kernel')447 If you do not specify a default tag, and give a package name without an448 explicit tag, your package specification is considered invalid:449 >>> print kvm_utils.get_default_koji_tag()450 None451 >>> print kvm_utils.KojiPkgSpec('kernel').is_valid()452 False453 >>> print kvm_utils.KojiPkgSpec(package='kernel').is_valid()454 False455 '''456 SEP = ':'457 def __init__(self, text='', tag=None, build=None,458 package=None, subpackages=[]):459 '''460 Instantiates a new KojiPkgSpec object461 :type text: string462 :param text: a textual representation of a package on Koji that463 will be parsed464 :type tag: string465 :param tag: a koji tag, example: Fedora-14-RELEASE466 (see U{})467 :type build: number468 :param build: a koji build, example: 1001469 (see U{})470 :type package: string471 :param package: a koji package, example: python472 (see U{})473 :type subpackages: list of strings474 :param subpackages: a list of package names, usually a subset of475 the RPM packages generated by a given build476 '''477 # Set to None to indicate 'not set' (and be able to use 'is')478 self.tag = None479 = None480 self.package = None481 self.subpackages = []482 self.default_tag = None483 # Textual representation takes precedence (most common use case)484 if text:485 self.parse(text)486 else:487 self.tag = tag488 = build489 self.package = package490 self.subpackages = subpackages491 # Set the default tag, if set, as a fallback492 if not and not self.tag:493 default_tag = get_default_koji_tag()494 if default_tag is not None:495 self.tag = default_tag496 def parse(self, text):497 '''498 Parses a textual representation of a package specification499 :type text: string500 :param text: textual representation of a package in koji501 '''502 parts = text.count(self.SEP) + 1503 if parts == 1:504 if text.isdigit():505 = text506 else:507 self.package = text508 elif parts == 2:509 part1, part2 = text.split(self.SEP)510 if part1.isdigit():511 = part1512 self.subpackages = part2.split(',')513 else:514 self.tag = part1515 self.package = part2516 elif parts >= 3:517 # Instead of erroring on more arguments, we simply ignore them518 # This makes the parser suitable for future syntax additions, such519 # as specifying the package architecture520 part1, part2, part3 = text.split(self.SEP)[0:3]521 self.tag = part1522 self.package = part2523 self.subpackages = part3.split(',')524 def _is_invalid_neither_tag_or_build(self):525 '''526 Checks if this package is invalid due to not having either a valid527 tag or build set, that is, both are empty.528 :return: True if this is invalid and False if it's valid529 '''530 return (self.tag is None and is None)531 def _is_invalid_package_but_no_tag(self):532 '''533 Checks if this package is invalid due to having a package name set534 but tag or build set, that is, both are empty.535 :return: True if this is invalid and False if it's valid536 '''537 return (self.package and not self.tag)538 def _is_invalid_subpackages_but_no_main_package(self):539 '''540 Checks if this package is invalid due to having a tag set (this is Ok)541 but specifying subpackage names without specifying the main package542 name.543 Specifying subpackages without a main package name is only valid when544 a build is used instead of a tag.545 :return: True if this is invalid and False if it's valid546 '''547 return (self.tag and self.subpackages and not self.package)548 def is_valid(self):549 '''550 Checks if this package specification is valid.551 Being valid means that it has enough and not conflicting information.552 It does not validate that the packages specified actually existe on553 the Koji server.554 :return: True or False555 '''556 if self._is_invalid_neither_tag_or_build():557 return False558 elif self._is_invalid_package_but_no_tag():559 return False560 elif self._is_invalid_subpackages_but_no_main_package():561 return False562 return True563 def describe_invalid(self):564 '''565 Describes why this is not valid, in a human friendly way566 '''567 if self._is_invalid_neither_tag_or_build():568 return ('neither a tag nor a build were set, one of them '569 'must be set')570 elif self._is_invalid_package_but_no_tag():571 return 'package name specified but no tag is set'572 elif self._is_invalid_subpackages_but_no_main_package():573 return 'subpackages specified but no main package is set'574 return 'unkwown reason, seems to be valid'575 def describe(self):576 '''577 Describe this package specification, in a human friendly way578 :return: package specification description579 '''580 if self.is_valid():581 description = ''582 if not self.subpackages:583 description += 'all subpackages from %s ' % self.package584 else:585 description += ('only subpackage(s) %s from package %s ' %586 (', '.join(self.subpackages), self.package))587 if description += 'from build %s' % self.build589 elif self.tag:590 description += 'tagged with %s' % self.tag591 else:592 raise ValueError('neither build or tag is set')593 return description594 else:595 return ('Invalid package specification: %s' %596 self.describe_invalid())597 def to_text(self):598 '''599 Return the textual representation of this package spec600 The output should be consumable by parse() and produce the same601 package specification.602 We find that it's acceptable to put the currently set default tag603 as the package explicit tag in the textual definition for completeness.604 :return: package specification in a textual representation605 '''606 default_tag = get_default_koji_tag()607 if if self.subpackages:609 return "%s:%s" % (, ",".join(self.subpackages))610 else:611 return "%s" % self.build612 elif self.tag:613 if self.subpackages:614 return "%s:%s:%s" % (self.tag, self.package,615 ",".join(self.subpackages))616 else:617 return "%s:%s" % (self.tag, self.package)618 elif default_tag is not None:619 # neither build or tag is set, try default_tag as a fallback620 if self.subpackages:...

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:


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

Run autotest 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?