~ubuntu-branches/ubuntu/utopic/cinder/utopic

« back to all changes in this revision

Viewing changes to cinder/tests/api/contrib/test_snapshot_actions.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, James Page, Adam Gandelman, Chuck Short
  • Date: 2013-09-08 21:09:46 UTC
  • mfrom: (1.1.18)
  • Revision ID: package-import@ubuntu.com-20130908210946-3dbzq1jy5uji4wad
Tags: 1:2013.2~b3-0ubuntu1
[ James Page ]
* d/control: Switch ceph-common -> python-ceph inline with upstream
  refactoring of Ceph RBD driver, move to Suggests of python-cinder.
  (LP: #1190791). 

[ Adam Gandelman ]
* debian/patches/avoid_paramiko_vers_depends.patch: Dropped, no longer
  required.
* Add minimum requirement python-greenlet (>= 0.3.2).
* Add minimum requirement python-eventlet (>= 0.12.0).
* Add minimum requirement python-paramiko (>= 1.8).

[ Chuck Short ]
* New upstream release.
* debian/patches/skip-sqlachemy-failures.patch: Skip testfailures
  with sqlalchemy 0.8 until they are fixed upstream.
* debian/control: Add python-babel to build-depends.
* debian/control: Add python-novaclient to build-depends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#   Copyright 2013, Red Hat, Inc.
 
2
#
 
3
#   Licensed under the Apache License, Version 2.0 (the "License"); you may
 
4
#   not use this file except in compliance with the License. You may obtain
 
5
#   a copy of the License at
 
6
#
 
7
#       http://www.apache.org/licenses/LICENSE-2.0
 
8
#
 
9
#   Unless required by applicable law or agreed to in writing, software
 
10
#   distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
11
#   WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
12
#   License for the specific language governing permissions and limitations
 
13
#   under the License.
 
14
 
 
15
import datetime
 
16
import uuid
 
17
import webob
 
18
 
 
19
from cinder import db
 
20
from cinder import exception
 
21
from cinder.openstack.common import jsonutils
 
22
from cinder.openstack.common.rpc import common as rpc_common
 
23
from cinder import test
 
24
from cinder.tests.api import fakes
 
25
from cinder.tests.api.v2 import stubs
 
26
from cinder import volume
 
27
from cinder.volume import api as volume_api
 
28
 
 
29
 
 
30
class SnapshotActionsTest(test.TestCase):
 
31
 
 
32
    def setUp(self):
 
33
        super(SnapshotActionsTest, self).setUp()
 
34
 
 
35
    def test_update_snapshot_status(self):
 
36
        self.stubs.Set(db, 'snapshot_get', stub_snapshot_get)
 
37
        self.stubs.Set(db, 'snapshot_update', stub_snapshot_update)
 
38
 
 
39
        body = {'os-update_snapshot_status': {'status': 'available'}}
 
40
        req = webob.Request.blank('/v2/fake/snapshots/1/action')
 
41
        req.method = "POST"
 
42
        req.body = jsonutils.dumps(body)
 
43
        req.headers["content-type"] = "application/json"
 
44
 
 
45
        res = req.get_response(fakes.wsgi_app())
 
46
        self.assertEqual(res.status_int, 202)
 
47
 
 
48
    def test_update_snapshot_status_invalid_status(self):
 
49
        self.stubs.Set(db, 'snapshot_get', stub_snapshot_get)
 
50
        body = {'os-update_snapshot_status': {'status': 'in-use'}}
 
51
        req = webob.Request.blank('/v2/fake/snapshots/1/action')
 
52
        req.method = "POST"
 
53
        req.body = jsonutils.dumps(body)
 
54
        req.headers["content-type"] = "application/json"
 
55
 
 
56
        res = req.get_response(fakes.wsgi_app())
 
57
        self.assertEqual(res.status_int, 400)
 
58
 
 
59
 
 
60
def stub_snapshot_get(context, snapshot_id):
 
61
    snapshot = stubs.stub_snapshot(snapshot_id)
 
62
    if snapshot_id == 3:
 
63
        snapshot['status'] = 'error'
 
64
    elif snapshot_id == 1:
 
65
        snapshot['status'] = 'creating'
 
66
    elif snapshot_id == 7:
 
67
        snapshot['status'] = 'available'
 
68
    else:
 
69
        snapshot['status'] = 'creating'
 
70
 
 
71
    return snapshot
 
72
 
 
73
 
 
74
def stub_snapshot_update(self, context, id, **kwargs):
 
75
    pass