From d2386bc1f68c925d8fca1e3eb12a307b2da955d2 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Mon, 31 Mar 2025 08:50:32 +1300 Subject: [PATCH] test: mock and assert offer_openrouter_oauth call in no-key test --- tests/basic/test_main.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/basic/test_main.py b/tests/basic/test_main.py index 9fe8a9f21..c50301de9 100644 --- a/tests/basic/test_main.py +++ b/tests/basic/test_main.py @@ -1002,9 +1002,12 @@ class TestMain(TestCase): self.assertIn("gemini", coder.main_model.name.lower()) del os.environ["GEMINI_API_KEY"] - # Test no API keys - result = main(["--exit", "--yes"], input=DummyInput(), output=DummyOutput()) - self.assertEqual(result, 1) + # Test no API keys - should offer OpenRouter OAuth + with patch("aider.onboarding.offer_openrouter_oauth") as mock_offer_oauth: + mock_offer_oauth.return_value = None # Simulate user declining or failure + result = main(["--exit", "--yes"], input=DummyInput(), output=DummyOutput()) + self.assertEqual(result, 1) # Expect failure since no model could be selected + mock_offer_oauth.assert_called_once() def test_model_precedence(self): with GitTemporaryDirectory():