Merge check_source_in_factory into check_tags_in_requests.py
Followup #2781
This commit is contained in:
parent
e9c42f6950
commit
673084d753
11
CONTENTS.md
11
CONTENTS.md
@ -224,17 +224,6 @@ Checks ABI compatibility in OBS requests.
|
|||||||
* Package: openSUSE-release-tools-abichecker
|
* Package: openSUSE-release-tools-abichecker
|
||||||
* Usage: gocd?
|
* Usage: gocd?
|
||||||
|
|
||||||
#### check_source_in_factory
|
|
||||||
|
|
||||||
Checks if the sources of a submission are either in Factory or a request for Factory with the same
|
|
||||||
sources exist. Not used as a standalone bot anymore, but called internally from
|
|
||||||
check_tags_in_requests.
|
|
||||||
|
|
||||||
* Sources: [check_source_in_factory.py](check_source_in_factory.py)
|
|
||||||
* Documentation: [docs/factory-source.asciidoc](docs/factory-source.asciidoc)
|
|
||||||
* Package: openSUSE-release-tools
|
|
||||||
* Usage: used from other bots (check_tags_in_requests)
|
|
||||||
|
|
||||||
#### openqa-maintenance
|
#### openqa-maintenance
|
||||||
|
|
||||||
OpenQA stuff, not sure about the details.
|
OpenQA stuff, not sure about the details.
|
||||||
|
@ -113,11 +113,6 @@ class MaintenanceChecker(ReviewBot.ReviewBot):
|
|||||||
|
|
||||||
self._check_maintainer_review_needed(req, a)
|
self._check_maintainer_review_needed(req, a)
|
||||||
|
|
||||||
if a.tgt_releaseproject.startswith("openSUSE:Backports:") \
|
|
||||||
and not a.tgt_releaseproject.startswith("openSUSE:Backports:SLE-15-SP3") \
|
|
||||||
and not a.tgt_releaseproject.startswith("openSUSE:Backports:SLE-15-SP4"):
|
|
||||||
self.add_factory_source = True
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def check_action_submit(self, req, a):
|
def check_action_submit(self, req, a):
|
||||||
@ -132,23 +127,10 @@ class MaintenanceChecker(ReviewBot.ReviewBot):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def check_one_request(self, req):
|
def check_one_request(self, req):
|
||||||
self.add_factory_source = False
|
|
||||||
self.needs_maintainer_review = set()
|
self.needs_maintainer_review = set()
|
||||||
|
|
||||||
ret = ReviewBot.ReviewBot.check_one_request(self, req)
|
ret = ReviewBot.ReviewBot.check_one_request(self, req)
|
||||||
|
|
||||||
# check if factory-source is already a reviewer
|
|
||||||
if self.add_factory_source:
|
|
||||||
for r in req.reviews:
|
|
||||||
if r.by_user == 'factory-source':
|
|
||||||
self.add_factory_source = False
|
|
||||||
self.logger.debug("factory-source already is a reviewer")
|
|
||||||
break
|
|
||||||
|
|
||||||
if self.add_factory_source:
|
|
||||||
self.logger.debug("%s needs review by factory-source" % req.reqid)
|
|
||||||
self.add_review(req, by_user='factory-source')
|
|
||||||
|
|
||||||
if self.needs_maintainer_review:
|
if self.needs_maintainer_review:
|
||||||
for p in self.needs_maintainer_review:
|
for p in self.needs_maintainer_review:
|
||||||
self.add_devel_project_review(req, p)
|
self.add_devel_project_review(req, p)
|
||||||
|
@ -1,170 +0,0 @@
|
|||||||
#!/usr/bin/python3
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import osc.conf
|
|
||||||
import osc.core
|
|
||||||
from urllib.error import HTTPError, URLError
|
|
||||||
import ReviewBot
|
|
||||||
|
|
||||||
|
|
||||||
class FactorySourceChecker(ReviewBot.ReviewBot):
|
|
||||||
""" This review bot is obsolete since the introduction of better
|
|
||||||
alternatives like origin-manager. But it's kept because other bots like
|
|
||||||
TagChecker (check_tags_in_request) still call this bot as part of their
|
|
||||||
implementation.
|
|
||||||
|
|
||||||
This review bot was used in the past to check if the sources of a submission
|
|
||||||
are either in Factory or a request for Factory with the same sources exist.
|
|
||||||
If the latter a request is only accepted if the Factory request is reviewed
|
|
||||||
positive."""
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
ReviewBot.ReviewBot.__init__(self, *args, **kwargs)
|
|
||||||
self.factory = ["openSUSE:Factory"]
|
|
||||||
self.review_messages = {'accepted': 'ok', 'declined': 'the package needs to be accepted in Factory first'}
|
|
||||||
self.history_limit = 5
|
|
||||||
|
|
||||||
def check_source_submission(self, src_project, src_package, src_rev, target_project, target_package):
|
|
||||||
super(FactorySourceChecker, self).check_source_submission(
|
|
||||||
src_project, src_package, src_rev, target_project, target_package)
|
|
||||||
src_srcinfo = self.get_sourceinfo(src_project, src_package, src_rev)
|
|
||||||
if src_srcinfo is None:
|
|
||||||
# source package does not exist?
|
|
||||||
# handle here to avoid crashing on the next line
|
|
||||||
self.logger.info("Could not get source info for %s/%s@%s" % (src_project, src_package, src_rev))
|
|
||||||
return False
|
|
||||||
projects = self._package_get_upstream_projects(target_package)
|
|
||||||
if projects is None:
|
|
||||||
self.logger.error("no upstream project found for {}, can't check".format(target_package))
|
|
||||||
return False
|
|
||||||
|
|
||||||
self.review_messages['declined'] = 'the package needs to be accepted in {} first'.format(' or '.join(projects))
|
|
||||||
for project in projects:
|
|
||||||
self.logger.info("Checking in project %s" % project)
|
|
||||||
good = self._check_matching_srcmd5(project, target_package, src_srcinfo.verifymd5, self.history_limit)
|
|
||||||
if good:
|
|
||||||
self.logger.info("{} is in {}".format(target_package, project))
|
|
||||||
return good
|
|
||||||
|
|
||||||
good = self._check_requests(project, target_package, src_srcinfo.verifymd5)
|
|
||||||
if good:
|
|
||||||
self.logger.info("{} already reviewed for {}".format(target_package, project))
|
|
||||||
|
|
||||||
if not good:
|
|
||||||
self.logger.info('{} failed source submission check'.format(target_package))
|
|
||||||
|
|
||||||
return good
|
|
||||||
|
|
||||||
def _package_get_upstream_projects(self, package):
|
|
||||||
""" return list of projects where the specified package is supposed to come
|
|
||||||
from. Either by lookup table or self.factory """
|
|
||||||
projects = []
|
|
||||||
for prj in self.factory:
|
|
||||||
r = self.lookup.get(prj, package)
|
|
||||||
if r:
|
|
||||||
projects.append(r)
|
|
||||||
|
|
||||||
if not projects:
|
|
||||||
projects = self.factory
|
|
||||||
|
|
||||||
return projects
|
|
||||||
|
|
||||||
def _check_requests(self, project, package, rev):
|
|
||||||
self.logger.debug("checking requests")
|
|
||||||
prjprefix = ''
|
|
||||||
apiurl = self.apiurl
|
|
||||||
sr = 'sr'
|
|
||||||
try:
|
|
||||||
if self.config.project_namespace_api_map:
|
|
||||||
for prefix, url, srprefix in self.config.project_namespace_api_map:
|
|
||||||
if project.startswith(prefix):
|
|
||||||
apiurl = url
|
|
||||||
prjprefix = prefix
|
|
||||||
project = project[len(prefix):]
|
|
||||||
sr = srprefix
|
|
||||||
break
|
|
||||||
requests = osc.core.get_request_list(apiurl, project, package, None, ['new', 'review'], 'submit')
|
|
||||||
except (HTTPError, URLError):
|
|
||||||
self.logger.error("caught exception while checking %s/%s", project, package)
|
|
||||||
return None
|
|
||||||
|
|
||||||
def srref(reqid):
|
|
||||||
return '#'.join((sr, reqid))
|
|
||||||
|
|
||||||
for req in requests:
|
|
||||||
for a in req.actions:
|
|
||||||
si = self.get_sourceinfo(prjprefix + a.src_project, a.src_package, a.src_rev)
|
|
||||||
self.logger.debug("rq %s: %s/%s@%s" % (req.reqid, prjprefix +
|
|
||||||
a.src_project, a.src_package, si.verifymd5))
|
|
||||||
if si.verifymd5 == rev:
|
|
||||||
if req.state.name == 'new':
|
|
||||||
self.logger.info("%s ok", srref(req.reqid))
|
|
||||||
return True
|
|
||||||
elif req.state.name == 'review':
|
|
||||||
self.logger.debug("%s still in review", srref(req.reqid))
|
|
||||||
if not req.reviews:
|
|
||||||
self.logger.error("%s in state review but no reviews?", srref(req.reqid))
|
|
||||||
return False
|
|
||||||
for r in req.reviews:
|
|
||||||
if r.state == 'new':
|
|
||||||
if r.by_project and r.by_project.startswith('openSUSE:Factory:Staging:'):
|
|
||||||
self.logger.info("%s review by %s ok", srref(req.reqid), r.by_project)
|
|
||||||
continue
|
|
||||||
|
|
||||||
if r.by_user == 'repo-checker':
|
|
||||||
self.logger.info('%s review by %s ok', srref(req.reqid), r.by_user)
|
|
||||||
continue
|
|
||||||
|
|
||||||
if r.state != 'accepted':
|
|
||||||
if r.by_user:
|
|
||||||
self.logger.info("%s waiting for review by %s", srref(req.reqid), r.by_user)
|
|
||||||
elif r.by_group:
|
|
||||||
self.logger.info("%s waiting for review by %s", srref(req.reqid), r.by_group)
|
|
||||||
elif r.by_project:
|
|
||||||
if r.by_package:
|
|
||||||
self.logger.info("%s waiting for review by %s/%s",
|
|
||||||
srref(req.reqid), r.by_project, r.by_package)
|
|
||||||
else:
|
|
||||||
self.logger.info("%s waiting for review by %s", srref(req.reqid), r.by_project)
|
|
||||||
return None
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
self.logger.error("%s in state %s not expected", srref(req.reqid), req.state.name)
|
|
||||||
return None
|
|
||||||
else:
|
|
||||||
self.logger.info("%s to %s has different sources", srref(req.reqid), project)
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
class CommandLineInterface(ReviewBot.CommandLineInterface):
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
ReviewBot.CommandLineInterface.__init__(self, args, kwargs)
|
|
||||||
self.clazz = FactorySourceChecker
|
|
||||||
|
|
||||||
def get_optparser(self):
|
|
||||||
parser = ReviewBot.CommandLineInterface.get_optparser(self)
|
|
||||||
parser.add_option("--factory", metavar="project", action="append",
|
|
||||||
help=("Project to check source against. Use multiple times to check more than one project. "
|
|
||||||
"[default: openSUSE:Factory]"))
|
|
||||||
parser.add_option("--lookup", metavar="project", help="use lookup file")
|
|
||||||
parser.add_option("--limit", metavar="limit", help="how many revisions back to check. [default: 5]")
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def setup_checker(self):
|
|
||||||
bot = ReviewBot.CommandLineInterface.setup_checker(self)
|
|
||||||
|
|
||||||
if self.options.factory:
|
|
||||||
bot.factory = self.options.factory
|
|
||||||
if self.options.lookup:
|
|
||||||
bot.parse_lookup(self.options.lookup)
|
|
||||||
if self.options.limit:
|
|
||||||
bot.history_limit = self.options.limit
|
|
||||||
|
|
||||||
return bot
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
app = CommandLineInterface()
|
|
||||||
sys.exit(app.main())
|
|
@ -9,7 +9,137 @@ from urllib.error import HTTPError, URLError
|
|||||||
|
|
||||||
import ReviewBot
|
import ReviewBot
|
||||||
|
|
||||||
import check_source_in_factory
|
|
||||||
|
class FactorySourceChecker(ReviewBot.ReviewBot):
|
||||||
|
""" This review bot is obsolete since the introduction of better
|
||||||
|
alternatives like origin-manager. But it's kept because other bots like
|
||||||
|
TagChecker (check_tags_in_request) still call this bot as part of their
|
||||||
|
implementation.
|
||||||
|
|
||||||
|
This review bot was used in the past to check if the sources of a submission
|
||||||
|
are either in Factory or a request for Factory with the same sources exist.
|
||||||
|
If the latter a request is only accepted if the Factory request is reviewed
|
||||||
|
positive."""
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
ReviewBot.ReviewBot.__init__(self, *args, **kwargs)
|
||||||
|
self.factory = ["openSUSE:Factory"]
|
||||||
|
self.review_messages = {'accepted': 'ok', 'declined': 'the package needs to be accepted in Factory first'}
|
||||||
|
self.history_limit = 5
|
||||||
|
|
||||||
|
def check_source_submission(self, src_project, src_package, src_rev, target_project, target_package):
|
||||||
|
super(FactorySourceChecker, self).check_source_submission(
|
||||||
|
src_project, src_package, src_rev, target_project, target_package)
|
||||||
|
src_srcinfo = self.get_sourceinfo(src_project, src_package, src_rev)
|
||||||
|
if src_srcinfo is None:
|
||||||
|
# source package does not exist?
|
||||||
|
# handle here to avoid crashing on the next line
|
||||||
|
self.logger.info("Could not get source info for %s/%s@%s" % (src_project, src_package, src_rev))
|
||||||
|
return False
|
||||||
|
projects = self._package_get_upstream_projects(target_package)
|
||||||
|
if projects is None:
|
||||||
|
self.logger.error("no upstream project found for {}, can't check".format(target_package))
|
||||||
|
return False
|
||||||
|
|
||||||
|
self.review_messages['declined'] = 'the package needs to be accepted in {} first'.format(' or '.join(projects))
|
||||||
|
for project in projects:
|
||||||
|
self.logger.info("Checking in project %s" % project)
|
||||||
|
good = self._check_matching_srcmd5(project, target_package, src_srcinfo.verifymd5, self.history_limit)
|
||||||
|
if good:
|
||||||
|
self.logger.info("{} is in {}".format(target_package, project))
|
||||||
|
return good
|
||||||
|
|
||||||
|
good = self._check_requests(project, target_package, src_srcinfo.verifymd5)
|
||||||
|
if good:
|
||||||
|
self.logger.info("{} already reviewed for {}".format(target_package, project))
|
||||||
|
|
||||||
|
if not good:
|
||||||
|
self.logger.info('{} failed source submission check'.format(target_package))
|
||||||
|
|
||||||
|
return good
|
||||||
|
|
||||||
|
def _check_requests(self, project, package, rev):
|
||||||
|
self.logger.debug("checking requests")
|
||||||
|
prjprefix = ''
|
||||||
|
apiurl = self.apiurl
|
||||||
|
sr = 'sr'
|
||||||
|
try:
|
||||||
|
if self.config.project_namespace_api_map:
|
||||||
|
for prefix, url, srprefix in self.config.project_namespace_api_map:
|
||||||
|
if project.startswith(prefix):
|
||||||
|
apiurl = url
|
||||||
|
prjprefix = prefix
|
||||||
|
project = project[len(prefix):]
|
||||||
|
sr = srprefix
|
||||||
|
break
|
||||||
|
requests = osc.core.get_request_list(apiurl, project, package, None, ['new', 'review'], 'submit')
|
||||||
|
except (HTTPError, URLError):
|
||||||
|
self.logger.error("caught exception while checking %s/%s", project, package)
|
||||||
|
return None
|
||||||
|
|
||||||
|
def srref(reqid):
|
||||||
|
return '#'.join((sr, reqid))
|
||||||
|
|
||||||
|
for req in requests:
|
||||||
|
for a in req.actions:
|
||||||
|
si = self.get_sourceinfo(prjprefix + a.src_project, a.src_package, a.src_rev)
|
||||||
|
self.logger.debug("rq %s: %s/%s@%s" % (req.reqid, prjprefix +
|
||||||
|
a.src_project, a.src_package, si.verifymd5))
|
||||||
|
if si.verifymd5 != rev:
|
||||||
|
self.logger.info("%s to %s has different sources", srref(req.reqid), project)
|
||||||
|
continue
|
||||||
|
|
||||||
|
if req.state.name == 'new':
|
||||||
|
self.logger.info("%s ok", srref(req.reqid))
|
||||||
|
return True
|
||||||
|
if req.state.name != 'review':
|
||||||
|
self.logger.error("%s in state %s not expected", srref(req.reqid), req.state.name)
|
||||||
|
return None
|
||||||
|
|
||||||
|
self.logger.debug("%s still in review", srref(req.reqid))
|
||||||
|
if not req.reviews:
|
||||||
|
self.logger.error("%s in state review but no reviews?", srref(req.reqid))
|
||||||
|
return False
|
||||||
|
for r in req.reviews:
|
||||||
|
if r.state == 'new':
|
||||||
|
if r.by_project and r.by_project.startswith('openSUSE:Factory:Staging:'):
|
||||||
|
self.logger.info("%s review by %s ok", srref(req.reqid), r.by_project)
|
||||||
|
continue
|
||||||
|
|
||||||
|
if r.by_user == 'repo-checker':
|
||||||
|
self.logger.info('%s review by %s ok', srref(req.reqid), r.by_user)
|
||||||
|
continue
|
||||||
|
|
||||||
|
if r.state == 'accepted':
|
||||||
|
continue
|
||||||
|
if r.by_user:
|
||||||
|
self.logger.info("%s waiting for review by %s", srref(req.reqid), r.by_user)
|
||||||
|
elif r.by_group:
|
||||||
|
self.logger.info("%s waiting for review by %s", srref(req.reqid), r.by_group)
|
||||||
|
elif r.by_project:
|
||||||
|
if r.by_package:
|
||||||
|
self.logger.info("%s waiting for review by %s/%s",
|
||||||
|
srref(req.reqid), r.by_project, r.by_package)
|
||||||
|
else:
|
||||||
|
self.logger.info("%s waiting for review by %s", srref(req.reqid), r.by_project)
|
||||||
|
return None
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
def _package_get_upstream_projects(self, package):
|
||||||
|
""" return list of projects where the specified package is supposed to come
|
||||||
|
from. Either by lookup table or self.factory """
|
||||||
|
projects = []
|
||||||
|
for prj in self.factory:
|
||||||
|
r = self.lookup.get(prj, package)
|
||||||
|
if r:
|
||||||
|
projects.append(r)
|
||||||
|
|
||||||
|
if not projects:
|
||||||
|
projects = self.factory
|
||||||
|
|
||||||
|
return projects
|
||||||
|
|
||||||
|
|
||||||
class TagChecker(ReviewBot.ReviewBot):
|
class TagChecker(ReviewBot.ReviewBot):
|
||||||
@ -82,7 +212,7 @@ by OBS on which this bot relies.
|
|||||||
# already in Factory with the same revision,
|
# already in Factory with the same revision,
|
||||||
# and the package is being introduced, not updated
|
# and the package is being introduced, not updated
|
||||||
# 2) A new package must have an issue tag
|
# 2) A new package must have an issue tag
|
||||||
factory_checker = check_source_in_factory.FactorySourceChecker(apiurl=self.apiurl,
|
factory_checker = FactorySourceChecker(apiurl=self.apiurl,
|
||||||
dryrun=self.dryrun,
|
dryrun=self.dryrun,
|
||||||
logger=self.logger,
|
logger=self.logger,
|
||||||
user=self.review_user,
|
user=self.review_user,
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
Factory Source Check
|
|
||||||
====================
|
|
||||||
:author: Ludwig Nussel <ludwig.nussel@suse.de>
|
|
||||||
:toc:
|
|
||||||
|
|
||||||
|
|
||||||
Introduction
|
|
||||||
------------
|
|
||||||
[id="intro"]
|
|
||||||
|
|
||||||
A review bot that checks if the sources of a submission are either in Factory
|
|
||||||
or a request for Factory with the same sources exist. If the latter a request
|
|
||||||
is only accepted if the Factory request is reviewed positive.
|
|
||||||
|
|
||||||
It's based on the generic ReviewBot.py
|
|
||||||
|
|
||||||
Installation
|
|
||||||
------------
|
|
||||||
[id="install"]
|
|
||||||
|
|
||||||
No installation. The bot can run directly from git.
|
|
||||||
|
|
||||||
Command line
|
|
||||||
------------
|
|
||||||
[id="cli"]
|
|
||||||
|
|
||||||
Check all requests that have "factory-source" as reviewer:
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
./check_source_in_factory.py review
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Checks done
|
|
||||||
-----------
|
|
||||||
[id="checks"]
|
|
||||||
|
|
||||||
|
|
||||||
This bot accepts review requests if sources for a request are accepted in
|
|
||||||
factory. Either at top, in the history or due to a submit request with the same
|
|
||||||
sources in state new. If not the request is rejected unless a submission with
|
|
||||||
the same sources in state review exists. In that case the bot doesn't touch the
|
|
||||||
request.
|
|
@ -36,5 +36,3 @@ Checks done
|
|||||||
This bot accepts review requests if the author of the request is a known
|
This bot accepts review requests if the author of the request is a known
|
||||||
maintainer of the package in Factory. If not the devel project/package is set
|
maintainer of the package in Factory. If not the devel project/package is set
|
||||||
as reviewer.
|
as reviewer.
|
||||||
Furthermore the bot checks if the submission is for the Backports project. In that
|
|
||||||
case it adds factory-source as reviewer.
|
|
||||||
|
@ -1,300 +0,0 @@
|
|||||||
import os
|
|
||||||
import unittest
|
|
||||||
import logging
|
|
||||||
import httpretty
|
|
||||||
from osclib.cache import Cache
|
|
||||||
from . import OBSLocal
|
|
||||||
|
|
||||||
from urllib.parse import urlparse, parse_qs
|
|
||||||
from check_source_in_factory import FactorySourceChecker
|
|
||||||
|
|
||||||
APIURL = 'http://testhost.example.com'
|
|
||||||
FIXTURES = os.path.join(os.getcwd(), 'tests/fixtures')
|
|
||||||
|
|
||||||
|
|
||||||
class TestFactorySourceAccept(OBSLocal.TestCase):
|
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
httpretty.disable()
|
|
||||||
httpretty.reset()
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
"""
|
|
||||||
Initialize the configuration
|
|
||||||
"""
|
|
||||||
super().setUp()
|
|
||||||
|
|
||||||
Cache.last_updated[APIURL] = {'__oldest': '2016-12-18T11:49:37Z'}
|
|
||||||
httpretty.reset()
|
|
||||||
httpretty.enable(allow_net_connect=False)
|
|
||||||
|
|
||||||
logging.basicConfig()
|
|
||||||
self.logger = logging.getLogger(__file__)
|
|
||||||
self.logger.setLevel(logging.DEBUG)
|
|
||||||
|
|
||||||
self.checker = FactorySourceChecker(apiurl=APIURL,
|
|
||||||
user='factory-source',
|
|
||||||
logger=self.logger)
|
|
||||||
self.checker.override_allow = False # Test setup cannot handle.
|
|
||||||
|
|
||||||
def test_accept_request(self):
|
|
||||||
|
|
||||||
httpretty.register_uri(httpretty.GET,
|
|
||||||
APIURL + '/source/openSUSE:Factory/00Meta/lookup.yml',
|
|
||||||
status=404)
|
|
||||||
|
|
||||||
httpretty.register_uri(httpretty.GET,
|
|
||||||
APIURL + "/request/770001",
|
|
||||||
body="""
|
|
||||||
<request id="770001" creator="chameleon">
|
|
||||||
<action type="submit">
|
|
||||||
<source project="Base:System" package="timezone" rev="481ecbe0dfc63ece3a1f1b5598f7d96c"/>
|
|
||||||
<target project="openSUSE:13.2" package="timezone"/>
|
|
||||||
</action>
|
|
||||||
<state name="new" who="factory-source" when="2014-10-08T12:06:07">
|
|
||||||
<comment>...</comment>
|
|
||||||
</state>
|
|
||||||
<review state="new" by_user="factory-source"/>
|
|
||||||
<description>...</description>
|
|
||||||
</request>
|
|
||||||
""")
|
|
||||||
|
|
||||||
httpretty.register_uri(httpretty.GET,
|
|
||||||
APIURL + "/source/Base:System/timezone?view=info&rev=481ecbe0dfc63ece3a1f1b5598f7d96c",
|
|
||||||
match_querystring=True,
|
|
||||||
body="""
|
|
||||||
<sourceinfo package="timezone"
|
|
||||||
rev="481ecbe0dfc63ece3a1f1b5598f7d96c"
|
|
||||||
srcmd5="481ecbe0dfc63ece3a1f1b5598f7d96c"
|
|
||||||
verifymd5="67bac34d29d70553239d33aaf92d2fdd">
|
|
||||||
<filename>timezone.spec</filename>
|
|
||||||
</sourceinfo>
|
|
||||||
""")
|
|
||||||
|
|
||||||
httpretty.register_uri(httpretty.GET,
|
|
||||||
APIURL + "/source/openSUSE:Factory/timezone/_meta",
|
|
||||||
body="""
|
|
||||||
<package name="timezone" project="openSUSE:Factory">
|
|
||||||
<title>timezone</title>
|
|
||||||
<description></description>
|
|
||||||
</package>
|
|
||||||
""")
|
|
||||||
|
|
||||||
httpretty.register_uri(httpretty.GET,
|
|
||||||
APIURL + "/source/Base:System/timezone/_meta",
|
|
||||||
body="""
|
|
||||||
<package name="timezone" project="Base:System">
|
|
||||||
<title>timezone</title>
|
|
||||||
<description></description>
|
|
||||||
</package>
|
|
||||||
""")
|
|
||||||
|
|
||||||
httpretty.register_uri(httpretty.GET,
|
|
||||||
APIURL + "/source/openSUSE:Factory/timezone?view=info",
|
|
||||||
match_querystring=True,
|
|
||||||
body="""
|
|
||||||
<sourceinfo package="timezone"
|
|
||||||
rev="89"
|
|
||||||
vrev="1"
|
|
||||||
srcmd5="a36605617cbeefa8168bf0ccf3058074"
|
|
||||||
verifymd5="a36605617cbeefa8168bf0ccf3058074">
|
|
||||||
<filename>timezone.spec</filename>
|
|
||||||
</sourceinfo>
|
|
||||||
""")
|
|
||||||
|
|
||||||
httpretty.register_uri(httpretty.GET,
|
|
||||||
APIURL + "/source/openSUSE:Factory/timezone/_history?limit=5",
|
|
||||||
match_querystring=True,
|
|
||||||
body="""
|
|
||||||
<sourceinfo package="timezone"
|
|
||||||
rev="89"
|
|
||||||
vrev="1"
|
|
||||||
srcmd5="a36605617cbeefa8168bf0ccf3058074"
|
|
||||||
verifymd5="a36605617cbeefa8168bf0ccf3058074">
|
|
||||||
<filename>timezone.spec</filename>
|
|
||||||
</sourceinfo>
|
|
||||||
""")
|
|
||||||
|
|
||||||
httpretty.register_uri(httpretty.GET,
|
|
||||||
APIURL + '/search/request',
|
|
||||||
responses=[
|
|
||||||
httpretty.Response(body="""
|
|
||||||
<collection matches="1">
|
|
||||||
<request id="254684" creator="chameleon">
|
|
||||||
<action type="submit">
|
|
||||||
<source project="Base:System" package="timezone" rev="481ecbe0dfc63ece3a1f1b5598f7d96c"/>
|
|
||||||
<target project="openSUSE:Factory" package="timezone"/>
|
|
||||||
</action>
|
|
||||||
<state name="review" who="factory-auto" when="2014-10-08T11:55:56">
|
|
||||||
<comment>...</comment>
|
|
||||||
</state>
|
|
||||||
<review state="new" by_group="opensuse-review-team">
|
|
||||||
<comment/>
|
|
||||||
</review>
|
|
||||||
<description> ... </description>
|
|
||||||
</request>
|
|
||||||
</collection>
|
|
||||||
"""),
|
|
||||||
httpretty.Response(body="""
|
|
||||||
<collection matches="1">
|
|
||||||
<request id="254684" creator="chameleon">
|
|
||||||
<action type="submit">
|
|
||||||
<source project="Base:System" package="timezone" rev="481ecbe0dfc63ece3a1f1b5598f7d96c"/>
|
|
||||||
<target project="openSUSE:Factory" package="timezone"/>
|
|
||||||
</action>
|
|
||||||
<state name="new" who="factory-auto" when="2014-10-08T11:55:56">
|
|
||||||
<comment>...</comment>
|
|
||||||
</state>
|
|
||||||
<description> ... </description>
|
|
||||||
</request>
|
|
||||||
</collection>
|
|
||||||
""")
|
|
||||||
])
|
|
||||||
|
|
||||||
result = {'status': None}
|
|
||||||
|
|
||||||
def change_request(result, method, uri, headers):
|
|
||||||
query = parse_qs(urlparse(uri).query)
|
|
||||||
if query == {'by_user': ['factory-source'], 'cmd': ['changereviewstate'], 'newstate': ['accepted']}:
|
|
||||||
result['status'] = True
|
|
||||||
else:
|
|
||||||
result['status'] = 'ERROR'
|
|
||||||
return (200, headers, '<status code="blah"/>')
|
|
||||||
|
|
||||||
httpretty.register_uri(httpretty.POST,
|
|
||||||
APIURL + "/request/770001",
|
|
||||||
body=lambda method, uri, headers: change_request(result, method, uri, headers))
|
|
||||||
|
|
||||||
# first time request is in in review
|
|
||||||
self.checker.set_request_ids(['770001'])
|
|
||||||
self.checker.check_requests()
|
|
||||||
|
|
||||||
self.assertEqual(result['status'], None)
|
|
||||||
|
|
||||||
# second time request is in state new so we can accept
|
|
||||||
self.checker.set_request_ids(['770001'])
|
|
||||||
self.checker.check_requests()
|
|
||||||
|
|
||||||
self.assertTrue(result['status'])
|
|
||||||
|
|
||||||
def test_source_not_in_factory(self):
|
|
||||||
url = '/search/request?match=state%2F%40name%3D%27review%27+and+review%5B%40by_user%3D'
|
|
||||||
url += '%27factory-source%27+and+%40state%3D%27new%27%5D&withfullhistory=1'
|
|
||||||
httpretty.register_uri(httpretty.GET,
|
|
||||||
APIURL + url,
|
|
||||||
match_querystring=True,
|
|
||||||
body="""
|
|
||||||
<collection matches="1">
|
|
||||||
<request id="261411" creator="lnussel">
|
|
||||||
<action type="maintenance_incident">
|
|
||||||
<source project="home:lnussel:branches:openSUSE:Backports:SLE-12" package="plan"
|
|
||||||
rev="71e76daf2c2e9ddb0b9208f54a14f608"/>
|
|
||||||
<target project="openSUSE:Maintenance" releaseproject="openSUSE:Backports:SLE-12"/>
|
|
||||||
</action>
|
|
||||||
<state name="review" who="maintbot" when="2014-11-13T13:22:02">
|
|
||||||
<comment></comment>
|
|
||||||
</state>
|
|
||||||
<review state="accepted" when="2014-11-13T13:22:02" who="maintbot" by_user="maintbot">
|
|
||||||
<comment>accepted</comment>
|
|
||||||
<history who="maintbot" when="2014-11-13T16:43:09">
|
|
||||||
<description>Review got accepted</description>
|
|
||||||
<comment>accepted</comment>
|
|
||||||
</history>
|
|
||||||
</review>
|
|
||||||
<review state="new" by_user="factory-source"/>
|
|
||||||
<history who="lnussel" when="2014-11-13T13:22:02">
|
|
||||||
<description>Request created</description>
|
|
||||||
<comment>test update</comment>
|
|
||||||
</history>
|
|
||||||
<history who="maintbot" when="2014-11-13T16:43:08">
|
|
||||||
<description>Request got a new review request</description>
|
|
||||||
</history>
|
|
||||||
<description>test update</description>
|
|
||||||
</request>
|
|
||||||
</collection>
|
|
||||||
""")
|
|
||||||
|
|
||||||
httpretty.register_uri(httpretty.GET,
|
|
||||||
APIURL + "/request/261411",
|
|
||||||
body="""
|
|
||||||
<request id="261411" creator="lnussel">
|
|
||||||
<action type="maintenance_incident">
|
|
||||||
<source project="home:lnussel:branches:openSUSE:Backports:SLE-12" package="plan"
|
|
||||||
rev="71e76daf2c2e9ddb0b9208f54a14f608"/>
|
|
||||||
<target project="openSUSE:Maintenance" releaseproject="openSUSE:Backports:SLE-12"/>
|
|
||||||
</action>
|
|
||||||
<state name="review" who="maintbot" when="2014-11-13T13:22:02">
|
|
||||||
<comment></comment>
|
|
||||||
</state>
|
|
||||||
<review state="accepted" when="2014-11-13T13:22:02" who="maintbot" by_user="maintbot">
|
|
||||||
<comment>accepted</comment>
|
|
||||||
<history who="maintbot" when="2014-11-13T16:43:09">
|
|
||||||
<description>Review got accepted</description>
|
|
||||||
<comment>accepted</comment>
|
|
||||||
</history>
|
|
||||||
</review>
|
|
||||||
<review state="new" by_user="factory-source"/>
|
|
||||||
<history who="lnussel" when="2014-11-13T13:22:02">
|
|
||||||
<description>Request created</description>
|
|
||||||
<comment>test update</comment>
|
|
||||||
</history>
|
|
||||||
<history who="maintbot" when="2014-11-13T16:43:08">
|
|
||||||
<description>Request got a new review request</description>
|
|
||||||
</history>
|
|
||||||
<description>test update</description>
|
|
||||||
</request>
|
|
||||||
""")
|
|
||||||
|
|
||||||
httpretty.register_uri(httpretty.GET,
|
|
||||||
APIURL + "/source/home:lnussel:branches:openSUSE:Backports:SLE-12/plan",
|
|
||||||
body="""
|
|
||||||
<directory name="plan" rev="1" vrev="1" srcmd5="b4ed19dc30c1b328168bc62a81ec6998">
|
|
||||||
<linkinfo project="home:lnussel:plan" package="plan" srcmd5="7a2353f73b29dba970702053229542a0"
|
|
||||||
baserev="7a2353f73b29dba970702053229542a0" xsrcmd5="71e76daf2c2e9ddb0b9208f54a14f608"
|
|
||||||
lsrcmd5="b4ed19dc30c1b328168bc62a81ec6998" />
|
|
||||||
<entry name="_link" md5="91f81d88456818a18a7332999fb2da18" size="125" mtime="1415807350" />
|
|
||||||
<entry name="plan.spec" md5="b6814215f6d2e8559b43de9a214b2cbd" size="8103" mtime="1413627959" />
|
|
||||||
</directory>
|
|
||||||
""")
|
|
||||||
|
|
||||||
httpretty.register_uri(httpretty.GET,
|
|
||||||
APIURL + "/source/openSUSE:Factory/plan/_meta",
|
|
||||||
status=404,
|
|
||||||
body="""
|
|
||||||
<status code="unknown_package">
|
|
||||||
<summary>openSUSE:Factory/plan</summary>
|
|
||||||
</status>
|
|
||||||
""")
|
|
||||||
|
|
||||||
httpretty.register_uri(httpretty.GET,
|
|
||||||
APIURL + '/source/openSUSE:Factory/00Meta/lookup.yml',
|
|
||||||
status=404)
|
|
||||||
|
|
||||||
httpretty.register_uri(httpretty.GET,
|
|
||||||
APIURL + '/search/request',
|
|
||||||
body="""
|
|
||||||
<collection matches="0">
|
|
||||||
</collection>
|
|
||||||
""")
|
|
||||||
|
|
||||||
result = {'factory_source_declined': None}
|
|
||||||
|
|
||||||
def change_request(result, method, uri, headers):
|
|
||||||
query = parse_qs(urlparse(uri).query)
|
|
||||||
if query == {'by_user': ['factory-source'], 'cmd': ['changereviewstate'], 'newstate': ['declined']}:
|
|
||||||
result['factory_source_declined'] = True
|
|
||||||
return (200, headers, '<status code="ok"/>')
|
|
||||||
|
|
||||||
httpretty.register_uri(httpretty.POST,
|
|
||||||
APIURL + "/request/261411",
|
|
||||||
body=lambda method, uri, headers: change_request(result, method, uri, headers))
|
|
||||||
|
|
||||||
self.checker.requests = []
|
|
||||||
self.checker.set_request_ids_search_review()
|
|
||||||
self.checker.check_requests()
|
|
||||||
|
|
||||||
self.assertTrue(result['factory_source_declined'])
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
unittest.main()
|
|
@ -281,89 +281,6 @@ class TestMaintenance(OBSLocal.TestCase):
|
|||||||
|
|
||||||
self.assertFalse(result['devel_review_added'])
|
self.assertFalse(result['devel_review_added'])
|
||||||
|
|
||||||
def test_backports_submit(self):
|
|
||||||
|
|
||||||
httpretty.register_uri(httpretty.GET,
|
|
||||||
APIURL + '/search/request',
|
|
||||||
body="""
|
|
||||||
<collection matches="1">
|
|
||||||
<request id="261411" creator="lnussel">
|
|
||||||
<action type="maintenance_incident">
|
|
||||||
<source project="home:lnussel:branches:openSUSE:Backports:SLE-12"
|
|
||||||
package="plan" rev="71e76daf2c2e9ddb0b9208f54a14f608"/>
|
|
||||||
<target project="openSUSE:Maintenance" releaseproject="openSUSE:Backports:SLE-12"/>
|
|
||||||
</action>
|
|
||||||
<state name="review" who="lnussel" when="2014-11-13T13:22:02">
|
|
||||||
<comment></comment>
|
|
||||||
</state>
|
|
||||||
<review state="new" by_user="maintbot"/>
|
|
||||||
<history who="lnussel" when="2014-11-13T13:22:02">
|
|
||||||
<description>Request created</description>
|
|
||||||
<comment>test update</comment>
|
|
||||||
</history>
|
|
||||||
<description>test update</description>
|
|
||||||
</request>
|
|
||||||
</collection>
|
|
||||||
""")
|
|
||||||
|
|
||||||
httpretty.register_uri(httpretty.GET,
|
|
||||||
APIURL + "/request/261411",
|
|
||||||
body="""
|
|
||||||
<request id="261411" creator="lnussel">
|
|
||||||
<action type="maintenance_incident">
|
|
||||||
<source project="home:lnussel:branches:openSUSE:Backports:SLE-12"
|
|
||||||
package="plan" rev="71e76daf2c2e9ddb0b9208f54a14f608"/>
|
|
||||||
<target project="openSUSE:Maintenance" releaseproject="openSUSE:Backports:SLE-12"/>
|
|
||||||
</action>
|
|
||||||
<state name="review" who="lnussel" when="2014-11-13T13:22:02">
|
|
||||||
<comment></comment>
|
|
||||||
</state>
|
|
||||||
<review state="new" by_user="maintbot"/>
|
|
||||||
<history who="lnussel" when="2014-11-13T13:22:02">
|
|
||||||
<description>Request created</description>
|
|
||||||
<comment>test update</comment>
|
|
||||||
</history>
|
|
||||||
<description>test update</description>
|
|
||||||
</request>
|
|
||||||
""")
|
|
||||||
|
|
||||||
httpretty.register_uri(httpretty.GET,
|
|
||||||
APIURL + "/source/home:lnussel:branches:openSUSE:Backports:SLE-12/plan",
|
|
||||||
body="""
|
|
||||||
<directory name="plan" rev="1" vrev="1" srcmd5="b4ed19dc30c1b328168bc62a81ec6998">
|
|
||||||
<linkinfo project="home:lnussel:plan" package="plan" srcmd5="7a2353f73b29dba970702053229542a0"
|
|
||||||
baserev="7a2353f73b29dba970702053229542a0" xsrcmd5="71e76daf2c2e9ddb0b9208f54a14f608"
|
|
||||||
lsrcmd5="b4ed19dc30c1b328168bc62a81ec6998" />
|
|
||||||
<entry name="_link" md5="91f81d88456818a18a7332999fb2da18" size="125" mtime="1415807350" />
|
|
||||||
<entry name="plan.spec" md5="b6814215f6d2e8559b43de9a214b2cbd" size="8103" mtime="1413627959" />
|
|
||||||
</directory>
|
|
||||||
|
|
||||||
""")
|
|
||||||
|
|
||||||
httpretty.register_uri(httpretty.GET,
|
|
||||||
APIURL + '/search/owner',
|
|
||||||
body="""
|
|
||||||
<collection/>
|
|
||||||
""")
|
|
||||||
|
|
||||||
result = {'factory_review_added': None}
|
|
||||||
|
|
||||||
def change_request(result, method, uri, headers):
|
|
||||||
query = parse_qs(urlparse(uri).query)
|
|
||||||
if query == {'cmd': ['addreview'], 'by_user': ['factory-source']}:
|
|
||||||
result['factory_review_added'] = True
|
|
||||||
return (200, headers, '<status code="ok"/>')
|
|
||||||
|
|
||||||
httpretty.register_uri(httpretty.POST,
|
|
||||||
APIURL + "/request/261411",
|
|
||||||
body=lambda method, uri, headers: change_request(result, method, uri, headers))
|
|
||||||
|
|
||||||
self.checker.requests = []
|
|
||||||
self.checker.set_request_ids_search_review()
|
|
||||||
self.checker.check_requests()
|
|
||||||
|
|
||||||
self.assertTrue(result['factory_review_added'])
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user