From 18b894c4d6d1288771110917d5f650ab9cd125a0 Mon Sep 17 00:00:00 2001 From: Sivan Grunberg Date: Tue, 19 Sep 2023 16:29:43 +0300 Subject: [PATCH] commit with commit message argparser monkey patching can be sometimes confusing --- agit/main.py | 6 +++++- tests/test_main.py | 14 ++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/agit/main.py b/agit/main.py index 6437a04..8d8fc79 100755 --- a/agit/main.py +++ b/agit/main.py @@ -65,7 +65,9 @@ async def main(): ) parser.add_argument( - "--version", action="store_true", help="Provide ATool's versios." + "--version", + action="store_true", + help="Provide ATool's version.", ) parser.add_argument( @@ -84,6 +86,8 @@ async def main(): args = parser.parse_args() + print(args) + if args.debug: mylogger.setLevel(DEBUG) diff --git a/tests/test_main.py b/tests/test_main.py index 0a1eec3..1487228 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -22,7 +22,7 @@ import pytest from agit.main import main -from unittest.mock import patch, MagicMock +from unittest.mock import patch, MagicMock, AsyncMock from tests import config @@ -37,7 +37,8 @@ async def test_main_with_translate_command( mocked_execute_git.return_value = config.mocked_exec_output mocked_args.return_value = MagicMock( command=["provide", "current", "status", "of", "the", "repo"], - debug=False, + debug=True, + version=False, explain=False, review=False, ) @@ -54,8 +55,9 @@ async def test_main_with_translate_command( mocked_translate.assert_awaited_once_with( "provide current status of the repo", False ) + mocked_is_destructive.assert_called_once_with("git status") - mocked_execute_git.assert_called_once_with(["git", "status"]) + mocked_execute_git.assert_called_once_with("git status") @patch("agit.main.argparse.ArgumentParser.parse_args") @@ -63,7 +65,11 @@ async def test_main_with_translate_command( async def test_main_with_review(mocked_review, mocked_args): # Mocking the return values mocked_args.return_value = MagicMock( - command=[], explain=False, debug=False, review=True + command=[], + explain=False, + debug=False, + review=True, + version=False, ) mocked_review.return_value = "Looks good!"