summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/tests/integrated/api_samples/all_extensions/server-action-rebuild-resp.xml.tpl8
-rw-r--r--nova/tests/integrated/api_samples/server-action-rebuild-resp.xml.tpl10
-rw-r--r--nova/tests/integrated/test_api_samples.py30
3 files changed, 18 insertions, 30 deletions
diff --git a/nova/tests/integrated/api_samples/all_extensions/server-action-rebuild-resp.xml.tpl b/nova/tests/integrated/api_samples/all_extensions/server-action-rebuild-resp.xml.tpl
index 105e19fdd..0ede362be 100644
--- a/nova/tests/integrated/api_samples/all_extensions/server-action-rebuild-resp.xml.tpl
+++ b/nova/tests/integrated/api_samples/all_extensions/server-action-rebuild-resp.xml.tpl
@@ -8,7 +8,7 @@
hostId="%(hostid)s" progress="0"
status="ACTIVE" adminPass="%(password)s"
created="%(timestamp)s"
- updated="%(timestamp)s"
+ updated="%(timestamp)s"
accessIPv4="%(ip)s"
accessIPv6="%(ip6)s"
OS-DCF:diskConfig="AUTO">
@@ -16,17 +16,11 @@
<atom:link
rel="bookmark"
href="%(host)s/openstack/images/%(uuid)s"/>
- <atom:link
- rel="self"
- href="%(host)s/openstack/images/%(uuid)s"/>
</image>
<flavor id="1">
<atom:link
rel="bookmark"
href="%(host)s/openstack/flavors/1"/>
- <atom:link
- rel="self"
- href="%(host)s/openstack/flavors/1"/>
</flavor>
<metadata>
<meta key="My Server Name">Apache1</meta>
diff --git a/nova/tests/integrated/api_samples/server-action-rebuild-resp.xml.tpl b/nova/tests/integrated/api_samples/server-action-rebuild-resp.xml.tpl
index 996c9ccbf..d9e80f8c4 100644
--- a/nova/tests/integrated/api_samples/server-action-rebuild-resp.xml.tpl
+++ b/nova/tests/integrated/api_samples/server-action-rebuild-resp.xml.tpl
@@ -1,30 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<server xmlns="http://docs.openstack.org/compute/api/v1.1"
xmlns:atom="http://www.w3.org/2005/Atom"
- id="%(uuid)s"
+ id="%(uuid)s"
tenantId="openstack" userId="fake"
name="%(name)s"
hostId="%(hostid)s" progress="0"
status="ACTIVE" adminPass="%(password)s"
created="%(timestamp)s"
- updated="%(timestamp)s"
+ updated="%(timestamp)s"
accessIPv4="%(ip)s"
accessIPv6="%(ip6)s">
<image id="%(uuid)s">
<atom:link
rel="bookmark"
href="%(host)s/openstack/images/%(uuid)s"/>
- <atom:link
- rel="self"
- href="%(host)s/openstack/images/%(uuid)s"/>
</image>
<flavor id="1">
<atom:link
rel="bookmark"
href="%(host)s/openstack/flavors/1"/>
- <atom:link
- rel="self"
- href="%(host)s/openstack/flavors/1"/>
</flavor>
<metadata>
<meta key="My Server Name">Apache1</meta>
diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py
index 1599bd9b8..a4c7f8493 100644
--- a/nova/tests/integrated/test_api_samples.py
+++ b/nova/tests/integrated/test_api_samples.py
@@ -142,21 +142,21 @@ class ApiSampleTestBase(integrated_helpers._IntegratedTestBase):
if not isinstance(result, list):
raise NoMatch(
_('Result: %(result)s is not a list.') % locals())
- # NOTE(maurosr): sort the list of dicts by their __tag__ element
- # when using xml. This will avoid some fails in keypairs api sample
- # which order in different way when using a private key itself or
- # its regular expression, and after all doesn't interfere with
- # other tests.
- # Besides that, there are some cases like Aggregates extension
- # where we got a list of strings. For those cases key will be None
- # (python's default) and the elements will be compared directly.
- # Should we define a criteria when ordering json? Doesn't seems
- # necessary so far.
- key = (lambda k: k.get('__tag__', k) if isinstance(k, dict)
- else None)
- for ex_obj, res_obj in zip(sorted(expected, key=key),
- sorted(result, key=key)):
- res = self._compare_result(subs, ex_obj, res_obj)
+ if len(expected) != len(result):
+ raise NoMatch(
+ _('Length mismatch: %(result)s\n%(expected)s.')
+ % locals())
+ for res_obj in result:
+ for ex_obj in expected:
+ try:
+ res = self._compare_result(subs, ex_obj, res_obj)
+ break
+ except NoMatch:
+ pass
+ else:
+ raise NoMatch(
+ _('Result: %(res_obj)s not in %(expected)s.')
+ % locals())
matched_value = res or matched_value
elif isinstance(expected, basestring) and '%' in expected: