Skip to content

Commit

Permalink
fix: update tests to call run() method
Browse files Browse the repository at this point in the history
These changes update the test cases to call the run() method on the AiCommit instance, ensuring that the tests accurately reflect the current implementation of the AiCommit class.
  • Loading branch information
versun committed Dec 31, 2024
1 parent 86149db commit eb80aa1
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions tests/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def test_help_command(capsys, mock_repo):
"""Test help command output"""
with patch.object(sys, "argv", ["aicmt", "-h"]):
with pytest.raises(SystemExit) as e:
AiCommit(mock_repo)
AiCommit(mock_repo).run()
assert e.value.code == 0

captured = capsys.readouterr()
Expand All @@ -24,7 +24,7 @@ def test_version_command(capsys, mock_repo):
"""Test version command output"""
with patch.object(sys, "argv", ["aicmt", "-v"]):
with pytest.raises(SystemExit) as e:
AiCommit(mock_repo)
AiCommit(mock_repo).run()
assert e.value.code == 0
from aicmt import __version__

Expand All @@ -37,15 +37,16 @@ def test_no_args_without_repo(tmp_path):
os.chdir(tmp_path)
with patch.object(sys, "argv", ["aicmt"]):
with pytest.raises(git.exc.InvalidGitRepositoryError) as exc_info:
AiCommit(tmp_path)
AiCommit(tmp_path).run()
assert str(exc_info.value) == "Not a valid Git repository"


def test_no_config_file(capsys, mock_repo):
def test_no_config_file(capsys, mock_repo, mock_home_dir):
"""Test no configuration file"""
with patch.object(sys, "argv", ["aicmt"]):
with patch("aicmt.config._get_config_paths", return_value=None):
AiCommit(mock_repo)
with pytest.raises(SystemExit) as e:
AiCommit(mock_repo).run()
assert e.value.code == 0
captured = capsys.readouterr()
assert "Please check and update your configuration file." in captured.out

Expand All @@ -54,7 +55,9 @@ def test_auto_create_config(capsys, mock_repo, mock_home_dir):
config_file = mock_home_dir / ".config/aicmt/.aicmtrc"
assert not config_file.exists()
with patch.object(sys, "argv", ["aicmt"]):
AiCommit(mock_repo)
with pytest.raises(SystemExit) as e:
AiCommit(mock_repo).run()
assert e.value.code == 0
#captured = capsys.readouterr()
#assert "Please check and update your configuration file." in captured.out
#assert "Auto created configuration file in" in captured.out
Expand Down

0 comments on commit eb80aa1

Please sign in to comment.