summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMORITA Kazutaka <morita.kazutaka@gmail.com>2011-05-16 16:29:21 +0900
committerMORITA Kazutaka <morita.kazutaka@gmail.com>2011-05-16 16:29:21 +0900
commit5eb57c6191ac7c8d98539eb3967ceb00f7c55daf (patch)
tree3171e68e7baf07f0e7ebe020622cce2e2e336181
parent8b86fb3a4d9ee3e328232c0051b9daff6838d00d (diff)
downloadnova-5eb57c6191ac7c8d98539eb3967ceb00f7c55daf.tar.gz
nova-5eb57c6191ac7c8d98539eb3967ceb00f7c55daf.tar.xz
nova-5eb57c6191ac7c8d98539eb3967ceb00f7c55daf.zip
Add a unit test for snapshot_volume.
-rw-r--r--nova/tests/test_volume.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/nova/tests/test_volume.py b/nova/tests/test_volume.py
index 236d12434..c66b66959 100644
--- a/nova/tests/test_volume.py
+++ b/nova/tests/test_volume.py
@@ -176,6 +176,33 @@ class VolumeTestCase(test.TestCase):
# This will allow us to test cross-node interactions
pass
+ @staticmethod
+ def _create_snapshot(volume_id, size='0'):
+ """Create a snapshot object."""
+ snap = {}
+ snap['volume_size'] = size
+ snap['user_id'] = 'fake'
+ snap['project_id'] = 'fake'
+ snap['volume_id'] = volume_id
+ snap['status'] = "creating"
+ return db.snapshot_create(context.get_admin_context(), snap)['id']
+
+ def test_create_delete_snapshot(self):
+ """Test snapshot can be created and deleted."""
+ volume_id = self._create_volume()
+ self.volume.create_volume(self.context, volume_id)
+ snapshot_id = self._create_snapshot(volume_id)
+ self.volume.create_snapshot(self.context, volume_id, snapshot_id)
+ self.assertEqual(snapshot_id, db.snapshot_get(context.get_admin_context(),
+ snapshot_id).id)
+
+ self.volume.delete_snapshot(self.context, snapshot_id)
+ self.assertRaises(exception.NotFound,
+ db.snapshot_get,
+ self.context,
+ snapshot_id)
+ self.volume.delete_volume(self.context, volume_id)
+
class DriverTestCase(test.TestCase):
"""Base Test class for Drivers."""