Added sample tests to FlavorDisabled API.

Partially implements blueprint nova-api-samples
Fixes bug 1070161

Change-Id: I889a5b2e85d31fda1e9a8a82043ba7e9ddf1b7a6
This commit is contained in:
Giampaolo Lauria 2012-12-14 00:05:23 -05:00
parent 8749df7775
commit 58d5b2b0c1
9 changed files with 311 additions and 1 deletions

View File

@ -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
}
]
}

View File

@ -0,0 +1,23 @@
<?xml version='1.0' encoding='UTF-8'?>
<flavors xmlns:OS-FLV-DISABLED="http://docs.openstack.org/compute/ext/flavor_disabled/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1">
<flavor disk="0" vcpus="1" ram="512" name="m1.tiny" id="1" OS-FLV-DISABLED:disabled="False">
<atom:link href="http://openstack.example.com/v2/openstack/flavors/1" rel="self"/>
<atom:link href="http://openstack.example.com/openstack/flavors/1" rel="bookmark"/>
</flavor>
<flavor disk="20" vcpus="1" ram="2048" name="m1.small" id="2" OS-FLV-DISABLED:disabled="False">
<atom:link href="http://openstack.example.com/v2/openstack/flavors/2" rel="self"/>
<atom:link href="http://openstack.example.com/openstack/flavors/2" rel="bookmark"/>
</flavor>
<flavor disk="40" vcpus="2" ram="4096" name="m1.medium" id="3" OS-FLV-DISABLED:disabled="False">
<atom:link href="http://openstack.example.com/v2/openstack/flavors/3" rel="self"/>
<atom:link href="http://openstack.example.com/openstack/flavors/3" rel="bookmark"/>
</flavor>
<flavor disk="80" vcpus="4" ram="8192" name="m1.large" id="4" OS-FLV-DISABLED:disabled="False">
<atom:link href="http://openstack.example.com/v2/openstack/flavors/4" rel="self"/>
<atom:link href="http://openstack.example.com/openstack/flavors/4" rel="bookmark"/>
</flavor>
<flavor disk="160" vcpus="8" ram="16384" name="m1.xlarge" id="5" OS-FLV-DISABLED:disabled="False">
<atom:link href="http://openstack.example.com/v2/openstack/flavors/5" rel="self"/>
<atom:link href="http://openstack.example.com/openstack/flavors/5" rel="bookmark"/>
</flavor>
</flavors>

View File

@ -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
}
}

View File

@ -0,0 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
<flavor xmlns:OS-FLV-DISABLED="http://docs.openstack.org/compute/ext/flavor_disabled/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" disk="0" vcpus="1" ram="512" name="m1.tiny" id="1" OS-FLV-DISABLED:disabled="False">
<atom:link href="http://openstack.example.com/v2/openstack/flavors/1" rel="self"/>
<atom:link href="http://openstack.example.com/openstack/flavors/1" rel="bookmark"/>
</flavor>

View File

@ -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
}
]
}

View File

@ -0,0 +1,23 @@
<?xml version='1.0' encoding='UTF-8'?>
<flavors xmlns:OS-FLV-DISABLED="http://docs.openstack.org/compute/ext/flavor_disabled/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1">
<flavor disk="0" vcpus="1" ram="512" name="m1.tiny" id="1" OS-FLV-DISABLED:disabled="False">
<atom:link href="%(host)s/v2/openstack/flavors/1" rel="self"/>
<atom:link href="%(host)s/openstack/flavors/1" rel="bookmark"/>
</flavor>
<flavor disk="20" vcpus="1" ram="2048" name="m1.small" id="2" OS-FLV-DISABLED:disabled="False">
<atom:link href="%(host)s/v2/openstack/flavors/2" rel="self"/>
<atom:link href="%(host)s/openstack/flavors/2" rel="bookmark"/>
</flavor>
<flavor disk="40" vcpus="2" ram="4096" name="m1.medium" id="3" OS-FLV-DISABLED:disabled="False">
<atom:link href="%(host)s/v2/openstack/flavors/3" rel="self"/>
<atom:link href="%(host)s/openstack/flavors/3" rel="bookmark"/>
</flavor>
<flavor disk="80" vcpus="4" ram="8192" name="m1.large" id="4" OS-FLV-DISABLED:disabled="False">
<atom:link href="%(host)s/v2/openstack/flavors/4" rel="self"/>
<atom:link href="%(host)s/openstack/flavors/4" rel="bookmark"/>
</flavor>
<flavor disk="160" vcpus="8" ram="16384" name="m1.xlarge" id="5" OS-FLV-DISABLED:disabled="False">
<atom:link href="%(host)s/v2/openstack/flavors/5" rel="self"/>
<atom:link href="%(host)s/openstack/flavors/5" rel="bookmark"/>
</flavor>
</flavors>

View File

@ -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
}
}

View File

@ -0,0 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
<flavor xmlns:OS-FLV-DISABLED="http://docs.openstack.org/compute/ext/flavor_disabled/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" disk="0" vcpus="1" ram="512" name="m1.tiny" id="%(flavor_id)s" OS-FLV-DISABLED:disabled="False">
<atom:link href="%(host)s/v2/openstack/flavors/%(flavor_id)s" rel="self"/>
<atom:link href="%(host)s/openstack/flavors/%(flavor_id)s" rel="bookmark"/>
</flavor>

View File

@ -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"