test: mock and assert offer_openrouter_oauth call in no-key test

This commit is contained in:
Paul Gauthier (aider) 2025-03-31 08:50:32 +13:00
parent 5b10af7b1a
commit d2386bc1f6

View file

@ -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
# 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)
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():