Best Python code snippet using tempest_python
bugtracker.py
Source:bugtracker.py  
...138        """139    def get_bug_url(self, bug_id):140        """Return the URL for bug_id. Raise an error if bug ID is malformed."""141        self.check_bug_id(bug_id)142        return self._get_bug_url(bug_id)143    def _get_bug_url(self, bug_id):144        """Given a validated bug_id, return the bug's web page's URL."""145class IntegerBugTracker(BugTracker):146    """A bug tracker that only allows integer bug IDs."""147    def check_bug_id(self, bug_id):148        try:149            int(bug_id)150        except ValueError:151            raise errors.MalformedBugIdentifier(bug_id, "Must be an integer")152class UniqueIntegerBugTracker(IntegerBugTracker):153    """A style of bug tracker that exists in one place only, such as Launchpad.154    If you have one of these trackers then register an instance passing in an155    abbreviated name for the bug tracker and a base URL. The bug ids are156    appended directly to the URL.157    """158    def __init__(self, abbreviated_bugtracker_name, base_url):159        self.abbreviation = abbreviated_bugtracker_name160        self.base_url = base_url161    def get(self, abbreviated_bugtracker_name, branch):162        """Returns the tracker if the abbreviation matches. Returns None163        otherwise."""164        if abbreviated_bugtracker_name != self.abbreviation:165            return None166        return self167    def _get_bug_url(self, bug_id):168        """Return the URL for bug_id."""169        return self.base_url + bug_id170tracker_registry.register(171    'launchpad', UniqueIntegerBugTracker('lp', 'https://launchpad.net/bugs/'))172tracker_registry.register(173    'debian', UniqueIntegerBugTracker('deb', 'http://bugs.debian.org/'))174tracker_registry.register('gnome',175    UniqueIntegerBugTracker('gnome',176                            'http://bugzilla.gnome.org/show_bug.cgi?id='))177class URLParametrizedBugTracker(BugTracker):178    """A type of bug tracker that can be found on a variety of different sites,179    and thus needs to have the base URL configured.180    Looks for a config setting in the form '<type_name>_<abbreviation>_url'.181    `type_name` is the name of the type of tracker and `abbreviation`182    is a short name for the particular instance.183    """184    def get(self, abbreviation, branch):185        config = branch.get_config()186        url = config.get_user_option(187            "%s_%s_url" % (self.type_name, abbreviation), expand=False)188        if url is None:189            return None190        self._base_url = url191        return self192    def __init__(self, type_name, bug_area):193        self.type_name = type_name194        self._bug_area = bug_area195    def _get_bug_url(self, bug_id):196        """Return a URL for a bug on this Trac instance."""197        return urlutils.join(self._base_url, self._bug_area) + str(bug_id)198class URLParametrizedIntegerBugTracker(IntegerBugTracker,199                                       URLParametrizedBugTracker):200    """A type of bug tracker that  only allows integer bug IDs.201    This can be found on a variety of different sites, and thus needs to have202    the base URL configured.203    Looks for a config setting in the form '<type_name>_<abbreviation>_url'.204    `type_name` is the name of the type of tracker (e.g. 'bugzilla' or 'trac')205    and `abbreviation` is a short name for the particular instance (e.g.206    'squid' or 'apache').207    """208tracker_registry.register(209    'trac', URLParametrizedIntegerBugTracker('trac', 'ticket/'))210tracker_registry.register(211    'bugzilla',212    URLParametrizedIntegerBugTracker('bugzilla', 'show_bug.cgi?id='))213class GenericBugTracker(URLParametrizedBugTracker):214    """Generic bug tracker specified by an URL template."""215    def __init__(self):216        super(GenericBugTracker, self).__init__('bugtracker', None)217    def get(self, abbreviation, branch):218        self._abbreviation = abbreviation219        return super(GenericBugTracker, self).get(abbreviation, branch)220    def _get_bug_url(self, bug_id):221        """Given a validated bug_id, return the bug's web page's URL."""222        if '{id}' not in self._base_url:223            raise errors.InvalidBugTrackerURL(self._abbreviation,224                                              self._base_url)225        return self._base_url.replace('{id}', str(bug_id))226tracker_registry.register('generic', GenericBugTracker())227FIXED = 'fixed'228ALLOWED_BUG_STATUSES = set([FIXED])229def encode_fixes_bug_urls(bug_urls):230    """Get the revision property value for a commit that fixes bugs.231    :param bug_urls: An iterable of escaped URLs to bugs. These normally232        come from `get_bug_url`.233    :return: A string that will be set as the 'bugs' property of a revision234        as part of a commit....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!!
