Migrate build results tests

This commit is contained in:
Michal Hrusecky 2014-02-26 16:11:32 +01:00 committed by Michal Hrusecky
parent ad65155a02
commit 6f3dae1fb6
2 changed files with 22 additions and 19 deletions

View File

@ -285,23 +285,24 @@ class TestApiCalls(unittest.TestCase):
self.assertEqual(httpretty.last_request().method, 'POST')
self.assertEqual(httpretty.last_request().querystring[u'cmd'], [u'addreview'])
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')
@httpretty.activate
def test_check_project_status_green(self):
"""
Test checking project status
"""
# Initiate the pretty overrides
self._register_pretty_url_get('https://localhost/build/green/_result',
'build-results-green.xml')
# Initiate the api with mocked rings
with mock_generate_ring_packages():
api = oscs.StagingAPI('https://localhost')
# Register OBS
self.obs.register_obs()
# Check print output
self.assertEqual(api.gather_build_status("green"), None)
self.assertEqual(self.obs.api.gather_build_status("green"), None)
@httpretty.activate
def test_check_project_status_red(self):
@ -309,18 +310,14 @@ class TestApiCalls(unittest.TestCase):
Test checking project status
"""
# Initiate the pretty overrides
self._register_pretty_url_get('https://localhost/build/red/_result',
'build-results-red.xml')
# Initiate the api with mocked rings
with mock_generate_ring_packages():
api = oscs.StagingAPI('https://localhost')
# Register OBS
self.obs.register_obs()
# Check print output
self.assertEqual(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'}]])
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'}]])
def test_bootstrap_copy(self):
import osclib.freeze_command

View File

@ -119,6 +119,8 @@ class OBS:
self._link_sources()
# Add packages
self._pkg_sources()
# Add fake build results
self._build_results()
def _pretty_callback(self, request, uri, headers, exception=True):
"""
@ -168,6 +170,10 @@ class OBS:
else:
return None
def _build_results(self):
self.responses['GET']['/build/red/_result'] = 'build-results-red.xml'
self.responses['GET']['/build/green/_result'] = 'build-results-green.xml'
def _project_meta(self):
# Load template
tmpl = Template(self._get_fixture_content('staging-project-meta.xml'))