Skip to content

Commit

Permalink
Merge pull request #290 from zhilong-xu/pure
Browse files Browse the repository at this point in the history
pure codeview-recompose test_reset_connection
  • Loading branch information
luopan-code authored Nov 10, 2021
2 parents 231c09b + 7aaa252 commit b2deff4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
8 changes: 6 additions & 2 deletions delfin/drivers/pure/pure/pure_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ def list_volumes(self, context):
pools = self.rest_handler.get_pools()
for volume in volumes:
volume_name = volume.get('name')
total_capacity = int(int(volume.get('size')) / units.Ki)
used_capacity = int(int(volume.get('volumes')) / units.Ki)
total_capacity = int(int(volume.get('size',
consts.DEFAULT_CAPACITY)) /
units.Ki)
used_capacity = int(int(volume.get('volumes',
consts.DEFAULT_CAPACITY)) /
units.Ki)
native_storage_pool_id = None
if pools:
for pool in pools:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import sys
from unittest import TestCase, mock

import six
from oslo_log import log

sys.modules['delfin.cryptor'] = mock.Mock()
Expand Down Expand Up @@ -264,7 +266,7 @@
]
reset_connection_info = {
"username": "username",
"status_code": 200
"status": 200
}


Expand All @@ -274,7 +276,7 @@ def create_driver():
return PureStorageDriver(**ACCESS_INFO)


class test_StorageDriver(TestCase):
class test_PureStorageDriver(TestCase):
driver = create_driver()

def test_init(self):
Expand Down Expand Up @@ -326,8 +328,18 @@ def test_list_ports(self):
self.assertEqual(list_ports[0].get('wwn'), port_info[0].get('wwn'))

def test_list_storage_pools(self):
RestHandler.get_info = mock.Mock(
side_effect=[pools_info])
RestHandler.get_info = mock.Mock(side_effect=[pools_info])
list_storage_pools = self.driver.list_storage_pools(context)
self.assertEqual(list_storage_pools[0].get('native_storage_pool_id'),
pools_info[0].get('name'))

def test_reset_connection(self):
RestHandler.logout = mock.Mock(side_effect=None)
RestHandler.login = mock.Mock(side_effect=None)
username = None
try:
self.driver.reset_connection(context)
except Exception as e:
LOG.error("test_reset_connection error: %s", six.text_type(e))
username = reset_connection_info.get('username')
self.assertEqual(username, None)

0 comments on commit b2deff4

Please sign in to comment.