forked from softlayer/softlayer-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobject_storage_tests.py
More file actions
121 lines (108 loc) · 4.62 KB
/
object_storage_tests.py
File metadata and controls
121 lines (108 loc) · 4.62 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
"""
SoftLayer.tests.managers.object_storage_tests
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:license: MIT, see LICENSE for more details.
"""
import SoftLayer
from SoftLayer import fixtures
from SoftLayer import testing
class ObjectStorageTests(testing.TestCase):
def set_up(self):
self.object_storage = SoftLayer.ObjectStorageManager(self.client)
def test_list_accounts(self):
accounts = self.object_storage.list_accounts()
self.assertEqual(accounts,
fixtures.SoftLayer_Account.getHubNetworkStorage)
def test_list_endpoints(self):
accounts = self.set_mock('SoftLayer_Account', 'getHubNetworkStorage')
accounts.return_value = {
'storageNodes': [{
'datacenter': {'name': 'dal05'},
'frontendIpAddress': 'https://dal05/auth/v1.0/',
'backendIpAddress': 'https://dal05/auth/v1.0/'}
],
}
endpoints = self.object_storage.list_endpoints()
self.assertEqual(endpoints,
[{'datacenter': {'name': 'dal05'},
'private': 'https://dal05/auth/v1.0/',
'public': 'https://dal05/auth/v1.0/'}])
def test_list_endpoints_no_results(self):
accounts = self.set_mock('SoftLayer_Account', 'getHubNetworkStorage')
accounts.return_value = {
'storageNodes': [],
}
endpoints = self.object_storage.list_endpoints()
self.assertEqual(endpoints,
[])
def test_create_credential(self):
accounts = self.set_mock('SoftLayer_Network_Storage_Hub_Cleversafe_Account', 'credentialCreate')
accounts.return_value = {
"id": 1103123,
"password": "nwUEUsx6PiEoN0B1Xe9z9hUCyXMkAF",
"username": "XfHhBNBPlPdlWyaP",
"type": {
"name": "S3 Compatible Signature"
}
}
credential = self.object_storage.create_credential(100)
self.assertEqual(credential,
{
"id": 1103123,
"password": "nwUEUsx6PiEoN0B1Xe9z9hUCyXMkAF",
"username": "XfHhBNBPlPdlWyaP",
"type": {
"name": "S3 Compatible Signature"
}
})
def test_delete_credential(self):
accounts = self.set_mock('SoftLayer_Network_Storage_Hub_Cleversafe_Account', 'credentialDelete')
accounts.return_value = True
credential = self.object_storage.delete_credential(100)
self.assertEqual(credential, True)
def test_limit_credential(self):
accounts = self.set_mock('SoftLayer_Network_Storage_Hub_Cleversafe_Account', 'getCredentialLimit')
accounts.return_value = 2
credential = self.object_storage.limit_credential(100)
self.assertEqual(credential, 2)
def test_list_credential(self):
accounts = self.set_mock('SoftLayer_Network_Storage_Hub_Cleversafe_Account', 'getCredentials')
accounts.return_value = [
{
"id": 1103123,
"password": "nwUEUsx6PiEoN0B1Xe9z9hUCyXsf4sf",
"username": "XfHhBNBPlPdlWyaP3fsd",
"type": {
"name": "S3 Compatible Signature"
}
},
{
"id": 1102341,
"password": "nwUEUsx6PiEoN0B1Xe9z9hUCyXMkAF",
"username": "XfHhBNBPlPdlWyaP",
"type": {
"name": "S3 Compatible Signature"
}
}
]
credential = self.object_storage.list_credential(100)
self.assertEqual(credential,
[
{
"id": 1103123,
"password": "nwUEUsx6PiEoN0B1Xe9z9hUCyXsf4sf",
"username": "XfHhBNBPlPdlWyaP3fsd",
"type": {
"name": "S3 Compatible Signature"
}
},
{
"id": 1102341,
"password": "nwUEUsx6PiEoN0B1Xe9z9hUCyXMkAF",
"username": "XfHhBNBPlPdlWyaP",
"type": {
"name": "S3 Compatible Signature"
}
}
]
)