test remove cli hist file

This commit is contained in:
Diogo Sousa
2023-02-02 13:02:37 +00:00
parent 5c96937e4c
commit 42acf57cc2
2 changed files with 29 additions and 0 deletions

View File

@@ -96,3 +96,30 @@ def test_remove_session_file_exception():
os_mock.path.isfile.assert_called_with(local_model.SESSION_FILE_PATH)
os_mock.remove.assert_called_with(local_model.SESSION_FILE_PATH)
def test_remove_cli_history_file():
with patch("openbb_terminal.session.local_model.os") as os_mock:
assert local_model.remove_cli_history_file() is True
os_mock.path.isfile.assert_called_with(local_model.HIST_FILE_PATH)
os_mock.remove.assert_called_with(local_model.HIST_FILE_PATH)
def test_remove_cli_history_file_not_exist():
with patch("openbb_terminal.session.local_model.os") as os_mock:
os_mock.path.isfile.return_value = False
assert local_model.remove_cli_history_file() is True
os_mock.path.isfile.assert_called_with(local_model.HIST_FILE_PATH)
os_mock.remove.assert_not_called()
@pytest.mark.record_stdout
def test_remove_cli_history_file_exception():
with patch("openbb_terminal.session.local_model.os") as os_mock:
os_mock.remove.side_effect = Exception
assert local_model.remove_cli_history_file() is False
os_mock.path.isfile.assert_called_with(local_model.HIST_FILE_PATH)
os_mock.remove.assert_called_with(local_model.HIST_FILE_PATH)

View File

@@ -0,0 +1,2 @@
[red]Failed to remove terminal history file.[/red]