Skip to content
Permalink
Browse files
Fix snapshot tests
  • Loading branch information
brogand93 committed Aug 6, 2014
1 parent d027dfb commit b6a48b93c5ee6677b931a8abcbaa81a3b06a0592
Showing 4 changed files with 9 additions and 12 deletions.
@@ -4,14 +4,10 @@
"""This module contains functions for handling requests in relation to snapshots.
"""

import uuid

from flask import current_app

from ec2stack import errors
from ec2stack import helpers
from ec2stack.providers import cloudstack
from ec2stack.providers.cloudstack import requester, zones
from ec2stack.providers.cloudstack import requester


@helpers.authentication_required
@@ -46,7 +42,7 @@ def _create_snapshot_response(response):
@return: Response.
"""

response = response['snapshot']
response = response['vmsnapshot']
return {
'template_name_or_list': 'create_snapshot.xml',
'response_type': 'CreateSnapshotResponse',
@@ -101,7 +97,7 @@ def describe_snapshots():
"""
args = {'command': 'listSnapshots'}
response = cloudstack.describe_item(
args, 'snapshot', errors.invalid_snapshot_id, 'SnapshotId'
args, 'vmsnapshot', errors.invalid_snapshot_id, 'SnapshotId'
)

return _describe_snapshot_response(
@@ -2,7 +2,7 @@
{% block response_content %}
<snapshot>
<snapshotId>{{ response.id }}</snapshotId>
<volumeId>{{ snapshot.volumeid }}</volumeId>
<volumeId>{{ response.volumeid }}</volumeId>
<status>{{ response.state }}</status>
</snapshot>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "response.xml" %}
{% block response_content %}
<snapshotSet>
{% for snapshot in response.snapshot %}
{% for snapshot in response.vmsnapshot %}
<item>
<snapshotId>{{ snapshot.id }}</snapshotId>
<volumeId>{{ snapshot.volumeid }}</volumeId>
@@ -55,7 +55,7 @@ def test_describe_snapshots(self):

def test_describe_snapshot_by_name(self):
data = self.get_example_data()
data['Action'] = 'DescribeVpcs'
data['Action'] = 'DescribeSnapshots'
data['SnapshotId'] = 'examplesnapshot'
data['Signature'] = generate_signature(data, 'POST', 'localhost', '/')

@@ -71,13 +71,14 @@ 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

def test_describe_snapshot_by_name_invalid_name(self):
data = self.get_example_data()
data['Action'] = 'DescribeVpcs'
data['Action'] = 'DescribeSnapshots'
data['SnapshotId'] = 'invalidsnapshot'
data['Signature'] = generate_signature(data, 'POST', 'localhost', '/')

@@ -94,7 +95,7 @@ def test_describe_snapshot_by_name_invalid_name(self):
)

self.assert_bad_request(response)
assert 'InvalidSnapshotID.NotFound' in response.data
assert 'InvalidSnapshot.NotFound' in response.data

def test_delete_snapshot(self):
data = self.get_example_data()

0 comments on commit b6a48b9

Please sign in to comment.