commit
0f6c728741
@ -9,6 +9,9 @@ class ListCommand:
|
||||
self.api = api
|
||||
|
||||
def perform(self):
|
||||
"""
|
||||
Perform the list command
|
||||
"""
|
||||
self.packages_staged = dict()
|
||||
for prj in self.api.get_staging_projects():
|
||||
meta = self.api.get_prj_pseudometa(prj)
|
||||
@ -26,25 +29,33 @@ class ListCommand:
|
||||
for letter, reqs in self.supersedes.items():
|
||||
print("osc staging select {} {}".format(letter, ' '.join(reqs)))
|
||||
|
||||
def one_request(self, rq):
|
||||
id = int(rq.get('id'))
|
||||
actions = rq.findall('action')
|
||||
def one_request(self, request):
|
||||
"""
|
||||
Process one request potentially to be listed
|
||||
:param request: request to process
|
||||
"""
|
||||
rq_id = int(request.get('id'))
|
||||
actions = request.findall('action')
|
||||
act = actions[0]
|
||||
|
||||
# tprj = act.find('target').get('project')
|
||||
tpkg = act.find('target').get('package')
|
||||
|
||||
stage_info = self.packages_staged.get(tpkg, ('', 0))
|
||||
if stage_info[1] != 0 and int(stage_info[1]) != id:
|
||||
reqs = self.supersedes.get(stage_info[0], [])
|
||||
reqs.append(str(id))
|
||||
self.supersedes[stage_info[0]] = reqs
|
||||
# Replace superseded
|
||||
stage_info = self.packages_staged.get(tpkg, {'prj': '', 'rq_id': 0})
|
||||
if stage_info['rq_id'] != 0 and int(stage_info['rq_id']) != rq_id:
|
||||
# Remove the old request
|
||||
self.api.rm_from_prj(stage_info['prj'], request_id=stage_info['rq_id'],
|
||||
review='declined', msg='Replaced by newer request')
|
||||
# Add the new one that should be replacing it
|
||||
self.api.rq_to_prj(rq_id, stage_info['prj'])
|
||||
# Update local data structure
|
||||
self.packages_staged[tpkg]['rq_id'] = rq_id
|
||||
return
|
||||
|
||||
ring = self.api.ring_packages.get(tpkg)
|
||||
if ring:
|
||||
print("Request(%d): %s -> %s" % (id, tpkg, ring))
|
||||
return
|
||||
|
||||
|
||||
# no ring, no group -> ok
|
||||
self.api.change_review_state(id, 'accepted', by_group='factory-staging', message='ok')
|
||||
|
@ -130,7 +130,7 @@ class TestApiCalls(unittest.TestCase):
|
||||
Test if we get proper project, name and revision from the staging informations
|
||||
"""
|
||||
|
||||
package_info = {'project': 'devel:wine',
|
||||
package_info = {'project': 'home:Admin',
|
||||
'rev': '7b98ac01b8071d63a402fa99dc79331c',
|
||||
'srcmd5': '7b98ac01b8071d63a402fa99dc79331c',
|
||||
'package': 'wine'}
|
||||
@ -378,3 +378,13 @@ class TestApiCalls(unittest.TestCase):
|
||||
# U == unfrozen
|
||||
self.assertEqual(self.obs.api.prj_frozen_enough('openSUSE:Factory:Staging:U'), False)
|
||||
|
||||
@httpretty.activate
|
||||
def test_move(self):
|
||||
|
||||
# Register OBS
|
||||
self.obs.register_obs()
|
||||
|
||||
init_data = self.obs.api.get_package_information('openSUSE:Factory:Staging:B', 'wine')
|
||||
self.obs.api.move_between_project('openSUSE:Factory:Staging:B', 333, 'openSUSE:Factory:Staging:A')
|
||||
test_data = self.obs.api.get_package_information('openSUSE:Factory:Staging:A', 'wine')
|
||||
self.assertEqual(init_data, test_data)
|
||||
|
@ -88,10 +88,13 @@ class OBS:
|
||||
}
|
||||
self.links_data = { 'openSUSE:Factory:Staging:B/wine':
|
||||
{ 'prj': 'openSUSE:Factory:Staging:B',
|
||||
'pkg': 'wine', 'devprj': 'devel:wine' }
|
||||
'pkg': 'wine', 'devprj': 'home:Admin' }
|
||||
}
|
||||
self.pkg_data = { 'home:Admin/gcc':
|
||||
{ 'rev': '1', 'vrev': '1', 'name': 'gcc',
|
||||
'srcmd5': 'de7a9f5e3bedb01980465f3be3d236cb' },
|
||||
'home:Admin/wine':
|
||||
{ 'rev': '1', 'vrev': '1', 'name': 'wine',
|
||||
'srcmd5': 'de7a9f5e3bedb01980465f3be3d236cb' }
|
||||
}
|
||||
|
||||
@ -300,12 +303,15 @@ class OBS:
|
||||
return "Ok"
|
||||
|
||||
def create_link(responses, request, uri):
|
||||
tmpl = Template(self._get_fixture_content('linksource.xml'))
|
||||
key = re.match( r'.*/source/(.+)/_link',uri).group(1)
|
||||
match = re.match( r'(.+)/(.+)', key)
|
||||
xml = ET.fromstring(str(request.body))
|
||||
self.links_data[str(key)] = { 'prj': match.group(1), 'pkg': match.group(2),
|
||||
'devprj': xml.get('project')
|
||||
}
|
||||
self.responses['GET']['/source/' + key] = tmpl.substitute(self.links_data[key])
|
||||
self.responses['DELETE']['/source/' + key] = delete_link
|
||||
return "Ok"
|
||||
|
||||
# Register methods for requests
|
||||
|
Loading…
x
Reference in New Issue
Block a user