Merge pull request #86 from miska/master
Implement a way to use custom statuses
This commit is contained in:
commit
06b97f4324
12
tests/obs.py
12
tests/obs.py
@ -145,6 +145,12 @@ class OBS:
|
|||||||
reply = self.responses[request.method][path]
|
reply = self.responses[request.method][path]
|
||||||
# We have something to reply with
|
# We have something to reply with
|
||||||
if reply:
|
if reply:
|
||||||
|
# It's a dict, therefore there is return code as well
|
||||||
|
if isinstance(reply, dict):
|
||||||
|
ret_code = reply['status']
|
||||||
|
reply = reply['reply']
|
||||||
|
else:
|
||||||
|
ret_code = 200
|
||||||
# It's a list, so take the first
|
# It's a list, so take the first
|
||||||
if isinstance(reply, list):
|
if isinstance(reply, list):
|
||||||
reply = reply.pop(0)
|
reply = reply.pop(0)
|
||||||
@ -152,13 +158,13 @@ class OBS:
|
|||||||
if isinstance(reply, string_types):
|
if isinstance(reply, string_types):
|
||||||
# It's XML
|
# It's XML
|
||||||
if reply.startswith('<'):
|
if reply.startswith('<'):
|
||||||
return (200, headers, reply)
|
return (ret_code, headers, reply)
|
||||||
# It's fixture
|
# It's fixture
|
||||||
else:
|
else:
|
||||||
return (200, headers, self._get_fixture_content(reply))
|
return (ret_code, headers, self._get_fixture_content(reply))
|
||||||
# All is left is callback function
|
# All is left is callback function
|
||||||
else:
|
else:
|
||||||
return (200, headers, reply(self.responses, request, uri))
|
return (ret_code, headers, reply(self.responses, request, uri))
|
||||||
# No possible response found
|
# No possible response found
|
||||||
else:
|
else:
|
||||||
if len(path) == 0:
|
if len(path) == 0:
|
||||||
|
@ -55,8 +55,7 @@ class TestSelect(unittest.TestCase):
|
|||||||
|
|
||||||
# search for requests
|
# search for requests
|
||||||
self.obs.responses['GET']['/request'] = '<collection matches="0"/>'
|
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'] = {'status': 404, 'reply': '<collection matches="0"/>' }
|
||||||
self.obs.responses['GET']['/request/bash'] = '<collection matches="0"/>'
|
|
||||||
|
|
||||||
with self.assertRaises(oscerr.WrongArgs) as cm:
|
with self.assertRaises(oscerr.WrongArgs) as cm:
|
||||||
SelectCommand(self.obs.api).perform('openSUSE:Factory:Staging:A', ['bash'])
|
SelectCommand(self.obs.api).perform('openSUSE:Factory:Staging:A', ['bash'])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user