summaryrefslogtreecommitdiff
path: root/novaclient/tests/unit/v2/test_server_groups.py
diff options
context:
space:
mode:
Diffstat (limited to 'novaclient/tests/unit/v2/test_server_groups.py')
-rw-r--r--novaclient/tests/unit/v2/test_server_groups.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/novaclient/tests/unit/v2/test_server_groups.py b/novaclient/tests/unit/v2/test_server_groups.py
new file mode 100644
index 0000000..fcda2de
--- /dev/null
+++ b/novaclient/tests/unit/v2/test_server_groups.py
@@ -0,0 +1,59 @@
1# Copyright (c) 2014 VMware, Inc.
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
16from novaclient.tests.unit.fixture_data import client
17from novaclient.tests.unit.fixture_data import server_groups as data
18from novaclient.tests.unit import utils
19from novaclient.v2 import server_groups
20
21
22class ServerGroupsTest(utils.FixturedTestCase):
23
24 client_fixture_class = client.V1
25 data_fixture_class = data.Fixture
26
27 def test_list_server_groups(self):
28 result = self.cs.server_groups.list()
29 self.assert_called('GET', '/os-server-groups')
30 for server_group in result:
31 self.assertTrue(isinstance(server_group,
32 server_groups.ServerGroup))
33
34 def test_create_server_group(self):
35 kwargs = {'name': 'ig1',
36 'policies': ['anti-affinity']}
37 server_group = self.cs.server_groups.create(**kwargs)
38 body = {'server_group': kwargs}
39 self.assert_called('POST', '/os-server-groups', body)
40 self.assertTrue(isinstance(server_group,
41 server_groups.ServerGroup))
42
43 def test_get_server_group(self):
44 id = '2cbd51f4-fafe-4cdb-801b-cf913a6f288b'
45 server_group = self.cs.server_groups.get(id)
46 self.assert_called('GET', '/os-server-groups/%s' % id)
47 self.assertTrue(isinstance(server_group,
48 server_groups.ServerGroup))
49
50 def test_delete_server_group(self):
51 id = '2cbd51f4-fafe-4cdb-801b-cf913a6f288b'
52 self.cs.server_groups.delete(id)
53 self.assert_called('DELETE', '/os-server-groups/%s' % id)
54
55 def test_delete_server_group_object(self):
56 id = '2cbd51f4-fafe-4cdb-801b-cf913a6f288b'
57 server_group = self.cs.server_groups.get(id)
58 server_group.delete()
59 self.assert_called('DELETE', '/os-server-groups/%s' % id)