Merge "check some responses in functional tests before using the resp"

This commit is contained in:
Jenkins 2015-03-12 18:07:54 +00:00 committed by Gerrit Code Review
commit b6e5a21056
4 changed files with 18 additions and 2 deletions

View File

@ -36,7 +36,7 @@ class ConsumerBehaviors(base_behaviors.BaseBehaviors):
extra_headers=extra_headers)
returned_data = self.get_json(resp)
consumer_data = returned_data['consumers']
consumer_data = returned_data.get('consumers')
return resp, consumer_data

View File

@ -159,6 +159,7 @@ class OrdersTestCase(base.TestCase):
self.assertEqual(resp.status_code, 202)
order_resp = self.behaviors.get_order(order_ref)
self.assertEqual(order_resp.status_code, 200)
# PENDING orders may take a moment to be processed by the workers
# when running tests with queue enabled
@ -253,7 +254,6 @@ class OrdersTestCase(base.TestCase):
test_model.meta['payload_content_encoding'] = "blarg!"
resp, order_ref = self.behaviors.create_order(test_model)
print(resp.content)
# Make sure we actually get a message back
error_msg = json.loads(resp.content).get('title')

View File

@ -100,6 +100,7 @@ class SecretsTestCase(base.TestCase):
self.assertEqual(resp.status_code, 201)
resp = self.behaviors.get_secret_metadata(secret_ref)
self.assertEqual(resp.status_code, 200)
content_types = resp.model.content_types
self.assertIsNotNone(content_types)
self.assertIn('default', content_types)
@ -381,6 +382,7 @@ class SecretsTestCase(base.TestCase):
secret_ref,
payload_content_type=test_model.payload_content_type,
payload_content_encoding=test_model.payload_content_encoding)
self.assertEqual(get_resp.status_code, 200)
self.assertIn(test_model.payload,
binascii.b2a_base64(get_resp.content))
@ -591,6 +593,7 @@ class SecretsTestCase(base.TestCase):
secret_ref,
payload_content_type=test_model.payload_content_type,
payload_content_encoding=payload_content_encoding)
self.assertEqual(get_resp.status_code, 200)
if payload_content_encoding == 'base64':
self.assertIn(test_model.payload,
@ -630,6 +633,7 @@ class SecretsTestCase(base.TestCase):
secret_ref,
payload_content_type=test_model.payload_content_type,
payload_content_encoding=payload_content_encoding)
self.assertEqual(get_resp.status_code, 200)
if payload_content_encoding == 'base64':
self.assertIn(test_model.payload,

View File

@ -12,6 +12,8 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import time
from testtools import testcase
from barbican.tests import utils
@ -60,6 +62,14 @@ class OrdersTestCase(base.TestCase):
self.behaviors.delete_all_created_orders()
super(OrdersTestCase, self).tearDown()
def wait_for_order(self, order_resp, order_ref):
# Make sure we have an active order
time_count = 1
while order_resp.model.status != "ACTIVE" and time_count <= 4:
time.sleep(1)
time_count += 1
order_resp = self.behaviors.get_order(order_ref)
@testcase.attr('positive')
def test_create_order_defaults(self):
"""Covers simple order creation."""
@ -135,6 +145,8 @@ class OrdersTestCase(base.TestCase):
# create an order
test_model = order_models.OrderModel(**order_create_defaults_data)
create_resp, order_ref = self.behaviors.create_order(test_model)
self.assertEqual(create_resp.status_code, 202)
self.assertIsNotNone(order_ref)
# delete the order
delete_resp = self.behaviors.delete_order(order_ref)