Skip to content

Commit

Permalink
commit with commit message argparser monkey patching can be sometimes…
Browse files Browse the repository at this point in the history
… confusing
  • Loading branch information
sivang committed Sep 19, 2023
1 parent 2ac9d72 commit 18b894c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
6 changes: 5 additions & 1 deletion agit/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -84,6 +86,8 @@ async def main():

args = parser.parse_args()

print(args)

if args.debug:
mylogger.setLevel(DEBUG)

Expand Down
14 changes: 10 additions & 4 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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,
)
Expand All @@ -54,16 +55,21 @@ 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")
@patch("agit.main.review_patch")
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!"

Expand Down

0 comments on commit 18b894c

Please sign in to comment.