forked from jacobian/openstack.compute
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_images.py
More file actions
36 lines (29 loc) · 1 KB
/
test_images.py
File metadata and controls
36 lines (29 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from openstack.compute import Image
from fakeserver import FakeServer
from utils import assert_isinstance
from nose.tools import assert_equal
cs = FakeServer()
def test_list_images():
il = cs.images.list()
cs.assert_called('GET', '/images/detail')
[assert_isinstance(i, Image) for i in il]
def test_get_image_details():
i = cs.images.get(1)
cs.assert_called('GET', '/images/1')
assert_isinstance(i, Image)
assert_equal(i.id, 1)
assert_equal(i.name, 'CentOS 5.2')
def test_create_image():
i = cs.images.create(server=1234, name="Just in case")
cs.assert_called('POST', '/images')
assert_isinstance(i, Image)
def test_delete_image():
cs.images.delete(1)
cs.assert_called('DELETE', '/images/1')
def test_find():
i = cs.images.find(name="CentOS 5.2")
assert_equal(i.id, 1)
cs.assert_called('GET', '/images/detail')
iml = cs.images.findall(status='SAVING')
assert_equal(len(iml), 1)
assert_equal(iml[0].name, 'My Server Backup')