summaryrefslogtreecommitdiff
path: root/novaclient/tests/unit/v2/test_images.py
diff options
context:
space:
mode:
Diffstat (limited to 'novaclient/tests/unit/v2/test_images.py')
-rw-r--r--novaclient/tests/unit/v2/test_images.py66
1 files changed, 66 insertions, 0 deletions
diff --git a/novaclient/tests/unit/v2/test_images.py b/novaclient/tests/unit/v2/test_images.py
new file mode 100644
index 0000000..1f8104e
--- /dev/null
+++ b/novaclient/tests/unit/v2/test_images.py
@@ -0,0 +1,66 @@
1#
2# Licensed under the Apache License, Version 2.0 (the "License"); you may
3# not use this file except in compliance with the License. You may obtain
4# a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11# License for the specific language governing permissions and limitations
12# under the License.
13
14from novaclient.tests.unit.fixture_data import client
15from novaclient.tests.unit.fixture_data import images as data
16from novaclient.tests.unit import utils
17from novaclient.v2 import images
18
19
20class ImagesTest(utils.FixturedTestCase):
21
22 client_fixture_class = client.V1
23 data_fixture_class = data.V1
24
25 def test_list_images(self):
26 il = self.cs.images.list()
27 self.assert_called('GET', '/images/detail')
28 [self.assertIsInstance(i, images.Image) for i in il]
29
30 def test_list_images_undetailed(self):
31 il = self.cs.images.list(detailed=False)
32 self.assert_called('GET', '/images')
33 [self.assertIsInstance(i, images.Image) for i in il]
34
35 def test_list_images_with_limit(self):
36 self.cs.images.list(limit=4)
37 self.assert_called('GET', '/images/detail?limit=4')
38
39 def test_get_image_details(self):
40 i = self.cs.images.get(1)
41 self.assert_called('GET', '/images/1')
42 self.assertIsInstance(i, images.Image)
43 self.assertEqual(1, i.id)
44 self.assertEqual('CentOS 5.2', i.name)
45
46 def test_delete_image(self):
47 self.cs.images.delete(1)
48 self.assert_called('DELETE', '/images/1')
49
50 def test_delete_meta(self):
51 self.cs.images.delete_meta(1, {'test_key': 'test_value'})
52 self.assert_called('DELETE', '/images/1/metadata/test_key')
53
54 def test_set_meta(self):
55 self.cs.images.set_meta(1, {'test_key': 'test_value'})
56 self.assert_called('POST', '/images/1/metadata',
57 {"metadata": {'test_key': 'test_value'}})
58
59 def test_find(self):
60 i = self.cs.images.find(name="CentOS 5.2")
61 self.assertEqual(1, i.id)
62 self.assert_called('GET', '/images/1')
63
64 iml = self.cs.images.findall(status='SAVING')
65 self.assertEqual(1, len(iml))
66 self.assertEqual('My Server Backup', iml[0].name)