MCPcopy Create free account
hub / github.com/idank/explainshell / TestAzureRouting

Class TestAzureRouting

tests/extraction/llm/test_openai_provider.py:667–769  ·  view source on GitHub ↗

Azure-prefixed models should route through the OpenAI-compatible provider.

Source from the content-addressed store, hash-verified

665
666
667class TestAzureRouting(unittest.TestCase):
668 """Azure-prefixed models should route through the OpenAI-compatible provider."""
669
670 @patch.dict(
671 "os.environ",
672 {
673 "AZURE_OPENAI_API_KEY": "azure-key",
674 "AZURE_OPENAI_ENDPOINT": "https://example.openai.azure.com",
675 },
676 )
677 @patch("explainshell.extraction.llm.providers.openai.OpenAI")
678 def test_factory_routes_azure_models_to_openai_provider(
679 self, _mock_openai_cls: MagicMock
680 ) -> None:
681 self.assertIsInstance(make_provider("azure/my-deployment"), OpenAIProvider)
682 self.assertIsInstance(
683 make_batch_provider("azure/my-deployment"), OpenAIProvider
684 )
685
686 @patch.dict(
687 "os.environ",
688 {
689 "AZURE_OPENAI_API_KEY": "azure-key",
690 "AZURE_OPENAI_ENDPOINT": "https://example.openai.azure.com",
691 },
692 clear=True,
693 )
694 @patch("explainshell.extraction.llm.providers.openai.OpenAI")
695 def test_call_uses_azure_endpoint_configuration(
696 self, mock_openai_cls: MagicMock
697 ) -> None:
698 response = SimpleNamespace(output_text='{"options":[]}', usage=None)
699 client = MagicMock()
700 client.responses.create.return_value = response
701 mock_openai_cls.return_value = client
702
703 provider = OpenAIProvider("azure/my-deployment")
704 text, usage = provider.call("man page text")
705
706 self.assertEqual(text, '{"options":[]}')
707 self.assertEqual(usage.input_tokens, 0)
708 mock_openai_cls.assert_called_once_with(
709 api_key="azure-key",
710 base_url="https://example.openai.azure.com/openai/v1/",
711 timeout=LLM_TIMEOUT_SECONDS,
712 )
713 client.responses.create.assert_called_once()
714 self.assertEqual(
715 client.responses.create.call_args.kwargs["model"], "my-deployment"
716 )
717
718 @patch.dict(
719 "os.environ",
720 {
721 "AZURE_OPENAI_API_KEY": "azure-key",
722 "AZURE_OPENAI_BASE_URL": "https://example.openai.azure.com/openai/v1",
723 },
724 clear=True,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected