Add Tests for GET/HEAD queue
This patch adds tests for the new API endpoint for GET/HEAD queue. Change-Id: Ife61b838ccc518f11e443a4daeddec650c956d6b Tests: blueprint queue-get-and-head
This commit is contained in:
parent
5cbfcefe29
commit
fcebbe042e
@ -34,6 +34,23 @@ def get(url, header=''):
|
||||
return response
|
||||
|
||||
|
||||
def head(url, header=''):
|
||||
"""Does http HEAD."""
|
||||
if header:
|
||||
header = json.loads(header)
|
||||
try:
|
||||
response = requests.head(url, headers=header)
|
||||
except requests.ConnectionError as detail:
|
||||
print('ConnectionError: Exception in http.head {}'.format(detail))
|
||||
except requests.HTTPError as detail:
|
||||
print('HTTPError: Exception in http.head {}'.format(detail))
|
||||
except requests.Timeout as detail:
|
||||
print('Timeout: Exception in http.head {}'.format(detail))
|
||||
except requests.TooManyRedirects as detail:
|
||||
print('TooManyRedirects: Exception in http.head {}'.format(detail))
|
||||
return response
|
||||
|
||||
|
||||
def post(url, header='', body=''):
|
||||
"""Does http POST."""
|
||||
if header:
|
||||
|
@ -339,6 +339,31 @@ class TestQueue(functionlib.TestUtils):
|
||||
|
||||
test_023_check_health.tags = ['positive']
|
||||
|
||||
def test_024_check_queue_exists(self):
|
||||
"""Checks if queue exists."""
|
||||
url = self.cfg.base_url + '/queues/qtestqueue'
|
||||
http.put(url, self.header)
|
||||
|
||||
result = http.get(url, self.header)
|
||||
self.assertEqual(result.status_code, 204)
|
||||
|
||||
result = http.head(url, self.header)
|
||||
self.assertEqual(result.status_code, 204)
|
||||
|
||||
test_024_check_queue_exists.tags = ['positive']
|
||||
|
||||
def test_025_check_queue_exists(self):
|
||||
"""Checks non-existing queue."""
|
||||
url = self.cfg.base_url + '/queues/nonexistingqueue'
|
||||
|
||||
result = http.get(url, self.header)
|
||||
self.assertEqual(result.status_code, 404)
|
||||
|
||||
result = http.head(url, self.header)
|
||||
self.assertEqual(result.status_code, 404)
|
||||
|
||||
test_025_check_queue_exists.tags = ['negative']
|
||||
|
||||
def test_999_delete_queue(self):
|
||||
"""Delete Queue.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user