forked from jdunck/python-cloudservers
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_ipgroups.py
More file actions
39 lines (32 loc) · 1.18 KB
/
test_ipgroups.py
File metadata and controls
39 lines (32 loc) · 1.18 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
37
38
39
from __future__ import absolute_import
from cloudservers import IPGroup
from .fakeserver import FakeServer
from .utils import assert_isinstance
from nose.tools import assert_equal
cs = FakeServer()
def test_list_ipgroups():
ipl = cs.ipgroups.list()
cs.assert_called('GET', '/shared_ip_groups/detail')
[assert_isinstance(ipg, IPGroup) for ipg in ipl]
def test_get_ipgroup():
ipg = cs.ipgroups.get(1)
cs.assert_called('GET', '/shared_ip_groups/1')
assert_isinstance(ipg, IPGroup)
def test_create_ipgroup():
ipg = cs.ipgroups.create("My group", 1234)
cs.assert_called('POST', '/shared_ip_groups')
assert_isinstance(ipg, IPGroup)
def test_delete_ipgroup():
ipg = cs.ipgroups.get(1)
ipg.delete()
cs.assert_called('DELETE', '/shared_ip_groups/1')
cs.ipgroups.delete(ipg)
cs.assert_called('DELETE', '/shared_ip_groups/1')
cs.ipgroups.delete(1)
cs.assert_called('DELETE', '/shared_ip_groups/1')
def test_find():
ipg = cs.ipgroups.find(name='group1')
cs.assert_called('GET', '/shared_ip_groups/detail')
assert_equal(ipg.name, 'group1')
ipgl = cs.ipgroups.findall(id=1)
assert_equal(ipgl, [IPGroup(None, {'id': 1})])