From 58d5b2b0c1e684831f6ff11f7644c9e046e09e1f Mon Sep 17 00:00:00 2001 From: Giampaolo Lauria Date: Fri, 14 Dec 2012 00:05:23 -0500 Subject: [PATCH] Added sample tests to FlavorDisabled API. Partially implements blueprint nova-api-samples Fixes bug 1070161 Change-Id: I889a5b2e85d31fda1e9a8a82043ba7e9ddf1b7a6 --- .../flavor-detail-get-resp.json | 94 +++++++++++++++++++ .../flavor-detail-get-resp.xml | 23 +++++ .../OS-FLV-DISABLED/flavor-show-get-resp.json | 20 ++++ .../OS-FLV-DISABLED/flavor-show-get-resp.xml | 5 + .../flavor-detail-get-resp.json.tpl | 94 +++++++++++++++++++ .../flavor-detail-get-resp.xml.tpl | 23 +++++ .../flavor-show-get-resp.json.tpl | 20 ++++ .../flavor-show-get-resp.xml.tpl | 5 + nova/tests/integrated/test_api_samples.py | 28 +++++- 9 files changed, 311 insertions(+), 1 deletion(-) create mode 100644 doc/api_samples/OS-FLV-DISABLED/flavor-detail-get-resp.json create mode 100644 doc/api_samples/OS-FLV-DISABLED/flavor-detail-get-resp.xml create mode 100644 doc/api_samples/OS-FLV-DISABLED/flavor-show-get-resp.json create mode 100644 doc/api_samples/OS-FLV-DISABLED/flavor-show-get-resp.xml create mode 100644 nova/tests/integrated/api_samples/OS-FLV-DISABLED/flavor-detail-get-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/OS-FLV-DISABLED/flavor-detail-get-resp.xml.tpl create mode 100644 nova/tests/integrated/api_samples/OS-FLV-DISABLED/flavor-show-get-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/OS-FLV-DISABLED/flavor-show-get-resp.xml.tpl diff --git a/doc/api_samples/OS-FLV-DISABLED/flavor-detail-get-resp.json b/doc/api_samples/OS-FLV-DISABLED/flavor-detail-get-resp.json new file mode 100644 index 000000000000..42e0e21ce2f0 --- /dev/null +++ b/doc/api_samples/OS-FLV-DISABLED/flavor-detail-get-resp.json @@ -0,0 +1,94 @@ +{ + "flavors": [ + { + "OS-FLV-DISABLED:disabled": false, + "disk": 0, + "id": "1", + "links": [ + { + "href": "http://openstack.example.com/v2/openstack/flavors/1", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/flavors/1", + "rel": "bookmark" + } + ], + "name": "m1.tiny", + "ram": 512, + "vcpus": 1 + }, + { + "OS-FLV-DISABLED:disabled": false, + "disk": 20, + "id": "2", + "links": [ + { + "href": "http://openstack.example.com/v2/openstack/flavors/2", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/flavors/2", + "rel": "bookmark" + } + ], + "name": "m1.small", + "ram": 2048, + "vcpus": 1 + }, + { + "OS-FLV-DISABLED:disabled": false, + "disk": 40, + "id": "3", + "links": [ + { + "href": "http://openstack.example.com/v2/openstack/flavors/3", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/flavors/3", + "rel": "bookmark" + } + ], + "name": "m1.medium", + "ram": 4096, + "vcpus": 2 + }, + { + "OS-FLV-DISABLED:disabled": false, + "disk": 80, + "id": "4", + "links": [ + { + "href": "http://openstack.example.com/v2/openstack/flavors/4", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/flavors/4", + "rel": "bookmark" + } + ], + "name": "m1.large", + "ram": 8192, + "vcpus": 4 + }, + { + "OS-FLV-DISABLED:disabled": false, + "disk": 160, + "id": "5", + "links": [ + { + "href": "http://openstack.example.com/v2/openstack/flavors/5", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/flavors/5", + "rel": "bookmark" + } + ], + "name": "m1.xlarge", + "ram": 16384, + "vcpus": 8 + } + ] +} \ No newline at end of file diff --git a/doc/api_samples/OS-FLV-DISABLED/flavor-detail-get-resp.xml b/doc/api_samples/OS-FLV-DISABLED/flavor-detail-get-resp.xml new file mode 100644 index 000000000000..92b51a86644e --- /dev/null +++ b/doc/api_samples/OS-FLV-DISABLED/flavor-detail-get-resp.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/doc/api_samples/OS-FLV-DISABLED/flavor-show-get-resp.json b/doc/api_samples/OS-FLV-DISABLED/flavor-show-get-resp.json new file mode 100644 index 000000000000..3fd5fa1d7cd1 --- /dev/null +++ b/doc/api_samples/OS-FLV-DISABLED/flavor-show-get-resp.json @@ -0,0 +1,20 @@ +{ + "flavor": { + "OS-FLV-DISABLED:disabled": false, + "disk": 0, + "id": "1", + "links": [ + { + "href": "http://openstack.example.com/v2/openstack/flavors/1", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/flavors/1", + "rel": "bookmark" + } + ], + "name": "m1.tiny", + "ram": 512, + "vcpus": 1 + } +} \ No newline at end of file diff --git a/doc/api_samples/OS-FLV-DISABLED/flavor-show-get-resp.xml b/doc/api_samples/OS-FLV-DISABLED/flavor-show-get-resp.xml new file mode 100644 index 000000000000..6abd2264152f --- /dev/null +++ b/doc/api_samples/OS-FLV-DISABLED/flavor-show-get-resp.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/nova/tests/integrated/api_samples/OS-FLV-DISABLED/flavor-detail-get-resp.json.tpl b/nova/tests/integrated/api_samples/OS-FLV-DISABLED/flavor-detail-get-resp.json.tpl new file mode 100644 index 000000000000..d1f78c08e2c0 --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-FLV-DISABLED/flavor-detail-get-resp.json.tpl @@ -0,0 +1,94 @@ +{ + "flavors": [ + { + "OS-FLV-DISABLED:disabled": false, + "disk": 0, + "id": "1", + "links": [ + { + "href": "%(host)s/v2/openstack/flavors/1", + "rel": "self" + }, + { + "href": "%(host)s/openstack/flavors/1", + "rel": "bookmark" + } + ], + "name": "m1.tiny", + "ram": 512, + "vcpus": 1 + }, + { + "OS-FLV-DISABLED:disabled": false, + "disk": 20, + "id": "2", + "links": [ + { + "href": "%(host)s/v2/openstack/flavors/2", + "rel": "self" + }, + { + "href": "%(host)s/openstack/flavors/2", + "rel": "bookmark" + } + ], + "name": "m1.small", + "ram": 2048, + "vcpus": 1 + }, + { + "OS-FLV-DISABLED:disabled": false, + "disk": 40, + "id": "3", + "links": [ + { + "href": "%(host)s/v2/openstack/flavors/3", + "rel": "self" + }, + { + "href": "%(host)s/openstack/flavors/3", + "rel": "bookmark" + } + ], + "name": "m1.medium", + "ram": 4096, + "vcpus": 2 + }, + { + "OS-FLV-DISABLED:disabled": false, + "disk": 80, + "id": "4", + "links": [ + { + "href": "%(host)s/v2/openstack/flavors/4", + "rel": "self" + }, + { + "href": "%(host)s/openstack/flavors/4", + "rel": "bookmark" + } + ], + "name": "m1.large", + "ram": 8192, + "vcpus": 4 + }, + { + "OS-FLV-DISABLED:disabled": false, + "disk": 160, + "id": "5", + "links": [ + { + "href": "%(host)s/v2/openstack/flavors/5", + "rel": "self" + }, + { + "href": "%(host)s/openstack/flavors/5", + "rel": "bookmark" + } + ], + "name": "m1.xlarge", + "ram": 16384, + "vcpus": 8 + } + ] +} diff --git a/nova/tests/integrated/api_samples/OS-FLV-DISABLED/flavor-detail-get-resp.xml.tpl b/nova/tests/integrated/api_samples/OS-FLV-DISABLED/flavor-detail-get-resp.xml.tpl new file mode 100644 index 000000000000..8d992e42d120 --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-FLV-DISABLED/flavor-detail-get-resp.xml.tpl @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nova/tests/integrated/api_samples/OS-FLV-DISABLED/flavor-show-get-resp.json.tpl b/nova/tests/integrated/api_samples/OS-FLV-DISABLED/flavor-show-get-resp.json.tpl new file mode 100644 index 000000000000..cf5fb232afcc --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-FLV-DISABLED/flavor-show-get-resp.json.tpl @@ -0,0 +1,20 @@ +{ + "flavor": { + "OS-FLV-DISABLED:disabled": false, + "disk": 0, + "id": "%(flavor_id)s", + "links": [ + { + "href": "%(host)s/v2/openstack/flavors/%(flavor_id)s", + "rel": "self" + }, + { + "href": "%(host)s/openstack/flavors/%(flavor_id)s", + "rel": "bookmark" + } + ], + "name": "m1.tiny", + "ram": 512, + "vcpus": 1 + } +} diff --git a/nova/tests/integrated/api_samples/OS-FLV-DISABLED/flavor-show-get-resp.xml.tpl b/nova/tests/integrated/api_samples/OS-FLV-DISABLED/flavor-show-get-resp.xml.tpl new file mode 100644 index 000000000000..c7bdd1ca885c --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-FLV-DISABLED/flavor-show-get-resp.xml.tpl @@ -0,0 +1,5 @@ + + + + + diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py index 49ff77306032..256946d10fc2 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -348,7 +348,6 @@ class ApiSamplesTrap(ApiSampleTestBase): # removed) soon. do_not_approve_additions = [] do_not_approve_additions.append('NMN') - do_not_approve_additions.append('OS-FLV-DISABLED') do_not_approve_additions.append('os-config-drive') do_not_approve_additions.append('os-coverage') do_not_approve_additions.append('os-create-server-ext') @@ -2102,3 +2101,30 @@ class NetworksAssociateJsonTests(ApiSampleTestBase): class NetworksAssociateXmlTests(NetworksAssociateJsonTests): ctype = 'xml' + + +class FlavorDisabledSampleJsonTests(ApiSampleTestBase): + extension_name = ("nova.api.openstack.compute.contrib.flavor_disabled." + "Flavor_disabled") + + def test_show_flavor(self): + """Get api sample to show flavor_disabled attr. of a flavor""" + flavor_id = 1 + response = self._do_get('flavors/%s' % flavor_id) + self.assertEqual(response.status, 200) + subs = self._get_regexes() + subs['flavor_id'] = flavor_id + return self._verify_response('flavor-show-get-resp', subs, + response) + + def test_detail_flavor(self): + """Get api sample to show details of a flavor""" + response = self._do_get('flavors/detail') + self.assertEqual(response.status, 200) + subs = self._get_regexes() + return self._verify_response('flavor-detail-get-resp', subs, + response) + + +class FlavorDisabledSampleXmlTests(FlavorDisabledSampleJsonTests): + ctype = "xml"