forked from softlayer/softlayer-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiscsi_tests.py
More file actions
122 lines (97 loc) · 4.14 KB
/
iscsi_tests.py
File metadata and controls
122 lines (97 loc) · 4.14 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
"""
SoftLayer.tests.managers.iscsi_tests
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:license: MIT, see LICENSE for more details.
"""
import SoftLayer
from SoftLayer import fixtures
from SoftLayer import testing
class ISCSITests(testing.TestCase):
def set_up(self):
self.iscsi = SoftLayer.ISCSIManager(self.client)
def test_get_iscsi(self):
result = self.iscsi.get_iscsi(100)
self.assertEqual(fixtures.SoftLayer_Network_Storage_Iscsi.getObject,
result)
self.assert_called_with('SoftLayer_Network_Storage_Iscsi', 'getObject',
identifier=100)
def test_cancel_iscsi_immediately(self):
self.iscsi.cancel_iscsi(600, immediate=True)
self.assert_called_with('SoftLayer_Billing_Item', 'cancelItem',
args=(True, True, 'unNeeded'),
identifier=600)
def test_cancel_iscsi_without_reason(self):
self.iscsi.cancel_iscsi(600)
self.assert_called_with('SoftLayer_Billing_Item', 'cancelItem',
args=(False, True, 'unNeeded'),
identifier=600)
def test_cancel_iscsi_with_reason(self):
self.iscsi.cancel_iscsi(600, 'Network Performance')
self.assert_called_with('SoftLayer_Billing_Item', 'cancelItem',
args=(False, True, 'Network Performance'),
identifier=600)
def test_invalid_datacenter(self):
self.assertRaises(ValueError,
self.iscsi.create_iscsi,
size=10, location='foo')
def test_create_iscsi(self):
mock = self.set_mock('SoftLayer_Product_Package', 'getItems')
mock.return_value = [
{
'id': 4439,
'capacity': '1',
'description': '1 GB iSCSI Storage',
'itemCategory': {'categoryCode': 'iscsi'},
'prices': [{'id': 2222}]
}
]
self.iscsi.create_iscsi(size=1, location='dal05')
args = ({'prices': [{'id': 2222}],
'quantity': 1,
'location': 0,
'packageId': 0,
'complexType':
'SoftLayer_Container_Product_Order_Network_Storage_Iscsi'},)
self.assert_called_with('SoftLayer_Product_Order', 'placeOrder',
args=args)
def test_delete_snapshot(self):
self.iscsi.delete_snapshot(1)
self.assert_called_with('SoftLayer_Network_Storage_Iscsi',
'deleteObject',
identifier=1)
def test_create_snapshot(self):
self.iscsi.create_snapshot(100, 'unNeeded')
self.assert_called_with('SoftLayer_Network_Storage_Iscsi',
'createSnapshot',
identifier=100)
def test_create_snapshot_space(self):
mock = self.set_mock('SoftLayer_Product_Package', 'getItems')
mock.return_value = [
{
'id': 1121,
'capacity': '20',
'description': '20 GB iSCSI snapshot',
'itemCategory': {'categoryCode': 'iscsi_snapshot_space'},
'prices': [{'id': 2014}]
}]
self.iscsi.create_snapshot_space(100, 20)
args = (
{
'volumeId': 100,
'location': 138124,
'packageId': 0,
'complexType':
'SoftLayer_Container_'
'Product_Order_Network_Storage_Iscsi_SnapshotSpace',
'prices': [{'id': 2014}],
'quantity': 1,
},
)
self.assert_called_with('SoftLayer_Product_Order', 'placeOrder',
args=args)
def test_restore_from_snapshot(self):
self.iscsi.restore_from_snapshot(100, 101)
self.assert_called_with('SoftLayer_Network_Storage_Iscsi',
'restoreFromSnapshot',
args=(101,),
identifier=100)