py34: heat.tests.api.*
The recursive sort utility function in the repository won't work for python 3 because it can't sort dictionaries inside lists. Python 2 could but python 3 forbids that. It does not seem possible to have a simple one size fits all sorted function to recursively sort lists of dictionaries, hence just workaround by manually sorting by key or value. partial blueprint heat-python34-support Change-Id: I2e46bfacf5a8ebdaf0ca50901b7f0262d23833cb
This commit is contained in:
parent
0e2f02c129
commit
413b71dc9d
@ -74,12 +74,12 @@ class WatchControllerTest(common.HeatTestCase):
|
||||
dims = [{'StackId': u'21617058-781e-4262-97ab-5f9df371ee52',
|
||||
'Foo': 'bar'}]
|
||||
self.assertEqual(
|
||||
utils.recursive_sort(
|
||||
[{'Name': 'StackId',
|
||||
'Value': u'21617058-781e-4262-97ab-5f9df371ee52'},
|
||||
{'Name': 'Foo',
|
||||
'Value': 'bar'}]),
|
||||
utils.recursive_sort(self.controller._reformat_dimensions(dims)))
|
||||
[{'Name': 'Foo',
|
||||
'Value': 'bar'},
|
||||
{'Name': 'StackId',
|
||||
'Value': u'21617058-781e-4262-97ab-5f9df371ee52'}],
|
||||
sorted((self.controller._reformat_dimensions(dims)),
|
||||
key=lambda k: k['Name']))
|
||||
|
||||
def test_enforce_default(self):
|
||||
self.m.ReplayAll()
|
||||
@ -302,10 +302,20 @@ class WatchControllerTest(common.HeatTestCase):
|
||||
'Value': 1}],
|
||||
'MetricName': u'ServiceFailure3'}]}}}
|
||||
|
||||
response = self.controller.list_metrics(dummy_req)
|
||||
metrics = (response['ListMetricsResponse']['ListMetricsResult']
|
||||
['Metrics'])
|
||||
metrics[0]['Dimensions'] = sorted(
|
||||
metrics[0]['Dimensions'], key=lambda k: k['Name'])
|
||||
metrics[1]['Dimensions'] = sorted(
|
||||
metrics[1]['Dimensions'], key=lambda k: k['Name'])
|
||||
metrics[2]['Dimensions'] = sorted(
|
||||
metrics[2]['Dimensions'], key=lambda k: k['Name'])
|
||||
metrics = sorted(metrics, key=lambda k: k['MetricName'])
|
||||
response['ListMetricsResponse']['ListMetricsResult'] = (
|
||||
{'Metrics': metrics})
|
||||
# First pass no query paramters filtering, should get all three
|
||||
self.assertEqual(
|
||||
utils.recursive_sort(expected),
|
||||
utils.recursive_sort(self.controller.list_metrics(dummy_req)))
|
||||
self.assertEqual(expected, response)
|
||||
|
||||
def test_list_metrics_filter_name(self):
|
||||
|
||||
@ -361,10 +371,15 @@ class WatchControllerTest(common.HeatTestCase):
|
||||
{'Name': u'Value',
|
||||
'Value': 1}],
|
||||
'MetricName': u'ServiceFailure'}]}}}
|
||||
response = self.controller.list_metrics(dummy_req)
|
||||
metrics = (response['ListMetricsResponse']['ListMetricsResult']
|
||||
['Metrics'])
|
||||
metrics[0]['Dimensions'] = sorted(
|
||||
metrics[0]['Dimensions'], key=lambda k: k['Name'])
|
||||
response['ListMetricsResponse']['ListMetricsResult'] = (
|
||||
{'Metrics': metrics})
|
||||
# First pass no query paramters filtering, should get all three
|
||||
self.assertEqual(
|
||||
utils.recursive_sort(expected),
|
||||
utils.recursive_sort(self.controller.list_metrics(dummy_req)))
|
||||
self.assertEqual(expected, response)
|
||||
|
||||
def test_list_metrics_filter_namespace(self):
|
||||
|
||||
@ -432,9 +447,17 @@ class WatchControllerTest(common.HeatTestCase):
|
||||
{'Name': u'Value',
|
||||
'Value': 1}],
|
||||
'MetricName': u'ServiceFailure2'}]}}}
|
||||
self.assertEqual(
|
||||
utils.recursive_sort(expected),
|
||||
utils.recursive_sort(self.controller.list_metrics(dummy_req)))
|
||||
response = self.controller.list_metrics(dummy_req)
|
||||
metrics = (response['ListMetricsResponse']['ListMetricsResult']
|
||||
['Metrics'])
|
||||
metrics[0]['Dimensions'] = sorted(
|
||||
metrics[0]['Dimensions'], key=lambda k: k['Name'])
|
||||
metrics[1]['Dimensions'] = sorted(
|
||||
metrics[1]['Dimensions'], key=lambda k: k['Name'])
|
||||
response['ListMetricsResponse']['ListMetricsResult'] = (
|
||||
{'Metrics': metrics})
|
||||
# First pass no query paramters filtering, should get all three
|
||||
self.assertEqual(expected, response)
|
||||
|
||||
def test_put_metric_alarm(self):
|
||||
# Not yet implemented, should raise HeatAPINotImplementedError
|
||||
|
@ -1,8 +1,10 @@
|
||||
rackspace.tests
|
||||
heat_docker.tests
|
||||
heat.tests.api
|
||||
heat.tests.api.aws.test_api_aws
|
||||
heat.tests.api.aws.test_api_ec2token
|
||||
heat.tests.api.cfn.test_api_v1
|
||||
heat.tests.api.cloudwatch.test_api_cloudwatch
|
||||
heat.tests.api.middleware.test_ssl_middleware
|
||||
heat.tests.api.middleware.test_version_negotiation_middleware
|
||||
heat.tests.api.openstack_v1.test_stacks_view
|
||||
|
Loading…
Reference in New Issue
Block a user