From 9018d543ed4334d045a2cd101650b0dc00c426dc Mon Sep 17 00:00:00 2001 From: Andrew Anglin Date: Fri, 28 Jun 2024 10:58:08 -0400 Subject: [PATCH] Finnished the uint test for Confirm_user_backup() * This unit test was mostly done we just needed to account for the user input and now it does that and it passes --- convert2rhel/unit_tests/main_test.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/convert2rhel/unit_tests/main_test.py b/convert2rhel/unit_tests/main_test.py index 6fa0c00ed9..056c4935a7 100644 --- a/convert2rhel/unit_tests/main_test.py +++ b/convert2rhel/unit_tests/main_test.py @@ -812,7 +812,8 @@ def test_handle_inhibitors_found_exception(monkeypatch, rollback_failures, retur assert ret == return_code -def test_confirm_user_backup(caplog): +@pytest.mark.parametrize("user_input", ["y", "n"]) +def test_confirm_user_backup(caplog, monkeypatch, user_input): message = ( "Convert2RHEL modifies the systems during the analysis and then rolls back these " "changes when the analysis is complete. In rare cases, this rollback can fail. " @@ -820,6 +821,9 @@ def test_confirm_user_backup(caplog): "you can restore from the backup." ) + # Simulate user input + monkeypatch.setattr("builtins.input", lambda _: user_input) + main.confirm_user_backup() assert message in caplog.text