summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiampaolo Lauria <lauria@us.ibm.com>2013-02-19 14:46:30 -0500
committerGiampaolo Lauria <lauria@us.ibm.com>2013-02-25 11:33:47 -0500
commitd10a2e13e1ad77720d1433eafa9e04a017fcaeb3 (patch)
tree124330649d230013f240ef975aad279dcbfe806d
parent6053ca12d76d18ffc50d5941c2e379f4df2c70e2 (diff)
downloadnova-d10a2e13e1ad77720d1433eafa9e04a017fcaeb3.tar.gz
nova-d10a2e13e1ad77720d1433eafa9e04a017fcaeb3.tar.xz
nova-d10a2e13e1ad77720d1433eafa9e04a017fcaeb3.zip
Add API Sample tests for Snapshots extension.
Partially implements blueprint nova-api-samples Modifies fakes to produce a real timestamp Fixes bug 1126211 Change-Id: I8973d50fa67abbf6f96684ff8a0b898912f09caf
-rw-r--r--doc/api_samples/os-volumes/snapshot-create-req.json8
-rw-r--r--doc/api_samples/os-volumes/snapshot-create-req.xml7
-rw-r--r--doc/api_samples/os-volumes/snapshot-create-resp.json32
-rw-r--r--doc/api_samples/os-volumes/snapshot-create-resp.xml2
-rw-r--r--doc/api_samples/os-volumes/snapshots-detail-resp.json31
-rw-r--r--doc/api_samples/os-volumes/snapshots-detail-resp.xml6
-rw-r--r--doc/api_samples/os-volumes/snapshots-list-resp.json31
-rw-r--r--doc/api_samples/os-volumes/snapshots-list-resp.xml6
-rw-r--r--doc/api_samples/os-volumes/snapshots-show-resp.json11
-rw-r--r--doc/api_samples/os-volumes/snapshots-show-resp.xml2
-rw-r--r--nova/tests/api/openstack/fakes.py2
-rw-r--r--nova/tests/integrated/api_samples/os-volumes/snapshot-create-req.json.tpl8
-rw-r--r--nova/tests/integrated/api_samples/os-volumes/snapshot-create-req.xml.tpl7
-rw-r--r--nova/tests/integrated/api_samples/os-volumes/snapshot-create-resp.json.tpl32
-rw-r--r--nova/tests/integrated/api_samples/os-volumes/snapshot-create-resp.xml.tpl2
-rw-r--r--nova/tests/integrated/api_samples/os-volumes/snapshots-detail-resp.json.tpl31
-rw-r--r--nova/tests/integrated/api_samples/os-volumes/snapshots-detail-resp.xml.tpl6
-rw-r--r--nova/tests/integrated/api_samples/os-volumes/snapshots-list-resp.json.tpl31
-rw-r--r--nova/tests/integrated/api_samples/os-volumes/snapshots-list-resp.xml.tpl6
-rw-r--r--nova/tests/integrated/api_samples/os-volumes/snapshots-show-resp.json.tpl11
-rw-r--r--nova/tests/integrated/api_samples/os-volumes/snapshots-show-resp.xml.tpl2
-rw-r--r--nova/tests/integrated/test_api_samples.py72
22 files changed, 344 insertions, 2 deletions
diff --git a/doc/api_samples/os-volumes/snapshot-create-req.json b/doc/api_samples/os-volumes/snapshot-create-req.json
new file mode 100644
index 000000000..8ad5b3cb0
--- /dev/null
+++ b/doc/api_samples/os-volumes/snapshot-create-req.json
@@ -0,0 +1,8 @@
+{
+ "snapshot": {
+ "display_name": "snap-001",
+ "display_description": "Daily backup",
+ "volume_id": "521752a6-acf6-4b2d-bc7a-119f9148cd8c",
+ "force": false
+ }
+} \ No newline at end of file
diff --git a/doc/api_samples/os-volumes/snapshot-create-req.xml b/doc/api_samples/os-volumes/snapshot-create-req.xml
new file mode 100644
index 000000000..e5001cf06
--- /dev/null
+++ b/doc/api_samples/os-volumes/snapshot-create-req.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <snapshot>
+ <display_name>snap-001</display_name>
+ <display_description>Daily backup</display_description>
+ <volume_id>521752a6-acf6-4b2d-bc7a-119f9148cd8c</volume_id>
+ <force>false</force>
+ </snapshot> \ No newline at end of file
diff --git a/doc/api_samples/os-volumes/snapshot-create-resp.json b/doc/api_samples/os-volumes/snapshot-create-resp.json
new file mode 100644
index 000000000..1a14bea01
--- /dev/null
+++ b/doc/api_samples/os-volumes/snapshot-create-resp.json
@@ -0,0 +1,32 @@
+{
+ "snapshot": {
+ "createdAt": "2013-02-25T16:27:54.680544",
+ "displayDescription": "Daily backup",
+ "displayName": "snap-001",
+ "id": 100,
+ "size": 100,
+ "status": "available",
+ "volumeId": {
+ "attach_status": "attached",
+ "availability_zone": "fakeaz",
+ "created_at": "1999-01-01T01:01:01.000000",
+ "display_description": "displaydesc",
+ "display_name": "displayname",
+ "host": "fakehost",
+ "id": "521752a6-acf6-4b2d-bc7a-119f9148cd8c",
+ "instance_uuid": "fakeuuid",
+ "mountpoint": "/",
+ "name": "vol name",
+ "project_id": "fakeproject",
+ "size": 1,
+ "snapshot_id": null,
+ "status": "fakestatus",
+ "user_id": "fakeuser",
+ "volume_metadata": [],
+ "volume_type": {
+ "name": "vol_type_name"
+ },
+ "volume_type_id": "fakevoltype"
+ }
+ }
+} \ No newline at end of file
diff --git a/doc/api_samples/os-volumes/snapshot-create-resp.xml b/doc/api_samples/os-volumes/snapshot-create-resp.xml
new file mode 100644
index 000000000..ad815f723
--- /dev/null
+++ b/doc/api_samples/os-volumes/snapshot-create-resp.xml
@@ -0,0 +1,2 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<snapshot status="available" displayDescription="Daily backup" displayName="snap-001" volumeId="{'instance_uuid': 'fakeuuid', 'status': 'fakestatus', 'user_id': 'fakeuser', 'name': 'vol name', 'display_name': 'displayname', 'availability_zone': 'fakeaz', 'created_at': datetime.datetime(1999, 1, 1, 1, 1, 1), 'attach_status': 'attached', 'display_description': 'displaydesc', 'host': 'fakehost', 'volume_type_id': 'fakevoltype', 'volume_metadata': [], 'volume_type': {'name': 'vol_type_name'}, 'snapshot_id': None, 'mountpoint': '/', 'project_id': 'fakeproject', 'id': u'521752a6-acf6-4b2d-bc7a-119f9148cd8c', 'size': 1}" id="100" createdAt="2013-02-25 16:27:36.840121" size="100"/> \ No newline at end of file
diff --git a/doc/api_samples/os-volumes/snapshots-detail-resp.json b/doc/api_samples/os-volumes/snapshots-detail-resp.json
new file mode 100644
index 000000000..796e522c4
--- /dev/null
+++ b/doc/api_samples/os-volumes/snapshots-detail-resp.json
@@ -0,0 +1,31 @@
+{
+ "snapshots": [
+ {
+ "createdAt": "2013-02-25T16:27:54.671372",
+ "displayDescription": "Default description",
+ "displayName": "Default name",
+ "id": 100,
+ "size": 100,
+ "status": "available",
+ "volumeId": 12
+ },
+ {
+ "createdAt": "2013-02-25T16:27:54.671378",
+ "displayDescription": "Default description",
+ "displayName": "Default name",
+ "id": 101,
+ "size": 100,
+ "status": "available",
+ "volumeId": 12
+ },
+ {
+ "createdAt": "2013-02-25T16:27:54.671381",
+ "displayDescription": "Default description",
+ "displayName": "Default name",
+ "id": 102,
+ "size": 100,
+ "status": "available",
+ "volumeId": 12
+ }
+ ]
+} \ No newline at end of file
diff --git a/doc/api_samples/os-volumes/snapshots-detail-resp.xml b/doc/api_samples/os-volumes/snapshots-detail-resp.xml
new file mode 100644
index 000000000..5e946939f
--- /dev/null
+++ b/doc/api_samples/os-volumes/snapshots-detail-resp.xml
@@ -0,0 +1,6 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<snapshots>
+ <snapshot status="available" displayDescription="Default description" displayName="Default name" volumeId="12" id="100" createdAt="2013-02-25 16:27:36.862459" size="100"/>
+ <snapshot status="available" displayDescription="Default description" displayName="Default name" volumeId="12" id="101" createdAt="2013-02-25 16:27:36.862466" size="100"/>
+ <snapshot status="available" displayDescription="Default description" displayName="Default name" volumeId="12" id="102" createdAt="2013-02-25 16:27:36.862469" size="100"/>
+</snapshots> \ No newline at end of file
diff --git a/doc/api_samples/os-volumes/snapshots-list-resp.json b/doc/api_samples/os-volumes/snapshots-list-resp.json
new file mode 100644
index 000000000..9b7cb412a
--- /dev/null
+++ b/doc/api_samples/os-volumes/snapshots-list-resp.json
@@ -0,0 +1,31 @@
+{
+ "snapshots": [
+ {
+ "createdAt": "2013-02-25T16:27:54.684999",
+ "displayDescription": "Default description",
+ "displayName": "Default name",
+ "id": 100,
+ "size": 100,
+ "status": "available",
+ "volumeId": 12
+ },
+ {
+ "createdAt": "2013-02-25T16:27:54.685005",
+ "displayDescription": "Default description",
+ "displayName": "Default name",
+ "id": 101,
+ "size": 100,
+ "status": "available",
+ "volumeId": 12
+ },
+ {
+ "createdAt": "2013-02-25T16:27:54.685008",
+ "displayDescription": "Default description",
+ "displayName": "Default name",
+ "id": 102,
+ "size": 100,
+ "status": "available",
+ "volumeId": 12
+ }
+ ]
+} \ No newline at end of file
diff --git a/doc/api_samples/os-volumes/snapshots-list-resp.xml b/doc/api_samples/os-volumes/snapshots-list-resp.xml
new file mode 100644
index 000000000..6714c98bc
--- /dev/null
+++ b/doc/api_samples/os-volumes/snapshots-list-resp.xml
@@ -0,0 +1,6 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<snapshots>
+ <snapshot status="available" displayDescription="Default description" displayName="Default name" volumeId="12" id="100" createdAt="2013-02-25 16:27:36.769149" size="100"/>
+ <snapshot status="available" displayDescription="Default description" displayName="Default name" volumeId="12" id="101" createdAt="2013-02-25 16:27:36.769154" size="100"/>
+ <snapshot status="available" displayDescription="Default description" displayName="Default name" volumeId="12" id="102" createdAt="2013-02-25 16:27:36.769157" size="100"/>
+</snapshots> \ No newline at end of file
diff --git a/doc/api_samples/os-volumes/snapshots-show-resp.json b/doc/api_samples/os-volumes/snapshots-show-resp.json
new file mode 100644
index 000000000..d7b3f26e4
--- /dev/null
+++ b/doc/api_samples/os-volumes/snapshots-show-resp.json
@@ -0,0 +1,11 @@
+{
+ "snapshot": {
+ "createdAt": "2013-02-25T16:27:54.724209",
+ "displayDescription": "Default description",
+ "displayName": "Default name",
+ "id": "100",
+ "size": 100,
+ "status": "available",
+ "volumeId": 12
+ }
+} \ No newline at end of file
diff --git a/doc/api_samples/os-volumes/snapshots-show-resp.xml b/doc/api_samples/os-volumes/snapshots-show-resp.xml
new file mode 100644
index 000000000..3c70cf033
--- /dev/null
+++ b/doc/api_samples/os-volumes/snapshots-show-resp.xml
@@ -0,0 +1,2 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<snapshot status="available" displayDescription="Default description" displayName="Default name" volumeId="12" id="100" createdAt="2013-02-25 16:27:36.854206" size="100"/> \ No newline at end of file
diff --git a/nova/tests/api/openstack/fakes.py b/nova/tests/api/openstack/fakes.py
index c906dae7f..cced8c787 100644
--- a/nova/tests/api/openstack/fakes.py
+++ b/nova/tests/api/openstack/fakes.py
@@ -587,7 +587,7 @@ def stub_snapshot(id, **kwargs):
'volume_id': 12,
'status': 'available',
'volume_size': 100,
- 'created_at': None,
+ 'created_at': timeutils.utcnow(),
'display_name': 'Default name',
'display_description': 'Default description',
'project_id': 'fake'
diff --git a/nova/tests/integrated/api_samples/os-volumes/snapshot-create-req.json.tpl b/nova/tests/integrated/api_samples/os-volumes/snapshot-create-req.json.tpl
new file mode 100644
index 000000000..a8d47ea03
--- /dev/null
+++ b/nova/tests/integrated/api_samples/os-volumes/snapshot-create-req.json.tpl
@@ -0,0 +1,8 @@
+{
+ "snapshot": {
+ "display_name": "%(snapshot_name)s",
+ "display_description": "%(description)s",
+ "volume_id": "%(volume_id)s",
+ "force": false
+ }
+}
diff --git a/nova/tests/integrated/api_samples/os-volumes/snapshot-create-req.xml.tpl b/nova/tests/integrated/api_samples/os-volumes/snapshot-create-req.xml.tpl
new file mode 100644
index 000000000..a5b670bc2
--- /dev/null
+++ b/nova/tests/integrated/api_samples/os-volumes/snapshot-create-req.xml.tpl
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <snapshot>
+ <display_name>%(snapshot_name)s</display_name>
+ <display_description>%(description)s</display_description>
+ <volume_id>%(volume_id)s</volume_id>
+ <force>false</force>
+ </snapshot>
diff --git a/nova/tests/integrated/api_samples/os-volumes/snapshot-create-resp.json.tpl b/nova/tests/integrated/api_samples/os-volumes/snapshot-create-resp.json.tpl
new file mode 100644
index 000000000..73cd02d9d
--- /dev/null
+++ b/nova/tests/integrated/api_samples/os-volumes/snapshot-create-resp.json.tpl
@@ -0,0 +1,32 @@
+{
+ "snapshot": {
+ "createdAt": "%(timestamp)s",
+ "displayDescription": "%(description)s",
+ "displayName": "%(snapshot_name)s",
+ "id": 100,
+ "size": 100,
+ "status": "available",
+ "volumeId": {
+ "attach_status": "attached",
+ "availability_zone": "fakeaz",
+ "created_at": "%(timestamp)s",
+ "display_description": "displaydesc",
+ "display_name": "displayname",
+ "host": "fakehost",
+ "id": "%(uuid)s",
+ "instance_uuid": "fakeuuid",
+ "mountpoint": "/",
+ "name": "vol name",
+ "project_id": "fakeproject",
+ "size": 1,
+ "snapshot_id": null,
+ "status": "fakestatus",
+ "user_id": "fakeuser",
+ "volume_metadata": [],
+ "volume_type": {
+ "name": "vol_type_name"
+ },
+ "volume_type_id": "fakevoltype"
+ }
+ }
+}
diff --git a/nova/tests/integrated/api_samples/os-volumes/snapshot-create-resp.xml.tpl b/nova/tests/integrated/api_samples/os-volumes/snapshot-create-resp.xml.tpl
new file mode 100644
index 000000000..aa713311f
--- /dev/null
+++ b/nova/tests/integrated/api_samples/os-volumes/snapshot-create-resp.xml.tpl
@@ -0,0 +1,2 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<snapshot status="available" displayDescription="%(description)s" displayName="%(snapshot_name)s" volumeId="{'instance_uuid': 'fakeuuid', 'status': 'fakestatus', 'user_id': 'fakeuser', 'name': 'vol name', 'display_name': 'displayname', 'availability_zone': 'fakeaz', 'created_at': datetime.datetime(1999, 1, 1, 1, 1, 1), 'attach_status': 'attached', 'display_description': 'displaydesc', 'host': 'fakehost', 'volume_type_id': 'fakevoltype', 'volume_metadata': [], 'volume_type': {'name': 'vol_type_name'}, 'snapshot_id': None, 'mountpoint': '/', 'project_id': 'fakeproject', 'id': u'521752a6-acf6-4b2d-bc7a-119f9148cd8c', 'size': 1}" id="100" createdAt="%(timestamp)s" size="100"/>
diff --git a/nova/tests/integrated/api_samples/os-volumes/snapshots-detail-resp.json.tpl b/nova/tests/integrated/api_samples/os-volumes/snapshots-detail-resp.json.tpl
new file mode 100644
index 000000000..f6b4a3abf
--- /dev/null
+++ b/nova/tests/integrated/api_samples/os-volumes/snapshots-detail-resp.json.tpl
@@ -0,0 +1,31 @@
+{
+ "snapshots": [
+ {
+ "createdAt": "%(timestamp)s",
+ "displayDescription": "Default description",
+ "displayName": "Default name",
+ "id": 100,
+ "size": 100,
+ "status": "available",
+ "volumeId": 12
+ },
+ {
+ "createdAt": "%(timestamp)s",
+ "displayDescription": "Default description",
+ "displayName": "Default name",
+ "id": 101,
+ "size": 100,
+ "status": "available",
+ "volumeId": 12
+ },
+ {
+ "createdAt": "%(timestamp)s",
+ "displayDescription": "Default description",
+ "displayName": "Default name",
+ "id": 102,
+ "size": 100,
+ "status": "available",
+ "volumeId": 12
+ }
+ ]
+}
diff --git a/nova/tests/integrated/api_samples/os-volumes/snapshots-detail-resp.xml.tpl b/nova/tests/integrated/api_samples/os-volumes/snapshots-detail-resp.xml.tpl
new file mode 100644
index 000000000..dbfe32526
--- /dev/null
+++ b/nova/tests/integrated/api_samples/os-volumes/snapshots-detail-resp.xml.tpl
@@ -0,0 +1,6 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<snapshots>
+ <snapshot status="available" displayDescription="%(text)s" displayName="%(text)s" volumeId="12" id="100" createdAt="%(timestamp)s" size="100"/>
+ <snapshot status="available" displayDescription="%(text)s" displayName="%(text)s" volumeId="12" id="101" createdAt="%(timestamp)s" size="100"/>
+ <snapshot status="available" displayDescription="%(text)s" displayName="%(text)s" volumeId="12" id="102" createdAt="%(timestamp)s" size="100"/>
+</snapshots>
diff --git a/nova/tests/integrated/api_samples/os-volumes/snapshots-list-resp.json.tpl b/nova/tests/integrated/api_samples/os-volumes/snapshots-list-resp.json.tpl
new file mode 100644
index 000000000..5cfbd7283
--- /dev/null
+++ b/nova/tests/integrated/api_samples/os-volumes/snapshots-list-resp.json.tpl
@@ -0,0 +1,31 @@
+{
+ "snapshots": [
+ {
+ "createdAt": "%(timestamp)s",
+ "displayDescription": "%(text)s",
+ "displayName": "%(text)s",
+ "id": 100,
+ "size": 100,
+ "status": "available",
+ "volumeId": 12
+ },
+ {
+ "createdAt": "%(timestamp)s",
+ "displayDescription": "%(text)s",
+ "displayName": "%(text)s",
+ "id": 101,
+ "size": 100,
+ "status": "available",
+ "volumeId": 12
+ },
+ {
+ "createdAt": "%(timestamp)s",
+ "displayDescription": "%(text)s",
+ "displayName": "%(text)s",
+ "id": 102,
+ "size": 100,
+ "status": "available",
+ "volumeId": 12
+ }
+ ]
+}
diff --git a/nova/tests/integrated/api_samples/os-volumes/snapshots-list-resp.xml.tpl b/nova/tests/integrated/api_samples/os-volumes/snapshots-list-resp.xml.tpl
new file mode 100644
index 000000000..dbfe32526
--- /dev/null
+++ b/nova/tests/integrated/api_samples/os-volumes/snapshots-list-resp.xml.tpl
@@ -0,0 +1,6 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<snapshots>
+ <snapshot status="available" displayDescription="%(text)s" displayName="%(text)s" volumeId="12" id="100" createdAt="%(timestamp)s" size="100"/>
+ <snapshot status="available" displayDescription="%(text)s" displayName="%(text)s" volumeId="12" id="101" createdAt="%(timestamp)s" size="100"/>
+ <snapshot status="available" displayDescription="%(text)s" displayName="%(text)s" volumeId="12" id="102" createdAt="%(timestamp)s" size="100"/>
+</snapshots>
diff --git a/nova/tests/integrated/api_samples/os-volumes/snapshots-show-resp.json.tpl b/nova/tests/integrated/api_samples/os-volumes/snapshots-show-resp.json.tpl
new file mode 100644
index 000000000..0690ed8b6
--- /dev/null
+++ b/nova/tests/integrated/api_samples/os-volumes/snapshots-show-resp.json.tpl
@@ -0,0 +1,11 @@
+{
+ "snapshot": {
+ "createdAt": "%(timestamp)s",
+ "displayDescription": "%(description)s",
+ "displayName": "%(snapshot_name)s",
+ "id": "100",
+ "size": 100,
+ "status": "available",
+ "volumeId": 12
+ }
+}
diff --git a/nova/tests/integrated/api_samples/os-volumes/snapshots-show-resp.xml.tpl b/nova/tests/integrated/api_samples/os-volumes/snapshots-show-resp.xml.tpl
new file mode 100644
index 000000000..3525851cf
--- /dev/null
+++ b/nova/tests/integrated/api_samples/os-volumes/snapshots-show-resp.xml.tpl
@@ -0,0 +1,2 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<snapshot status="available" displayDescription="%(description)s" displayName="%(snapshot_name)s" volumeId="12" id="100" createdAt="%(timestamp)s" size="100"/>
diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py
index aaf22ff9d..f6926b50e 100644
--- a/nova/tests/integrated/test_api_samples.py
+++ b/nova/tests/integrated/test_api_samples.py
@@ -57,6 +57,7 @@ from nova.tests.image import fake
from nova.tests.integrated import integrated_helpers
from nova.tests import utils as test_utils
from nova import utils
+from nova.volume import cinder
CONF = cfg.CONF
CONF.import_opt('allow_resize_to_same_host', 'nova.compute.api')
@@ -384,7 +385,6 @@ class ApiSamplesTrap(ApiSampleTestBase):
# removed) soon.
do_not_approve_additions = []
do_not_approve_additions.append('os-create-server-ext')
- do_not_approve_additions.append('os-volumes')
tests = self._get_extensions_tested()
extensions = self._get_extensions()
@@ -3589,3 +3589,73 @@ class AttachInterfacesSampleJsonTest(ServersSampleBase):
class AttachInterfacesSampleXmlTest(AttachInterfacesSampleJsonTest):
ctype = 'xml'
+
+
+class SnapshotsSampleJsonTests(ApiSampleTestBase):
+ extension_name = "nova.api.openstack.compute.contrib.volumes.Volumes"
+
+ create_subs = {
+ 'snapshot_name': 'snap-001',
+ 'description': 'Daily backup',
+ 'volume_id': '521752a6-acf6-4b2d-bc7a-119f9148cd8c'
+ }
+
+ def setUp(self):
+ super(SnapshotsSampleJsonTests, self).setUp()
+ self.stubs.Set(cinder.API, "get_all_snapshots",
+ fakes.stub_snapshot_get_all)
+ self.stubs.Set(cinder.API, "get_snapshot", fakes.stub_snapshot_get)
+
+ def _create_snapshot(self):
+ self.stubs.Set(cinder.API, "create_snapshot",
+ fakes.stub_snapshot_create)
+ self.stubs.Set(cinder.API, "get", fakes.stub_volume_get)
+
+ response = self._do_post("os-snapshots",
+ "snapshot-create-req",
+ self.create_subs)
+ return response
+
+ def test_snapshots_create(self):
+ response = self._create_snapshot()
+ self.assertEqual(response.status, 200)
+ self.create_subs.update(self._get_regexes())
+ return self._verify_response("snapshot-create-resp",
+ self.create_subs, response)
+
+ def test_snapshots_delete(self):
+ self.stubs.Set(cinder.API, "delete_snapshot",
+ fakes.stub_snapshot_delete)
+ self._create_snapshot()
+ response = self._do_delete('os-snapshots/100')
+ self.assertEqual(response.status, 202)
+ self.assertEqual(response.read(), '')
+
+ def test_snapshots_detail(self):
+ response = self._do_get('os-snapshots/detail')
+ self.assertEqual(response.status, 200)
+ subs = self._get_regexes()
+ return self._verify_response('snapshots-detail-resp',
+ subs, response)
+
+ def test_snapshots_list(self):
+ response = self._do_get('os-snapshots')
+ self.assertEqual(response.status, 200)
+ subs = self._get_regexes()
+ return self._verify_response('snapshots-list-resp',
+ subs, response)
+
+ def test_snapshots_show(self):
+ response = self._do_get('os-snapshots/100')
+ self.assertEqual(response.status, 200)
+ subs = {
+ 'snapshot_name': 'Default name',
+ 'description': 'Default description'
+ }
+ subs.update(self._get_regexes())
+ return self._verify_response('snapshots-show-resp',
+ subs, response)
+
+
+class SnapshotsSampleXmlTests(SnapshotsSampleJsonTests):
+ ctype = "xml"