mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-23 05:45:00 +00:00
add test for conf yml
This commit is contained in:
parent
d8e125f552
commit
1654ee422f
2 changed files with 21 additions and 1 deletions
|
@ -270,7 +270,9 @@ def main(args=None, input=None, output=None):
|
||||||
"No OpenAI API key provided. Use --openai-api-key or setx OPENAI_API_KEY."
|
"No OpenAI API key provided. Use --openai-api-key or setx OPENAI_API_KEY."
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
io.tool_error("No OpenAI API key provided. Use --openai-api-key or env OPENAI_API_KEY.")
|
io.tool_error(
|
||||||
|
"No OpenAI API key provided. Use --openai-api-key or export OPENAI_API_KEY."
|
||||||
|
)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
main_model = models.Model(args.model)
|
main_model = models.Model(args.model)
|
||||||
|
|
|
@ -9,6 +9,7 @@ from unittest.mock import patch
|
||||||
from prompt_toolkit.input import DummyInput
|
from prompt_toolkit.input import DummyInput
|
||||||
from prompt_toolkit.output import DummyOutput
|
from prompt_toolkit.output import DummyOutput
|
||||||
|
|
||||||
|
from aider.dump import dump # noqa: F401
|
||||||
from aider.main import main
|
from aider.main import main
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,6 +42,23 @@ class TestMain(TestCase):
|
||||||
main(["--yes", "foo.txt"], input=DummyInput(), output=DummyOutput())
|
main(["--yes", "foo.txt"], input=DummyInput(), output=DummyOutput())
|
||||||
self.assertTrue(os.path.exists("foo.txt"))
|
self.assertTrue(os.path.exists("foo.txt"))
|
||||||
|
|
||||||
|
def test_main_with_git_config_yml(self):
|
||||||
|
subprocess.run(["git", "init"])
|
||||||
|
subprocess.run(["git", "config", "user.email", "dummy@example.com"])
|
||||||
|
subprocess.run(["git", "config", "user.name", "Dummy User"])
|
||||||
|
|
||||||
|
Path(".aider.conf.yml").write_text("no-auto-commits: true\n")
|
||||||
|
with patch("aider.main.Coder.create") as MockCoder:
|
||||||
|
main([], input=DummyInput(), output=DummyOutput())
|
||||||
|
_, kwargs = MockCoder.call_args
|
||||||
|
assert kwargs["auto_commits"] is False
|
||||||
|
|
||||||
|
Path(".aider.conf.yml").write_text("auto-commits: true\n")
|
||||||
|
with patch("aider.main.Coder.create") as MockCoder:
|
||||||
|
main([], input=DummyInput(), output=DummyOutput())
|
||||||
|
_, kwargs = MockCoder.call_args
|
||||||
|
assert kwargs["auto_commits"] is True
|
||||||
|
|
||||||
def test_main_with_empty_git_dir_new_subdir_file(self):
|
def test_main_with_empty_git_dir_new_subdir_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"])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue