Skip to content

Commit

Permalink
Add one more test
Browse files Browse the repository at this point in the history
  • Loading branch information
vvolam committed Nov 25, 2024
1 parent e3e9e79 commit 19d7415
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/sonic-py-common/sonic_py_common/device_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ def is_dpu():
# Retrieve platform.json data
platform_data = get_platform_json_data()
if platform_data:
return "DPU" in platform_data
return 'DPU' in platform_data

return False

Expand Down
4 changes: 4 additions & 0 deletions src/sonic-py-common/tests/device_info_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ def test_is_dpu(self, mock_get_platform, mock_is_smartswitch, mock_get_platform_
mock_get_platform_json_data.return_value={"DPU": {}}
assert device_info.is_dpu() == True

# Test case where platform is a smart switch and DPU data is present in platform.json
mock_get_platform_json_data.return_value={"DPUS": {}}
assert device_info.is_dpu() == False

@mock.patch("sonic_py_common.device_info.get_platform_json_data")
@mock.patch("sonic_py_common.device_info.get_platform")
def test_get_dpu_info(self, mock_get_platform, mock_get_platform_json_data):
Expand Down

0 comments on commit 19d7415

Please sign in to comment.