2014-02-04 11:23:23 +01:00
|
|
|
#!/usr/bin/env python
|
2014-02-11 10:43:18 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
2014-02-04 11:23:23 +01:00
|
|
|
#
|
|
|
|
# (C) 2014 tchvatal@suse.cz, openSUSE.org
|
|
|
|
# Distribute under GPLv2 or later
|
|
|
|
|
2014-02-13 14:15:14 +01:00
|
|
|
import sys
|
2014-02-04 11:23:23 +01:00
|
|
|
import unittest
|
2014-02-04 14:04:46 +01:00
|
|
|
import httpretty
|
2014-03-03 23:31:43 +01:00
|
|
|
import mock
|
2014-03-04 10:55:55 +01:00
|
|
|
import time
|
2014-02-28 11:11:10 +01:00
|
|
|
|
2014-03-04 10:55:55 +01:00
|
|
|
from string import Template
|
2014-02-25 10:58:21 +01:00
|
|
|
from obs import OBS
|
2014-03-04 10:55:55 +01:00
|
|
|
from osc import oscerr
|
2014-02-04 11:23:23 +01:00
|
|
|
|
2014-02-18 23:35:45 +01:00
|
|
|
PY3 = sys.version_info[0] == 3
|
|
|
|
|
|
|
|
if PY3:
|
|
|
|
string_types = str,
|
|
|
|
else:
|
|
|
|
string_types = basestring,
|
2014-02-24 15:52:30 +01:00
|
|
|
|
2014-02-28 11:11:10 +01:00
|
|
|
|
2014-02-24 15:52:30 +01:00
|
|
|
class TestApiCalls(unittest.TestCase):
|
|
|
|
"""
|
|
|
|
Tests for various api calls to ensure we return expected content
|
|
|
|
"""
|
|
|
|
|
2014-02-04 14:04:46 +01:00
|
|
|
def setUp(self):
|
|
|
|
"""
|
2014-02-24 17:20:48 +01:00
|
|
|
Initialize the configuration
|
2014-02-04 14:04:46 +01:00
|
|
|
"""
|
|
|
|
|
2014-02-24 17:20:48 +01:00
|
|
|
self.obs = OBS()
|
2014-02-04 11:23:23 +01:00
|
|
|
|
2014-02-10 13:24:49 +01:00
|
|
|
@httpretty.activate
|
|
|
|
def test_ring_packages(self):
|
|
|
|
"""
|
|
|
|
Validate the creation of the rings.
|
|
|
|
"""
|
|
|
|
|
|
|
|
# our content in the XML files
|
2014-02-12 13:15:49 +01:00
|
|
|
ring_packages = {
|
|
|
|
'elem-ring-0': 'openSUSE:Factory:Rings:0-Bootstrap',
|
|
|
|
'elem-ring-1': 'openSUSE:Factory:Rings:1-MinimalX',
|
|
|
|
}
|
2014-02-10 13:24:49 +01:00
|
|
|
|
2014-02-26 16:22:56 +01:00
|
|
|
# Register OBS
|
|
|
|
self.obs.register_obs()
|
|
|
|
self.assertEqual(ring_packages, self.obs.api.ring_packages)
|
2014-02-10 13:24:49 +01:00
|
|
|
|
2014-02-10 13:58:59 +01:00
|
|
|
@httpretty.activate
|
|
|
|
def test_dispatch_open_requests(self):
|
|
|
|
"""
|
|
|
|
Test dispatching and closure of non-ring packages
|
|
|
|
"""
|
|
|
|
|
2014-02-24 15:52:30 +01:00
|
|
|
# Register OBS
|
|
|
|
self.obs.register_obs()
|
2014-02-25 13:12:10 +01:00
|
|
|
|
2014-02-24 15:52:30 +01:00
|
|
|
# Get rid of open requests
|
|
|
|
self.obs.api.dispatch_open_requests()
|
|
|
|
# Check that we tried to close it
|
|
|
|
self.assertEqual(httpretty.last_request().method, 'POST')
|
|
|
|
self.assertEqual(httpretty.last_request().querystring[u'cmd'], [u'changereviewstate'])
|
|
|
|
# Try it again
|
|
|
|
self.obs.api.dispatch_open_requests()
|
|
|
|
# This time there should be nothing to close
|
|
|
|
self.assertEqual(httpretty.last_request().method, 'GET')
|
2014-02-10 13:24:49 +01:00
|
|
|
|
2014-02-10 14:25:31 +01:00
|
|
|
@httpretty.activate
|
|
|
|
def test_pseudometa_get_prj(self):
|
|
|
|
"""
|
|
|
|
Test getting project metadata from YAML in project description
|
|
|
|
"""
|
|
|
|
|
2014-02-25 09:28:46 +01:00
|
|
|
# Register OBS
|
|
|
|
self.obs.register_obs()
|
2014-02-10 14:25:31 +01:00
|
|
|
|
2014-02-25 09:28:46 +01:00
|
|
|
# Try to get data from project that has no metadata
|
|
|
|
data = self.obs.api.get_prj_pseudometa('openSUSE:Factory:Staging:A')
|
|
|
|
# Should be empty, but contain structure to work with
|
|
|
|
self.assertEqual(data, {'requests': []})
|
|
|
|
# Add some sample data
|
|
|
|
rq = { 'id': '123', 'package': 'test-package' }
|
|
|
|
data['requests'].append(rq)
|
|
|
|
# Save them and read them back
|
|
|
|
self.obs.api.set_prj_pseudometa('openSUSE:Factory:Staging:A',data)
|
|
|
|
test_data = self.obs.api.get_prj_pseudometa('openSUSE:Factory:Staging:A')
|
|
|
|
# Verify that we got back the same data
|
|
|
|
self.assertEqual(data,test_data)
|
2014-02-13 10:44:58 +01:00
|
|
|
|
2014-02-04 14:04:46 +01:00
|
|
|
@httpretty.activate
|
2014-02-04 11:23:23 +01:00
|
|
|
def test_list_projects(self):
|
|
|
|
"""
|
|
|
|
List projects and their content
|
|
|
|
"""
|
2014-02-10 13:58:59 +01:00
|
|
|
|
2014-02-25 13:12:10 +01:00
|
|
|
self.obs.register_obs()
|
2014-02-04 11:23:23 +01:00
|
|
|
|
2014-02-25 13:12:10 +01:00
|
|
|
# Prepare expected results
|
|
|
|
data = []
|
|
|
|
for prj in self.obs.st_project_data:
|
|
|
|
data.append('openSUSE:Factory:Staging:' + prj)
|
2014-02-10 13:24:49 +01:00
|
|
|
|
|
|
|
# Compare the results
|
2014-02-25 13:12:10 +01:00
|
|
|
self.assertEqual(data, self.obs.api.get_staging_projects())
|
2014-02-10 13:24:49 +01:00
|
|
|
|
|
|
|
@httpretty.activate
|
|
|
|
def test_open_requests(self):
|
|
|
|
"""
|
2014-02-12 14:27:49 +01:00
|
|
|
Test searching for open requests
|
2014-02-10 13:24:49 +01:00
|
|
|
"""
|
|
|
|
|
2014-02-10 13:58:59 +01:00
|
|
|
requests = []
|
2014-02-10 13:24:49 +01:00
|
|
|
|
2014-02-24 17:20:48 +01:00
|
|
|
self.obs.register_obs()
|
2014-02-10 13:24:49 +01:00
|
|
|
|
|
|
|
# get the open requests
|
2014-02-24 17:20:48 +01:00
|
|
|
requests = self.obs.api.get_open_requests()
|
2014-02-10 13:24:49 +01:00
|
|
|
|
2014-02-24 17:20:48 +01:00
|
|
|
# Compare the results, we only care now that we got 1 of them not the content
|
|
|
|
self.assertEqual(1, len(requests))
|
2014-02-10 13:24:49 +01:00
|
|
|
|
2014-02-12 14:27:49 +01:00
|
|
|
@httpretty.activate
|
|
|
|
def test_get_package_information(self):
|
|
|
|
"""
|
|
|
|
Test if we get proper project, name and revision from the staging informations
|
|
|
|
"""
|
|
|
|
|
|
|
|
package_info = {'project': 'devel:wine',
|
|
|
|
'rev': '7b98ac01b8071d63a402fa99dc79331c',
|
|
|
|
'srcmd5': '7b98ac01b8071d63a402fa99dc79331c',
|
|
|
|
'package': 'wine'}
|
|
|
|
|
2014-02-25 15:44:40 +01:00
|
|
|
self.obs.register_obs()
|
2014-02-12 14:27:49 +01:00
|
|
|
|
|
|
|
# Compare the results, we only care now that we got 2 of them not the content
|
|
|
|
self.assertEqual(package_info,
|
2014-02-25 15:44:40 +01:00
|
|
|
self.obs.api.get_package_information('openSUSE:Factory:Staging:B', 'wine'))
|
2014-02-12 14:27:49 +01:00
|
|
|
|
2014-02-26 09:51:30 +01:00
|
|
|
@httpretty.activate
|
2014-02-26 10:04:21 +01:00
|
|
|
def test_request_id_package_mapping(self):
|
2014-02-26 09:51:30 +01:00
|
|
|
"""
|
|
|
|
Test whether we can get correct id for sr in staging project
|
|
|
|
"""
|
|
|
|
|
|
|
|
self.obs.register_obs()
|
|
|
|
|
2014-02-26 10:04:21 +01:00
|
|
|
prj = 'openSUSE:Factory:Staging:B'
|
|
|
|
# Get rq
|
|
|
|
num = self.obs.api.get_request_id_for_package(prj, 'wine')
|
|
|
|
self.assertEqual(333,num)
|
|
|
|
# Get package name
|
|
|
|
self.assertEqual('wine',self.obs.api.get_package_for_request_id(prj, num))
|
2014-02-26 09:51:30 +01:00
|
|
|
|
2014-02-27 16:11:27 +01:00
|
|
|
@httpretty.activate
|
|
|
|
def test_check_one_request(self):
|
|
|
|
self.obs.register_obs()
|
|
|
|
|
|
|
|
prj = 'openSUSE:Factory:Staging:B'
|
|
|
|
pkg = 'wine'
|
|
|
|
|
|
|
|
# Verify package is there
|
|
|
|
self.assertEqual(self.obs.links_data.has_key(prj + '/' + pkg),True)
|
|
|
|
# Get rq number
|
|
|
|
num = self.obs.api.get_request_id_for_package(prj, pkg)
|
|
|
|
# Check the results
|
|
|
|
self.assertEqual(self.obs.api.check_one_request(num,prj), None)
|
|
|
|
# Pretend to be reviewed by other project
|
|
|
|
self.assertEqual(self.obs.api.check_one_request(num,'xyz'),
|
|
|
|
'wine: missing reviews: openSUSE:Factory:Staging:B')
|
|
|
|
|
2014-03-03 16:17:41 +01:00
|
|
|
@httpretty.activate
|
|
|
|
def test_check_project_status(self):
|
|
|
|
self.obs.register_obs()
|
|
|
|
|
|
|
|
# Check the results
|
|
|
|
with mock.patch('oscs.StagingAPI.find_openqa_state', return_value="Nothing"):
|
2014-03-03 23:27:53 +01:00
|
|
|
broken_results = ['At least following repositories is still building:',
|
|
|
|
' building/x86_64: building',
|
|
|
|
'Following packages are broken:',
|
|
|
|
' wine (failed/x86_64): failed',
|
|
|
|
' wine (broken/x86_64): broken',
|
|
|
|
'Nothing']
|
|
|
|
self.assertEqual(self.obs.api.check_project_status('openSUSE:Factory:Staging:B'), broken_results)
|
|
|
|
self.assertEqual(self.obs.api.check_project_status('openSUSE:Factory:Staging:A'), False)
|
2014-03-03 16:17:41 +01:00
|
|
|
|
2014-02-26 10:59:41 +01:00
|
|
|
@httpretty.activate
|
|
|
|
def test_rm_from_prj(self):
|
|
|
|
self.obs.register_obs()
|
|
|
|
|
|
|
|
prj = 'openSUSE:Factory:Staging:B'
|
2014-02-26 15:24:25 +01:00
|
|
|
pkg = 'wine'
|
2014-02-26 10:59:41 +01:00
|
|
|
|
|
|
|
# Verify package is there
|
2014-02-26 15:24:25 +01:00
|
|
|
self.assertEqual(self.obs.links_data.has_key(prj + '/' + pkg),True)
|
2014-02-26 10:59:41 +01:00
|
|
|
# Get rq number
|
2014-02-26 15:24:25 +01:00
|
|
|
num = self.obs.api.get_request_id_for_package(prj, pkg)
|
2014-02-26 10:59:41 +01:00
|
|
|
# Delete the package
|
|
|
|
self.obs.api.rm_from_prj(prj, package='wine');
|
|
|
|
# Verify package is not there
|
2014-02-26 15:24:25 +01:00
|
|
|
self.assertEqual(self.obs.links_data.has_key(prj + '/' + pkg),False)
|
|
|
|
# RQ is gone
|
|
|
|
self.assertEqual(None, self.obs.api.get_request_id_for_package(prj, pkg))
|
|
|
|
self.assertEqual(None, self.obs.api.get_package_for_request_id(prj, num))
|
2014-02-26 10:59:41 +01:00
|
|
|
# Verify that review is closed
|
|
|
|
self.assertEqual('accepted', self.obs.requests_data[str(num)]['review'])
|
|
|
|
self.assertEqual('new', self.obs.requests_data[str(num)]['request'])
|
|
|
|
|
2014-02-27 15:54:13 +01:00
|
|
|
# Try the same with request number
|
|
|
|
self.obs.reset_config()
|
|
|
|
# Delete the package
|
|
|
|
self.obs.api.rm_from_prj(prj, request_id=num);
|
|
|
|
# Verify package is not there
|
|
|
|
self.assertEqual(self.obs.links_data.has_key(prj + '/' + pkg),False)
|
|
|
|
# RQ is gone
|
|
|
|
self.assertEqual(None, self.obs.api.get_request_id_for_package(prj, pkg))
|
|
|
|
self.assertEqual(None, self.obs.api.get_package_for_request_id(prj, num))
|
|
|
|
# Verify that review is closed
|
|
|
|
self.assertEqual('accepted', self.obs.requests_data[str(num)]['review'])
|
|
|
|
self.assertEqual('new', self.obs.requests_data[str(num)]['request'])
|
|
|
|
|
2014-02-26 15:24:25 +01:00
|
|
|
@httpretty.activate
|
|
|
|
def test_add_sr(self):
|
|
|
|
self.obs.register_obs()
|
|
|
|
|
|
|
|
prj = 'openSUSE:Factory:Staging:A'
|
|
|
|
rq = '123'
|
|
|
|
pkg = self.obs.requests_data[rq]['package']
|
|
|
|
|
2014-02-26 16:30:03 +01:00
|
|
|
# Running it twice shouldn't change anything
|
|
|
|
for i in [1,2]:
|
|
|
|
# Add rq to the project
|
|
|
|
self.obs.api.rq_to_prj(rq, prj);
|
|
|
|
# Verify that review is there
|
|
|
|
self.assertEqual('new', self.obs.requests_data[str(rq)]['review'])
|
|
|
|
self.assertEqual('review', self.obs.requests_data[str(rq)]['request'])
|
|
|
|
self.assertEqual(self.obs.api.get_prj_pseudometa('openSUSE:Factory:Staging:A'),
|
|
|
|
{'requests': [{'id': 123, 'package': 'gcc'}]})
|
2014-02-26 15:24:25 +01:00
|
|
|
|
2014-02-27 15:11:43 +01:00
|
|
|
@httpretty.activate
|
|
|
|
def test_generate_build_status_details(self):
|
|
|
|
"""
|
|
|
|
Check whether generate_build_status_details works
|
|
|
|
"""
|
|
|
|
|
|
|
|
self.obs.register_obs()
|
|
|
|
details_green = self.obs.api.gather_build_status('green')
|
|
|
|
details_red = self.obs.api.gather_build_status('red')
|
|
|
|
red = ['red', [{'path': 'standard/x86_64', 'state': 'building'}],
|
|
|
|
[{'path': 'standard/i586', 'state': 'broken', 'pkg': 'glibc'},
|
|
|
|
{'path': 'standard/i586', 'state': 'failed', 'pkg': 'openSUSE-images'}]]
|
|
|
|
red_result = ['At least following repositories is still building:',
|
|
|
|
' standard/x86_64: building',
|
|
|
|
'Following packages are broken:',
|
|
|
|
' glibc (standard/i586): broken',
|
|
|
|
' openSUSE-images (standard/i586): failed'
|
|
|
|
]
|
|
|
|
self.assertEqual(details_red, red)
|
|
|
|
self.assertEqual(self.obs.api.generate_build_status_details(details_red), red_result)
|
|
|
|
self.assertEqual(self.obs.api.generate_build_status_details(details_red,True), red_result)
|
|
|
|
self.assertEqual(details_green, None)
|
|
|
|
self.assertEqual(self.obs.api.generate_build_status_details(details_green), [])
|
|
|
|
|
2014-02-13 14:15:14 +01:00
|
|
|
@httpretty.activate
|
|
|
|
def test_create_package_container(self):
|
|
|
|
"""
|
|
|
|
Test if the uploaded _meta is correct
|
|
|
|
"""
|
|
|
|
|
2014-02-26 16:22:56 +01:00
|
|
|
self.obs.register_obs()
|
2014-02-13 14:15:14 +01:00
|
|
|
|
2014-02-26 16:22:56 +01:00
|
|
|
self.obs.api.create_package_container('openSUSE:Factory:Staging:B', 'wine')
|
2014-02-13 14:15:14 +01:00
|
|
|
self.assertEqual(httpretty.last_request().method, 'PUT')
|
|
|
|
self.assertEqual(httpretty.last_request().body, '<package name="wine"><title/><description/></package>')
|
|
|
|
self.assertEqual(httpretty.last_request().path, '/source/openSUSE:Factory:Staging:B/wine/_meta')
|
2014-02-10 13:24:49 +01:00
|
|
|
|
2014-02-26 16:22:56 +01:00
|
|
|
self.obs.api.create_package_container('openSUSE:Factory:Staging:B', 'wine', disable_build=True)
|
2014-02-13 14:18:16 +01:00
|
|
|
self.assertEqual(httpretty.last_request().method, 'PUT')
|
|
|
|
self.assertEqual(httpretty.last_request().body, '<package name="wine"><title /><description /><build><disable /></build></package>')
|
|
|
|
self.assertEqual(httpretty.last_request().path, '/source/openSUSE:Factory:Staging:B/wine/_meta')
|
|
|
|
|
2014-02-17 15:12:18 +01:00
|
|
|
@httpretty.activate
|
2014-02-18 23:35:45 +01:00
|
|
|
def test_review_handling(self):
|
2014-02-17 15:12:18 +01:00
|
|
|
"""
|
2014-02-18 23:35:45 +01:00
|
|
|
Test whether accepting/creating reviews behaves correctly
|
2014-02-17 15:12:18 +01:00
|
|
|
"""
|
|
|
|
|
2014-02-24 15:52:30 +01:00
|
|
|
# Register OBS
|
|
|
|
self.obs.register_obs()
|
2014-02-17 15:12:18 +01:00
|
|
|
|
2014-02-18 23:35:45 +01:00
|
|
|
# Add review
|
2014-02-24 17:20:48 +01:00
|
|
|
self.obs.api.add_review('123', by_project='openSUSE:Factory:Staging:A')
|
2014-02-17 15:12:18 +01:00
|
|
|
self.assertEqual(httpretty.last_request().method, 'POST')
|
2014-02-18 23:35:45 +01:00
|
|
|
self.assertEqual(httpretty.last_request().querystring[u'cmd'], [u'addreview'])
|
|
|
|
# Try to readd, should do anything
|
2014-02-24 17:20:48 +01:00
|
|
|
self.obs.api.add_review('123', by_project='openSUSE:Factory:Staging:A')
|
2014-02-18 23:35:45 +01:00
|
|
|
self.assertEqual(httpretty.last_request().method, 'GET')
|
|
|
|
# Accept review
|
2014-02-24 15:52:30 +01:00
|
|
|
self.obs.api.set_review('123', 'openSUSE:Factory:Staging:A')
|
2014-02-18 23:35:45 +01:00
|
|
|
self.assertEqual(httpretty.last_request().method, 'POST')
|
|
|
|
self.assertEqual(httpretty.last_request().querystring[u'cmd'], [u'changereviewstate'])
|
|
|
|
# Try to accept it again should do anything
|
2014-02-24 15:52:30 +01:00
|
|
|
self.obs.api.set_review('123', 'openSUSE:Factory:Staging:A')
|
2014-02-17 15:12:18 +01:00
|
|
|
self.assertEqual(httpretty.last_request().method, 'GET')
|
2014-02-18 23:35:45 +01:00
|
|
|
# But we should be able to reopen it
|
2014-02-24 17:20:48 +01:00
|
|
|
self.obs.api.add_review('123', by_project='openSUSE:Factory:Staging:A')
|
2014-02-18 23:35:45 +01:00
|
|
|
self.assertEqual(httpretty.last_request().method, 'POST')
|
|
|
|
self.assertEqual(httpretty.last_request().querystring[u'cmd'], [u'addreview'])
|
|
|
|
|
2014-02-27 13:39:57 +01:00
|
|
|
@httpretty.activate
|
2014-02-26 16:11:32 +01:00
|
|
|
def test_prj_from_letter(self):
|
|
|
|
# Register OBS
|
|
|
|
self.obs.register_obs()
|
|
|
|
|
|
|
|
# Verify it works
|
|
|
|
self.assertEqual(self.obs.api.prj_from_letter('openSUSE:Factory'), 'openSUSE:Factory')
|
|
|
|
self.assertEqual(self.obs.api.prj_from_letter('A'), 'openSUSE:Factory:Staging:A')
|
2014-02-17 15:12:18 +01:00
|
|
|
|
2014-02-14 19:17:31 +01:00
|
|
|
@httpretty.activate
|
|
|
|
def test_check_project_status_green(self):
|
|
|
|
"""
|
|
|
|
Test checking project status
|
|
|
|
"""
|
2014-02-26 16:11:32 +01:00
|
|
|
# Register OBS
|
|
|
|
self.obs.register_obs()
|
2014-02-14 19:17:31 +01:00
|
|
|
|
|
|
|
# Check print output
|
2014-02-26 16:11:32 +01:00
|
|
|
self.assertEqual(self.obs.api.gather_build_status("green"), None)
|
2014-02-14 19:17:31 +01:00
|
|
|
|
|
|
|
@httpretty.activate
|
|
|
|
def test_check_project_status_red(self):
|
|
|
|
"""
|
|
|
|
Test checking project status
|
|
|
|
"""
|
|
|
|
|
2014-02-26 16:11:32 +01:00
|
|
|
# Register OBS
|
|
|
|
self.obs.register_obs()
|
2014-02-14 19:17:31 +01:00
|
|
|
|
|
|
|
# Check print output
|
2014-02-26 16:11:32 +01:00
|
|
|
self.assertEqual(self.obs.api.gather_build_status('red'),
|
|
|
|
['red', [{'path': 'standard/x86_64', 'state': 'building'}],
|
|
|
|
[{'path': 'standard/i586', 'pkg': 'glibc', 'state': 'broken'},
|
|
|
|
{'path': 'standard/i586', 'pkg': 'openSUSE-images', 'state': 'failed'}]])
|
2014-02-14 19:17:31 +01:00
|
|
|
|
2014-03-03 14:54:27 +01:00
|
|
|
@httpretty.activate
|
|
|
|
def test_check_project_status_red(self):
|
|
|
|
"""
|
|
|
|
Test checking project status
|
|
|
|
"""
|
|
|
|
|
|
|
|
# Register OBS
|
|
|
|
self.obs.register_obs()
|
|
|
|
|
|
|
|
# Testing frozen mtime
|
2014-03-04 10:55:55 +01:00
|
|
|
tmpl = Template(self.obs._get_fixture_content('project-a-metalist.xml'))
|
|
|
|
self.obs.responses['GET']['/source/openSUSE:Factory:Staging:A/_project'] = tmpl.substitute({'mtime': 1393152777 })
|
|
|
|
|
2014-03-03 14:54:27 +01:00
|
|
|
self.assertTrue(self.obs.api.days_since_last_freeze('openSUSE:Factory:Staging:A') > 8)
|
|
|
|
|
|
|
|
# U == unfrozen
|
|
|
|
self.obs.responses['GET']['/source/openSUSE:Factory:Staging:U/_project'] = 'project-u-metalist.xml'
|
|
|
|
self.assertTrue(self.obs.api.days_since_last_freeze('openSUSE:Factory:Staging:U') > 1000)
|
2014-03-04 10:55:55 +01:00
|
|
|
|
|
|
|
@httpretty.activate
|
|
|
|
def test_select(self):
|
|
|
|
"""
|
|
|
|
Test checking project status
|
|
|
|
"""
|
|
|
|
|
|
|
|
from osclib.select_command import SelectCommand
|
|
|
|
|
|
|
|
# Register OBS
|
|
|
|
self.obs.register_obs()
|
|
|
|
|
|
|
|
# old frozen
|
|
|
|
tmpl = Template(self.obs._get_fixture_content('project-a-metalist.xml'))
|
|
|
|
self.obs.responses['GET']['/source/openSUSE:Factory:Staging:A/_project'] = tmpl.substitute({'mtime': 1393152777})
|
|
|
|
self.assertEqual(False, SelectCommand(self.obs.api).perform('openSUSE:Factory:Staging:A', ['bash']))
|
|
|
|
|
|
|
|
# make sure the project is frozen recently for other tests
|
|
|
|
self.obs.responses['GET']['/source/openSUSE:Factory:Staging:A/_project'] = tmpl.substitute({'mtime': str(int(time.time()) - 1000) })
|
|
|
|
|
|
|
|
# search for requests
|
|
|
|
self.obs.responses['GET']['/request'] = '<collection matches="0"/>'
|
|
|
|
# TODO: it's actually 404 - but OBS class can't handle that ;(
|
|
|
|
self.obs.responses['GET']['/request/bash'] = '<collection matches="0"/>'
|
|
|
|
|
|
|
|
with self.assertRaises(oscerr.WrongArgs) as cm:
|
|
|
|
SelectCommand(self.obs.api).perform('openSUSE:Factory:Staging:A', ['bash'])
|
|
|
|
|
|
|
|
self.assertEqual(str(cm.exception), "No SR# found for: bash")
|