|
5 | 5 | :license: MIT, see LICENSE for more details. |
6 | 6 | """ |
7 | 7 | import json |
| 8 | +from unittest import mock |
8 | 9 |
|
9 | 10 | from SoftLayer import testing |
10 | 11 |
|
@@ -82,25 +83,11 @@ def test_limit_credential(self): |
82 | 83 | self.assertEqual(json.loads(result.output), [{'limit': 2}]) |
83 | 84 |
|
84 | 85 | def test_list_credential(self): |
85 | | - accounts = self.set_mock('SoftLayer_Network_Storage_Hub_Cleversafe_Account', 'getCredentials') |
86 | | - accounts.return_value = [{'id': 1103123, |
87 | | - 'password': 'nwUEUsx6PiEoN0B1Xe9z9hUCyXM', |
88 | | - 'type': {'name': 'S3 Compatible Signature'}, |
89 | | - 'username': 'XfHhBNBPlPdlWya'}, |
90 | | - {'id': 1103333, |
91 | | - 'password': 'nwUEUsx6PiEoN0B1Xe9z9', |
92 | | - 'type': {'name': 'S3 Compatible Signature'}, |
93 | | - 'username': 'XfHhBNBPlPd'}] |
94 | | - |
95 | 86 | result = self.run_command(['object-storage', 'credential', 'list', '100']) |
| 87 | + self.assert_no_fail(result) |
96 | 88 |
|
| 89 | + @mock.patch('SoftLayer.CLI.helpers.resolve_id') |
| 90 | + def test_list_credential_by_username(self, resolve_id_mock): |
| 91 | + resolve_id_mock.return_value = 100 |
| 92 | + result = self.run_command(['object-storage', 'credential', 'list', 'test']) |
97 | 93 | self.assert_no_fail(result) |
98 | | - self.assertEqual(json.loads(result.output), |
99 | | - [{'id': 1103123, |
100 | | - 'password': 'nwUEUsx6PiEoN0B1Xe9z9hUCyXM', |
101 | | - 'type_name': 'S3 Compatible Signature', |
102 | | - 'username': 'XfHhBNBPlPdlWya'}, |
103 | | - {'id': 1103333, |
104 | | - 'password': 'nwUEUsx6PiEoN0B1Xe9z9', |
105 | | - 'type_name': 'S3 Compatible Signature', |
106 | | - 'username': 'XfHhBNBPlPd'}]) |
0 commit comments