Skip to content

Commit

Permalink
Debugging test issue
Browse files Browse the repository at this point in the history
  • Loading branch information
rameshraghupathy committed Nov 13, 2024
1 parent 26552de commit a1ded43
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions sonic-chassisd/tests/test_chassisd.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,25 +433,25 @@ def test_smartswitch_configupdater_check_admin_state():
assert module.get_admin_state() == admin_state


@mock.patch("sonic_chassisd.tests.mock_platform.os.path.join", return_value="/mocked/path/to/reboot-cause.txt")
def test_is_first_boot_file_found_first_boot(self, mock_join):
def test_is_first_boot_file_found_first_boot(self):
chassis = MockSmartSwitchChassis()
module = "DPU0"

with mock.patch("builtins.open", mock.mock_open(read_data="First boot")):
result = chassis._is_first_boot(module)
assert result # Using simple assert as requested
with mock.patch("sonic_chassisd.tests.mock_platform.os.path.join", return_value="/mocked/path/to/reboot-cause.txt"):
with mock.patch("builtins.open", mock.mock_open(read_data="First boot")):
result = chassis._is_first_boot(module)
assert result # Using simple assert as requested


@mock.patch("sonic_chassisd.tests.mock_platform.os.path.join", return_value="/mocked/path/to/reboot-cause.txt")
def test_is_first_boot_file_not_found(self, mock_join):
def test_is_first_boot_file_not_found(self):
chassis = MockSmartSwitchChassis()
module = "DPU0"

with mock.patch("builtins.open", mock.mock_open()) as mock_file:
mock_file.side_effect = FileNotFoundError
result = chassis._is_first_boot(module)
assert not result
with mock.patch("sonic_chassisd.tests.mock_platform.os.path.join", return_value="/mocked/path/to/reboot-cause.txt"):
with mock.patch("builtins.open", mock.mock_open()) as mock_file:
mock_file.side_effect = FileNotFoundError
result = chassis._is_first_boot(module)
assert not result


'''
Expand Down

0 comments on commit a1ded43

Please sign in to comment.