diff --git a/tests/pages/test_settings_page.py b/tests/pages/test_settings_page.py index d8895055..583123fa 100644 --- a/tests/pages/test_settings_page.py +++ b/tests/pages/test_settings_page.py @@ -427,16 +427,18 @@ def test_set_first_tc_code(amigo, mocker): mocker, [ BUTTON_ENTER, - BUTTON_PAGE, BUTTON_ENTER, - ], # Skip TC Flash Hash at boot + ], # Confirm TC Flash Hash at boot ) ctx.tc_code_enabled = False settings_page = SettingsPage(ctx) settings_page.capture_from_keypad = mocker.MagicMock(return_value="123456") settings_page.enter_modify_tc_code() assert ctx.tc_code_enabled == True - assert mock_file.write_data == TC_CODE_EXTENDED_HASH + assert mock_file.previous_data[-1] == TC_CODE_EXTENDED_HASH + assert ( + mock_file.write_data == '{"settings": {"security": {"boot_flash_hash": true}}}' + ) def test_set_first_tc_code_not_match(amigo, mocker): @@ -477,16 +479,18 @@ def test_set_new_tc_code(amigo, mocker): mocker, [ BUTTON_ENTER, - BUTTON_PAGE, BUTTON_ENTER, - ], # Skip TC Flash Hash at boot + ], # Confirm TC Flash Hash at boot ) ctx.tc_code_enabled = True settings_page = SettingsPage(ctx) settings_page.capture_from_keypad = mocker.MagicMock(return_value="123456") settings_page.enter_modify_tc_code() assert ctx.tc_code_enabled == True - assert mock_file.write_data == TC_CODE_EXTENDED_HASH + assert mock_file.previous_data[-1] == TC_CODE_EXTENDED_HASH + assert ( + mock_file.write_data == '{"settings": {"security": {"boot_flash_hash": true}}}' + ) def test_wrong_code_set_new_tc_code(amigo, mocker): diff --git a/tests/shared_mocks.py b/tests/shared_mocks.py index 8f7db967..0ed8bb32 100644 --- a/tests/shared_mocks.py +++ b/tests/shared_mocks.py @@ -10,6 +10,7 @@ class MockFile: def __init__(self, data=b""): self.data = data if isinstance(data, bytes) else data.encode() + self.previous_data = [] self.position = 0 self.write_data = bytearray() self.mode = "rb" @@ -20,8 +21,12 @@ def __init__(self, data=b""): def set_mode(self, mode): self.mode = mode + if self.write_data: + self.previous_data.append(self.write_data) if "b" not in mode: self.write_data = "" + else: + self.write_data = bytearray() def seek(self, pos): self.position = pos