1
# Copyright 2012 OpenStack LLC.
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
8
# http://www.apache.org/licenses/LICENSE-2.0
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
16
from novaclient.v1_1 import flavor_access
17
from tests import utils
18
from tests.v1_1 import fakes
21
cs = fakes.FakeClient()
24
class FlavorAccessTest(utils.TestCase):
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]
32
def test_add_tenant_access(self):
33
flavor = cs.flavors.get(2)
35
r = cs.flavor_access.add_tenant_access(flavor, tenant)
43
cs.assert_called('POST', '/flavors/2/action', body)
44
[self.assertTrue(isinstance(a, flavor_access.FlavorAccess)) for a in r]
46
def test_remove_tenant_access(self):
47
flavor = cs.flavors.get(2)
49
r = cs.flavor_access.remove_tenant_access(flavor, tenant)
52
"removeTenantAccess": {
57
cs.assert_called('POST', '/flavors/2/action', body)
58
[self.assertTrue(isinstance(a, flavor_access.FlavorAccess)) for a in r]