py34: Fix integration tests

* Use bytes when retreiving contents of a file
* Header location should not be encoded because webob
  does a string operation over it.
* convert stack identifier manually to dict until
  review 227977 is merged.

Change-Id: I442236778114d205d10cddd82d5b58b3954a45f6
This commit is contained in:
Sirushti Murugesan 2015-09-26 19:36:57 +05:30
parent 2df093b75e
commit a5845985b5
6 changed files with 18 additions and 16 deletions

View File

@ -650,7 +650,7 @@ class StackSerializer(serializers.JSONResponseSerializer):
def _populate_response_header(self, response, location, status):
response.status = status
response.headers['Location'] = location.encode('utf-8')
response.headers['Location'] = location
response.headers['Content-Type'] = 'application/json'
return response

View File

@ -66,7 +66,7 @@ def get(url, allowed_schemes=('http', 'https')):
# (eg. it's possible to fetch 1000 bytes greater than
# max_template_size with a chunk_size of 1000).
reader = resp.iter_content(chunk_size=1000)
result = ""
result = b""
for chunk in reader:
result += chunk
if len(result) > cfg.CONF.max_template_size:

View File

@ -115,7 +115,7 @@ class StackResource(resource.Resource):
self.resource_id)
self.rpc_client().stack_cancel_update(
self.context,
stack_identity,
dict(stack_identity),
cancel_with_rollback=False)
def has_nested(self):
@ -427,7 +427,7 @@ class StackResource(resource.Resource):
try:
self.rpc_client().update_stack(
self.context,
nested_stack.identifier(),
dict(nested_stack.identifier()),
parsed_template.t,
child_env.user_env_as_dict(),
parsed_template.files,
@ -449,7 +449,7 @@ class StackResource(resource.Resource):
if stack is None:
return
stack_identity = stack.identifier()
stack_identity = dict(stack.identifier())
try:
self.rpc_client().delete_stack(self.context, stack_identity)
@ -472,7 +472,7 @@ class StackResource(resource.Resource):
self.context.tenant_id,
self.physical_resource_name(),
self.resource_id)
self.rpc_client().stack_suspend(self.context, stack_identity)
self.rpc_client().stack_suspend(self.context, dict(stack_identity))
def check_suspend_complete(self, cookie=None):
return self._check_status_complete(resource.Resource.SUSPEND)
@ -486,7 +486,7 @@ class StackResource(resource.Resource):
self.context.tenant_id,
self.physical_resource_name(),
self.resource_id)
self.rpc_client().stack_resume(self.context, stack_identity)
self.rpc_client().stack_resume(self.context, dict(stack_identity))
def check_resume_complete(self, cookie=None):
return self._check_status_complete(resource.Resource.RESUME)
@ -501,7 +501,7 @@ class StackResource(resource.Resource):
self.context.tenant_id,
self.physical_resource_name(),
self.resource_id)
self.rpc_client().stack_check(self.context, stack_identity)
self.rpc_client().stack_check(self.context, dict(stack_identity))
def check_check_complete(self, cookie=None):
return self._check_status_complete(resource.Resource.CHECK)

View File

@ -2361,5 +2361,5 @@ class StackSerializerTest(common.HeatTestCase):
response = webob.Response()
response = self.serializer.create(response, result)
self.assertEqual(201, response.status_int)
self.assertEqual(b'location', response.headers['Location'])
self.assertEqual('location', response.headers['Location'])
self.assertEqual('application/json', response.headers['Content-Type'])

View File

@ -839,7 +839,8 @@ class WithTemplateTest(StackResourceBaseTest):
nested = mock.MagicMock()
nested.updated_time = 'now_time'
nested.state = ('CREATE', 'COMPLETE')
nested.identifier.return_value = 'stack_identifier'
nested.identifier.return_value = {'stack_identifier':
'stack-identifier'}
self.parent_resource.nested = mock.MagicMock(return_value=nested)
self.parent_resource._nested = nested
@ -856,8 +857,9 @@ class WithTemplateTest(StackResourceBaseTest):
self.empty_temp, user_params=self.params,
timeout_mins=self.timeout_mins)
rpcc.return_value.update_stack.assert_called_once_with(
self.ctx, 'stack_identifier', self.empty_temp.t,
child_env, {}, {'timeout_mins': self.timeout_mins})
self.ctx, {'stack_identifier': 'stack-identifier'},
self.empty_temp.t, child_env, {},
{'timeout_mins': self.timeout_mins})
class RaiseLocalException(StackResourceBaseTest):

View File

@ -70,7 +70,7 @@ class UrlFetchTest(common.HeatTestCase):
def test_http_scheme(self):
url = 'http://example.com/template'
data = '{ "foo": "bar" }'
data = b'{ "foo": "bar" }'
response = Response(data)
requests.get(url, stream=True).AndReturn(response)
self.m.ReplayAll()
@ -79,7 +79,7 @@ class UrlFetchTest(common.HeatTestCase):
def test_https_scheme(self):
url = 'https://example.com/template'
data = '{ "foo": "bar" }'
data = b'{ "foo": "bar" }'
response = Response(data)
requests.get(url, stream=True).AndReturn(response)
self.m.ReplayAll()
@ -111,7 +111,7 @@ class UrlFetchTest(common.HeatTestCase):
def test_max_fetch_size_okay(self):
url = 'http://example.com/template'
data = '{ "foo": "bar" }'
data = b'{ "foo": "bar" }'
response = Response(data)
cfg.CONF.set_override('max_template_size', 500)
requests.get(url, stream=True).AndReturn(response)
@ -121,7 +121,7 @@ class UrlFetchTest(common.HeatTestCase):
def test_max_fetch_size_error(self):
url = 'http://example.com/template'
data = '{ "foo": "bar" }'
data = b'{ "foo": "bar" }'
response = Response(data)
cfg.CONF.set_override('max_template_size', 5)
requests.get(url, stream=True).AndReturn(response)