~ubuntu-cloud-archive/ubuntu/precise/python-novaclient/trunk

« back to all changes in this revision

Viewing changes to tests/v1_1/test_flavor_access.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Adam Gandelman, Soren Hansen, Chuck Short
  • Date: 2012-09-07 18:32:24 UTC
  • mfrom: (1.1.24)
  • Revision ID: package-import@ubuntu.com-20120907183224-5derwehm2omeiu0b
Tags: 1:2.8.0.5-0ubuntu1
[ Adam Gandelman ]
* debian/control: Add python-iso8601.

[ Soren Hansen ]
* Update debian/watch to account for symbolically named tarballs and
  use newer URL.
* Fix Launchpad URLs in debian/watch.

[ Chuck Short ]
* New usptream version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2012 OpenStack LLC.
 
2
# All Rights Reserved.
 
3
#
 
4
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
 
5
#    not use this file except in compliance with the License. You may obtain
 
6
#    a copy of the License at
 
7
#
 
8
#         http://www.apache.org/licenses/LICENSE-2.0
 
9
#
 
10
#    Unless required by applicable law or agreed to in writing, software
 
11
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
12
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
13
#    License for the specific language governing permissions and limitations
 
14
#    under the License.
 
15
 
 
16
from novaclient.v1_1 import flavor_access
 
17
from tests import utils
 
18
from tests.v1_1 import fakes
 
19
 
 
20
 
 
21
cs = fakes.FakeClient()
 
22
 
 
23
 
 
24
class FlavorAccessTest(utils.TestCase):
 
25
 
 
26
    def test_list_access_by_flavor_private(self):
 
27
        kwargs = {'flavor': cs.flavors.get(2)}
 
28
        r = cs.flavor_access.list(**kwargs)
 
29
        cs.assert_called('GET', '/flavors/2/os-flavor-access')
 
30
        [self.assertTrue(isinstance(a, flavor_access.FlavorAccess)) for a in r]
 
31
 
 
32
    def test_add_tenant_access(self):
 
33
        flavor = cs.flavors.get(2)
 
34
        tenant = 'proj2'
 
35
        r = cs.flavor_access.add_tenant_access(flavor, tenant)
 
36
 
 
37
        body = {
 
38
            "addTenantAccess": {
 
39
                "tenant": "proj2"
 
40
            }
 
41
        }
 
42
 
 
43
        cs.assert_called('POST', '/flavors/2/action', body)
 
44
        [self.assertTrue(isinstance(a, flavor_access.FlavorAccess)) for a in r]
 
45
 
 
46
    def test_remove_tenant_access(self):
 
47
        flavor = cs.flavors.get(2)
 
48
        tenant = 'proj2'
 
49
        r = cs.flavor_access.remove_tenant_access(flavor, tenant)
 
50
 
 
51
        body = {
 
52
            "removeTenantAccess": {
 
53
                "tenant": "proj2"
 
54
            }
 
55
        }
 
56
 
 
57
        cs.assert_called('POST', '/flavors/2/action', body)
 
58
        [self.assertTrue(isinstance(a, flavor_access.FlavorAccess)) for a in r]