@@ -47,11 +47,30 @@ function doGenerate(testCase,StringInputs)
4747            testCase .verifyGreaterThan(strlength(response ),0 );
4848        end 
4949
50-         function  doGenerateUsingSystemPrompt(testCase )
51-             chat =  ollamaChat(testCase .defaultModelName ," You are a helpful assistant" 
50+         function  sendsSystemPrompt(testCase )
51+             import  matlab .unittest .constraints .HasField 
52+             [sendRequestMock ,sendRequestBehaviour ] =  ...
53+                 createMock(testCase , AddedMethods= " sendRequest" 
54+             testCase .assignOutputsWhen( ...
55+                 withAnyInputs(sendRequestBehaviour .sendRequest ),...
56+                 iResponseMessage(" Hello" " This output is unused with Stream=false" 
57+ 
58+             chat =  testCase .constructor(" You are a helpful assistant" 
59+             chat.sendRequestFcn =  @(varargin ) sendRequestMock .sendRequest(varargin{: });
60+ 
5261            response =  testCase .verifyWarningFree(@() generate(chat ," Hi" 
53-             testCase .verifyClass(response ,' string' 
54-             testCase .verifyGreaterThan(strlength(response ),0 );
62+ 
63+             calls =  testCase .getMockHistory(sendRequestMock );
64+ 
65+             testCase .verifySize(calls ,[1 ,1 ]);
66+             sentHistory =  calls.Inputs{2 };
67+             testCase .verifyThat(sentHistory ,HasField(" messages" 
68+             testCase .verifyEqual(sentHistory .messages , ...
69+                 { ...
70+                     struct(role = " system" = " You are a helpful assistant" 
71+                     struct(role = " user" = " Hi" 
72+                 });
73+             testCase .verifyEqual(response ," Hello" 
5574        end 
5675
5776        function  generateOverridesProperties(testCase )
@@ -513,3 +532,13 @@ function queryModels(testCase)
513532            " Input" validMessages   " MaxNumTokens" 0  }},...
514533            " Error" " MATLAB:validators:mustBePositive" 
515534end 
535+ 
536+ function  msg  =  iResponseMessage(txt )
537+ %  minimal structure replacing the real matlab.net.http.ResponseMessage() in our mocks
538+ msg =  struct(...
539+     StatusCode= " OK" 
540+     Body= struct(...
541+         Data= struct(...
542+             message= struct(...
543+                 content= txt ))));
544+ end 
0 commit comments