Skip to content

Commit

Permalink
Debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
rameshraghupathy committed Nov 13, 2024
1 parent ffea8f0 commit 8227b4c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions sonic-chassisd/tests/test_chassisd.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,11 @@ def test_is_first_boot_file_found_first_boot():
chassis = MockSmartSwitchChassis()
module = "DPU0"

def ss_mock_open(*args, **kwargs):
return open(*args, **kwargs)

with patch("os.path.join", return_value="/mocked/path/to/reboot-cause.txt"), \
patch("builtins.open", new_callable=mock_open, read_data="First boot") as mock_file:
patch("builtins.open", new_callable=ss_mock_open, read_data="First boot") as mock_file:

# Call the method to check if it detects first boot
result = chassis._is_first_boot(module)
Expand All @@ -451,8 +454,11 @@ def test_is_first_boot_file_not_found():
chassis = MockSmartSwitchChassis()
module = "DPU0"

def ss_mock_open(*args, **kwargs):
return open(*args, **kwargs)

with patch("os.path.join", return_value="/mocked/path/to/reboot-cause.txt"), \
patch("builtins.open", new_callable=mock_open) as mock_file:
patch("builtins.open", new_callable=ss_mock_open) as mock_file:

# Simulate a file not being found by raising FileNotFoundError
mock_file.side_effect = FileNotFoundError
Expand Down

0 comments on commit 8227b4c

Please sign in to comment.