From fcebbe042e2e52076b25348b520cbfc1cddf423e Mon Sep 17 00:00:00 2001 From: Malini Kamalambal Date: Fri, 9 Aug 2013 08:51:10 -0400 Subject: [PATCH] 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 --- marconi/tests/system/common/http.py | 17 ++++++++++++++++ marconi/tests/system/queue/test_queue.py | 25 ++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/marconi/tests/system/common/http.py b/marconi/tests/system/common/http.py index 020c23daf..21f9b143f 100755 --- a/marconi/tests/system/common/http.py +++ b/marconi/tests/system/common/http.py @@ -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: diff --git a/marconi/tests/system/queue/test_queue.py b/marconi/tests/system/queue/test_queue.py index a693ee8c5..9099aba35 100644 --- a/marconi/tests/system/queue/test_queue.py +++ b/marconi/tests/system/queue/test_queue.py @@ -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.