Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename sonic_ssd to sonic_storage matching corresponding sonic-platform-common change #3334

Merged
merged 15 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ssdutil/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def import_ssd_api(diskdev):
except ImportError as e:
log.log_warning("Platform specific SsdUtil module not found. Falling down to the generic implementation")
try:
from sonic_platform_base.sonic_ssd.ssd_generic import SsdUtil
from sonic_platform_base.sonic_storage.ssd import SsdUtil
assrinivasan marked this conversation as resolved.
Show resolved Hide resolved
except ImportError as e:
log.log_error("Failed to import default SsdUtil. Error: {}".format(str(e)), True)
raise e
Expand Down
42 changes: 42 additions & 0 deletions tests/ssdutil_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import sys
import argparse
from unittest.mock import patch, MagicMock
import sonic_platform_base # noqa: F401

sys.modules['sonic_platform'] = MagicMock()
sys.modules['sonic_platform_base.sonic_ssd.ssd_generic'] = MagicMock()

import ssdutil.main as ssdutil # noqa: E402


class Ssd():

def get_model(self):
return 'SkyNet'

def get_firmware(self):
return 'ABC'

def get_serial(self):
return 'T1000'

def get_health(self):
return 5

def get_temperature(self):
return 3000

def get_vendor_output(self):
return 'SONiC Test'


class TestSsdutil:

@patch('sonic_py_common.device_info.get_paths_to_platform_and_hwsku_dirs', MagicMock(return_value=("test_path", ""))) # noqa: E501
@patch('os.geteuid', MagicMock(return_value=0))
def test_sonic_storage_path(self):

with patch('argparse.ArgumentParser.parse_args', MagicMock()) as mock_args: # noqa: E501
sys.modules['sonic_platform_base.sonic_storage.ssd'] = MagicMock(return_value=Ssd()) # noqa: E501
mock_args.return_value = argparse.Namespace(device='/dev/sda', verbose=True, vendor=True) # noqa: E501
ssdutil.ssdutil()
Loading