Skip to content
Permalink
Browse files
Add tests for invalid snapshot / volumes
  • Loading branch information
brogand93 committed Aug 10, 2014
1 parent 0aafa6d commit f0a8c1112a4936e046eeff07dfb576bcfe709bb5
Showing 1 changed file with 44 additions and 3 deletions.
@@ -33,6 +33,27 @@ def test_create_snapshot(self):
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 @@ def test_describe_snapshot_by_name(self):
data=data
)

print response.data
self.assert_ok(response)
assert 'DescribeSnapshotsResponse' in response.data
assert 'examplesnapshot' in response.data
@@ -100,7 +120,7 @@ def test_describe_snapshot_by_name_invalid_name(self):
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 @@ def test_delete_snapshot(self):
)

self.assert_ok(response)
assert 'DeleteSnapshotResponse' in response.data
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

0 comments on commit f0a8c11

Please sign in to comment.