Added sample tests to FlavorManage API.
Partially implements blueprint nova-api-samples Fixes bug 1070163 Change-Id: Ib838adf0c21f3eee6c52cd8e1942c96ae89cca98
This commit is contained in:
13
doc/api_samples/os-flavor-manage/flavor-create-post-req.json
Normal file
13
doc/api_samples/os-flavor-manage/flavor-create-post-req.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"flavor": {
|
||||
"name": "test_flavor",
|
||||
"ram": 1024,
|
||||
"vcpus": 2,
|
||||
"disk": 10,
|
||||
"id": "10",
|
||||
"os-flavor-access:is_public": true,
|
||||
"rxtx_factor": 1,
|
||||
"OS-FLV-EXT-DATA:ephemeral": 0,
|
||||
"swap": 0
|
||||
}
|
||||
}
|
10
doc/api_samples/os-flavor-manage/flavor-create-post-req.xml
Normal file
10
doc/api_samples/os-flavor-manage/flavor-create-post-req.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flavor>
|
||||
<name>test_flavor</name>
|
||||
<ram>1024</ram>
|
||||
<vcpus>2</vcpus>
|
||||
<disk>10</disk>
|
||||
<id>10</id>
|
||||
<rxtx_factor>1</rxtx_factor>
|
||||
<swap>0</swap>
|
||||
</flavor>
|
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"flavor": {
|
||||
"disk": 10,
|
||||
"id": "10",
|
||||
"links": [
|
||||
{
|
||||
"href": "http://openstack.example.com/v2/openstack/flavors/10",
|
||||
"rel": "self"
|
||||
},
|
||||
{
|
||||
"href": "http://openstack.example.com/openstack/flavors/10",
|
||||
"rel": "bookmark"
|
||||
}
|
||||
],
|
||||
"name": "test_flavor",
|
||||
"ram": 1024,
|
||||
"vcpus": 2
|
||||
}
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<flavor xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" disk="10" vcpus="2" ram="1024" name="test_flavor" id="10">
|
||||
<atom:link href="http://openstack.example.com/v2/openstack/flavors/10" rel="self"/>
|
||||
<atom:link href="http://openstack.example.com/openstack/flavors/10" rel="bookmark"/>
|
||||
</flavor>
|
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"flavor": {
|
||||
"name": "%(flavor_name)s",
|
||||
"ram": 1024,
|
||||
"vcpus": 2,
|
||||
"disk": 10,
|
||||
"id": "%(flavor_id)s",
|
||||
"os-flavor-access:is_public": true,
|
||||
"rxtx_factor": 1,
|
||||
"OS-FLV-EXT-DATA:ephemeral": 0,
|
||||
"swap": 0
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flavor>
|
||||
<name>%(flavor_name)s</name>
|
||||
<ram>1024</ram>
|
||||
<vcpus>2</vcpus>
|
||||
<disk>10</disk>
|
||||
<id>%(flavor_id)s</id>
|
||||
<rxtx_factor>1</rxtx_factor>
|
||||
<swap>0</swap>
|
||||
</flavor>
|
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"flavor": {
|
||||
"disk": 10,
|
||||
"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": "%(flavor_name)s",
|
||||
"ram": 1024,
|
||||
"vcpus": 2
|
||||
}
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<flavor xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" disk="10" vcpus="2" ram="1024" name="%(flavor_name)s" id="%(flavor_id)s">
|
||||
<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>
|
@@ -1852,3 +1852,36 @@ class ExtendedStatusSampleJsonTests(ServersSampleBase):
|
||||
|
||||
class ExtendedStatusSampleXmlTests(ExtendedStatusSampleJsonTests):
|
||||
ctype = 'xml'
|
||||
|
||||
|
||||
class FlavorManageSampleJsonTests(ApiSampleTestBase):
|
||||
extension_name = ("nova.api.openstack.compute.contrib.flavormanage."
|
||||
"Flavormanage")
|
||||
|
||||
def _create_flavor(self):
|
||||
"""Create a flavor"""
|
||||
subs = {
|
||||
'flavor_id': 10,
|
||||
'flavor_name': "test_flavor"
|
||||
}
|
||||
response = self._do_post("flavors",
|
||||
"flavor-create-post-req",
|
||||
subs)
|
||||
self.assertEqual(response.status, 200)
|
||||
subs.update(self._get_regexes())
|
||||
return self._verify_response("flavor-create-post-resp", subs, response)
|
||||
|
||||
def test_create_flavor(self):
|
||||
"""Get api sample to create a flavor"""
|
||||
self._create_flavor()
|
||||
|
||||
def test_delete_flavor(self):
|
||||
"""Get api sample to delete a flavor"""
|
||||
self._create_flavor()
|
||||
response = self._do_delete("flavors/10")
|
||||
self.assertEqual(response.status, 202)
|
||||
self.assertEqual(response.read(), '')
|
||||
|
||||
|
||||
class FlavorManageSampleXmlTests(FlavorManageSampleJsonTests):
|
||||
ctype = "xml"
|
||||
|
Reference in New Issue
Block a user