From a22bdd82f293366a144657f0bfb0a2a32cf75819 Mon Sep 17 00:00:00 2001 From: Vassilis Papanastasiou Date: Thu, 27 Jun 2024 17:00:19 +0100 Subject: [PATCH] Adding test for azureChat when deployment and endpoint cannot be found/are not available --- tests/tazureChat.m | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/tazureChat.m b/tests/tazureChat.m index bc26762..e3087e0 100644 --- a/tests/tazureChat.m +++ b/tests/tazureChat.m @@ -170,7 +170,26 @@ function canUseAPIVersions(testCase, APIVersions) response = testCase.verifyWarningFree(@() generate(chat,"How similar is the DNA of a cat and a tiger?")); testCase.verifyClass(response,'string'); testCase.verifyGreaterThan(strlength(response),0); + end + function endpointNotFound(testCase) + % to verify the error, we need to unset the environment variable + % AZURE_OPENAI_ENDPOINT, if given. Use a fixture to restore the + % value on leaving the test point + import matlab.unittest.fixtures.EnvironmentVariableFixture + testCase.applyFixture(EnvironmentVariableFixture("AZURE_OPENAI_ENDPOINT","dummy")); + unsetenv("AZURE_OPENAI_ENDPOINT"); + testCase.verifyError(@()azureChat, "llms:endpointMustBeSpecified"); + end + + function deploymentNotFound(testCase) + % to verify the error, we need to unset the environment variable + % AZURE_OPENAI_DEPLOYMENT, if given. Use a fixture to restore the + % value on leaving the test point + import matlab.unittest.fixtures.EnvironmentVariableFixture + testCase.applyFixture(EnvironmentVariableFixture("AZURE_OPENAI_DEPLOYMENT","dummy")); + unsetenv("AZURE_OPENAI_DEPLOYMENT"); + testCase.verifyError(@()azureChat, "deploymentMustBeSpecified"); end end end