Accept both 200 and 202 if no particular result is awaited
When deferred task is started successfully API can return either 200 or 202 depending on task status. So, we should not rely on particular value if caller did not set it (comparand) explcitly. Change-Id: I4c596cd0b591ef5985e2727fe204518d74a61332 Closes-Bug: #1558173
This commit is contained in:
parent
84465f603b
commit
3e4da833e5
|
@ -987,7 +987,7 @@ class EnvironmentManager(object):
|
|||
"Nothing to stop - try creating cluster"
|
||||
)
|
||||
|
||||
def reset_environment(self, expect_http=202, cluster_id=None):
|
||||
def reset_environment(self, expect_http=None, cluster_id=None):
|
||||
if self.clusters:
|
||||
cluster_id = self._get_cluster_by_id(cluster_id).id
|
||||
resp = self.app.put(
|
||||
|
@ -996,8 +996,13 @@ class EnvironmentManager(object):
|
|||
kwargs={'cluster_id': cluster_id}),
|
||||
expect_errors=True,
|
||||
headers=self.default_headers)
|
||||
self.tester.assertEqual(resp.status_code, expect_http)
|
||||
if not str(expect_http).startswith("2"):
|
||||
if expect_http is not None:
|
||||
self.tester.assertEqual(resp.status_code, expect_http)
|
||||
else:
|
||||
# if task was started status code can be either 200 or 202
|
||||
# depending on task status
|
||||
self.tester.assertIn(resp.status_code, [200, 202])
|
||||
if not (200 <= resp.status_code < 400):
|
||||
return resp.body
|
||||
return self.db.query(Task).filter_by(
|
||||
uuid=resp.json_body['uuid']
|
||||
|
|
Loading…
Reference in New Issue