Merge pull request #24 from miska/master

Not crashing on valid but incorrect YAML
This commit is contained in:
Stephan Kulow 2014-02-13 11:31:14 +01:00
commit 2ed75ae4cd
4 changed files with 35 additions and 2 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
*~
*.pyc
*.html
.*.swp

View File

@ -207,6 +207,7 @@ class StagingApi(object):
# * removed linked packages
try:
data = yaml.load(description.text)
data['requests']
except:
data = yaml.load('requests: []')
return data

View File

@ -125,18 +125,23 @@ class TestApiCalls(unittest.TestCase):
rq = { 'id': '123', 'package': 'test-package' }
# Initiate the pretty overrides
self._register_pretty_url_get('http://localhost/source/openSUSE:Factory:Staging:test/_meta',
self._register_pretty_url_get('http://localhost/source/openSUSE:Factory:Staging:test1/_meta',
'staging-project-meta.xml')
self._register_pretty_url_get('http://localhost/source/openSUSE:Factory:Staging:test2/_meta',
'staging-project-broken-meta.xml')
# Initiate the api with mocked rings
with mock_generate_ring_packages():
api = oscs.StagingApi('http://localhost')
# Ensure the output is equal to what we expect
data = api.get_prj_pseudometa('openSUSE:Factory:Staging:test')
data = api.get_prj_pseudometa('openSUSE:Factory:Staging:test1')
for i in rq.keys():
self.assertEqual(rq[i],data['requests'][0][i])
data = api.get_prj_pseudometa('openSUSE:Factory:Staging:test2')
self.assertEqual(len(data['requests']),0)
@httpretty.activate
def test_list_projects(self):
"""

View File

@ -0,0 +1,26 @@
<project name="openSUSE:Factory:Staging:test">
<title>Staging project "openSUSE:Factory:Staging:test"</title>
<description>
</description>
<link project="openSUSE:Factory"/>
<person userid="Admin" role="maintainer"/>
<build>
<enable/>
</build>
<publish>
<disable/>
</publish>
<debuginfo>
<enable/>
</debuginfo>
<repository name="standard" rebuild="direct" linkedbuild="all">
<path project="openSUSE:Factory:Build" repository="standard"/>
<arch>i586</arch>
<arch>x86_64</arch>
</repository>
<repository name="images" rebuild="direct" linkedbuild="all">
<path project="openSUSE:Factory" repository="standard"/>
<arch>x86_64</arch>
<arch>i586</arch>
</repository>
</project>