cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seb...@apache.org
Subject [26/50] cloudstack-ec2stack git commit: Add tests for invalid snapshot / volumes
Date Tue, 05 May 2015 13:26:19 GMT
Add tests for invalid snapshot / volumes


Project: http://git-wip-us.apache.org/repos/asf/cloudstack-ec2stack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack-ec2stack/commit/f0a8c111
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack-ec2stack/tree/f0a8c111
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack-ec2stack/diff/f0a8c111

Branch: refs/heads/master
Commit: f0a8c1112a4936e046eeff07dfb576bcfe709bb5
Parents: 0aafa6d
Author: BroganD1993 <darrenbrogan@hotmail.com>
Authored: Sun Aug 10 15:46:21 2014 +0100
Committer: BroganD1993 <darrenbrogan@hotmail.com>
Committed: Sun Aug 10 15:46:21 2014 +0100

----------------------------------------------------------------------
 tests/snapshot_tests.py | 47 +++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 44 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack-ec2stack/blob/f0a8c111/tests/snapshot_tests.py
----------------------------------------------------------------------
diff --git a/tests/snapshot_tests.py b/tests/snapshot_tests.py
index ec9a842..cfea1dc 100644
--- a/tests/snapshot_tests.py
+++ b/tests/snapshot_tests.py
@@ -33,6 +33,27 @@ class SnapshotTestCase(Ec2StackAppTestCase):
         self.assert_ok(response)
         assert 'CreateSnapshotResponse' in response.data
 
+    def test_create_snapshot_invalid_volume(self):
+        data = self.get_example_data()
+        data['Action'] = 'CreateSnapshot'
+        data['VolumeId'] = 'invalidvolumeid'
+        data['Signature'] = generate_signature(data, 'POST', 'localhost', '/')
+
+        get = mock.Mock()
+        get.return_value.text = read_file(
+            'tests/data/invalid_create_snapshot_volume_not_found.json'
+        )
+        get.return_value.status_code = 200
+
+        with mock.patch('requests.get', get):
+            response = self.post(
+                '/',
+                data=data
+            )
+
+        self.assert_bad_request(response)
+        assert 'InvalidVolume.NotFound' in response.data
+
     def test_describe_snapshots(self):
         data = self.get_example_data()
         data['Action'] = 'DescribeSnapshots'
@@ -71,7 +92,6 @@ class SnapshotTestCase(Ec2StackAppTestCase):
                 data=data
             )
 
-        print response.data
         self.assert_ok(response)
         assert 'DescribeSnapshotsResponse' in response.data
         assert 'examplesnapshot' in response.data
@@ -100,7 +120,7 @@ class SnapshotTestCase(Ec2StackAppTestCase):
     def test_delete_snapshot(self):
         data = self.get_example_data()
         data['Action'] = 'DeleteSnapshot'
-        data['SnapshotId'] = 'Test'
+        data['SnapshotId'] = 'snapshotid'
         data['Signature'] = generate_signature(data, 'POST', 'localhost', '/')
 
         get = mock.Mock()
@@ -116,4 +136,25 @@ class SnapshotTestCase(Ec2StackAppTestCase):
             )
 
         self.assert_ok(response)
-        assert 'DeleteSnapshotResponse' in response.data
\ No newline at end of file
+        assert 'DeleteSnapshotResponse' in response.data
+
+    def test_delete_snapshot(self):
+        data = self.get_example_data()
+        data['Action'] = 'DeleteSnapshot'
+        data['SnapshotId'] = 'invalidsnapshotid'
+        data['Signature'] = generate_signature(data, 'POST', 'localhost', '/')
+
+        get = mock.Mock()
+        get.return_value.text = read_file(
+            'tests/data/invalid_delete_snapshot_snapshot_not_found.json'
+        )
+        get.return_value.status_code = 200
+
+        with mock.patch('requests.get', get):
+            response = self.post(
+                '/',
+                data=data
+            )
+
+        self.assert_bad_request(response)
+        assert 'InvalidSnapshot.NotFound' in response.data
\ No newline at end of file


Mime
View raw message