mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 09:14:59 +00:00
tests run on windows now
This commit is contained in:
parent
ae5b4057e8
commit
bbd68097bd
1 changed files with 33 additions and 18 deletions
|
@ -2,11 +2,10 @@ import os
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
from io import StringIO
|
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from prompt_toolkit.input import create_input
|
from prompt_toolkit.input import create_pipe_input
|
||||||
from prompt_toolkit.output import DummyOutput
|
from prompt_toolkit.output import DummyOutput
|
||||||
|
|
||||||
from aider.main import main
|
from aider.main import main
|
||||||
|
@ -28,59 +27,75 @@ class TestMain(TestCase):
|
||||||
self.patcher.stop()
|
self.patcher.stop()
|
||||||
|
|
||||||
def test_main_with_empty_dir_no_files_on_command(self):
|
def test_main_with_empty_dir_no_files_on_command(self):
|
||||||
pipe_input = create_input(StringIO(""))
|
with create_pipe_input() as pipe_input:
|
||||||
|
pipe_input.send_text("/exit\n")
|
||||||
|
try:
|
||||||
main([], input=pipe_input, output=DummyOutput())
|
main([], input=pipe_input, output=DummyOutput())
|
||||||
pipe_input.close()
|
except SystemExit:
|
||||||
|
pass
|
||||||
|
|
||||||
def test_main_with_empty_dir_new_file(self):
|
def test_main_with_empty_dir_new_file(self):
|
||||||
pipe_input = create_input(StringIO(""))
|
with create_pipe_input() as pipe_input:
|
||||||
|
pipe_input.send_text("/exit\n")
|
||||||
|
try:
|
||||||
main(["foo.txt"], input=pipe_input, output=DummyOutput())
|
main(["foo.txt"], input=pipe_input, output=DummyOutput())
|
||||||
pipe_input.close()
|
except SystemExit:
|
||||||
|
pass
|
||||||
self.assertTrue(os.path.exists("foo.txt"))
|
self.assertTrue(os.path.exists("foo.txt"))
|
||||||
|
|
||||||
def test_main_with_empty_git_dir_new_file(self):
|
def test_main_with_empty_git_dir_new_file(self):
|
||||||
subprocess.run(["git", "init"])
|
subprocess.run(["git", "init"])
|
||||||
subprocess.run(["git", "config", "user.email", "dummy@example.com"])
|
subprocess.run(["git", "config", "user.email", "dummy@example.com"])
|
||||||
subprocess.run(["git", "config", "user.name", "Dummy User"])
|
subprocess.run(["git", "config", "user.name", "Dummy User"])
|
||||||
pipe_input = create_input(StringIO(""))
|
with create_pipe_input() as pipe_input:
|
||||||
|
pipe_input.send_text("/exit\n")
|
||||||
|
try:
|
||||||
main(["--yes", "foo.txt"], input=pipe_input, output=DummyOutput())
|
main(["--yes", "foo.txt"], input=pipe_input, output=DummyOutput())
|
||||||
pipe_input.close()
|
except SystemExit:
|
||||||
|
pass
|
||||||
self.assertTrue(os.path.exists("foo.txt"))
|
self.assertTrue(os.path.exists("foo.txt"))
|
||||||
|
|
||||||
def test_main_args(self):
|
def test_main_args(self):
|
||||||
with patch("aider.main.Coder.create") as MockCoder:
|
with patch("aider.main.Coder.create") as MockCoder:
|
||||||
main(["--no-auto-commits"])
|
with create_pipe_input() as pipe_input:
|
||||||
|
main(["--no-auto-commits"], input=pipe_input)
|
||||||
_, kwargs = MockCoder.call_args
|
_, kwargs = MockCoder.call_args
|
||||||
assert kwargs["auto_commits"] is False
|
assert kwargs["auto_commits"] is False
|
||||||
|
|
||||||
with patch("aider.main.Coder.create") as MockCoder:
|
with patch("aider.main.Coder.create") as MockCoder:
|
||||||
main(["--auto-commits"])
|
with create_pipe_input() as pipe_input:
|
||||||
|
main(["--auto-commits"], input=pipe_input)
|
||||||
_, kwargs = MockCoder.call_args
|
_, kwargs = MockCoder.call_args
|
||||||
assert kwargs["auto_commits"] is True
|
assert kwargs["auto_commits"] is True
|
||||||
|
|
||||||
with patch("aider.main.Coder.create") as MockCoder:
|
with patch("aider.main.Coder.create") as MockCoder:
|
||||||
main([])
|
with create_pipe_input() as pipe_input:
|
||||||
|
main([], input=pipe_input)
|
||||||
_, kwargs = MockCoder.call_args
|
_, kwargs = MockCoder.call_args
|
||||||
assert kwargs["dirty_commits"] is True
|
assert kwargs["dirty_commits"] is True
|
||||||
assert kwargs["auto_commits"] is True
|
assert kwargs["auto_commits"] is True
|
||||||
assert kwargs["pretty"] is True
|
assert kwargs["pretty"] is True
|
||||||
|
|
||||||
with patch("aider.main.Coder.create") as MockCoder:
|
with patch("aider.main.Coder.create") as MockCoder:
|
||||||
main(["--no-pretty"])
|
with create_pipe_input() as pipe_input:
|
||||||
|
main(["--no-pretty"], input=pipe_input)
|
||||||
_, kwargs = MockCoder.call_args
|
_, kwargs = MockCoder.call_args
|
||||||
assert kwargs["pretty"] is False
|
assert kwargs["pretty"] is False
|
||||||
|
|
||||||
with patch("aider.main.Coder.create") as MockCoder:
|
with patch("aider.main.Coder.create") as MockCoder:
|
||||||
main(["--pretty"])
|
with create_pipe_input() as pipe_input:
|
||||||
|
main(["--pretty"], input=pipe_input)
|
||||||
_, kwargs = MockCoder.call_args
|
_, kwargs = MockCoder.call_args
|
||||||
assert kwargs["pretty"] is True
|
assert kwargs["pretty"] is True
|
||||||
|
|
||||||
with patch("aider.main.Coder.create") as MockCoder:
|
with patch("aider.main.Coder.create") as MockCoder:
|
||||||
main(["--no-dirty-commits"])
|
with create_pipe_input() as pipe_input:
|
||||||
|
main(["--no-dirty-commits"], input=pipe_input)
|
||||||
_, kwargs = MockCoder.call_args
|
_, kwargs = MockCoder.call_args
|
||||||
assert kwargs["dirty_commits"] is False
|
assert kwargs["dirty_commits"] is False
|
||||||
|
|
||||||
with patch("aider.main.Coder.create") as MockCoder:
|
with patch("aider.main.Coder.create") as MockCoder:
|
||||||
main(["--dirty-commits"])
|
with create_pipe_input() as pipe_input:
|
||||||
|
main(["--dirty-commits"], input=pipe_input)
|
||||||
_, kwargs = MockCoder.call_args
|
_, kwargs = MockCoder.call_args
|
||||||
assert kwargs["dirty_commits"] is True
|
assert kwargs["dirty_commits"] is True
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue