File tree Expand file tree Collapse file tree 3 files changed +41
-3
lines changed
sdk/cognitivelanguage/azure-ai-language-questionanswering
azure/ai/language/questionanswering Expand file tree Collapse file tree 3 files changed +41
-3
lines changed Original file line number Diff line number Diff line change @@ -37,10 +37,9 @@ def _get_positional_body(*args, **kwargs):
3737 """Verify args and kwargs are valid, and then return the positional body, if users passed it in."""
3838 if len (args ) > 1 :
3939 raise TypeError ("There can only be one positional argument, which is the POST body of this request." )
40- if args and "options" in kwargs :
40+ if "options" in kwargs :
4141 raise TypeError (
42- "You have already supplied the request body as a positional parameter, "
43- "you can not supply it as a keyword argument as well."
42+ "The 'options' parameter is positional only."
4443 )
4544 return args [0 ] if args else None
4645
Original file line number Diff line number Diff line change @@ -355,6 +355,19 @@ def test_query_knowledgebase_overload_positional_and_kwarg(self):
355355 client .get_answers ("positional_one" , "positional_two" )
356356 with pytest .raises (TypeError ):
357357 client .get_answers ("positional_options_bag" , options = "options bag by name" )
358+ with pytest .raises (TypeError ):
359+ client .get_answers (
360+ options = {'qnaId' : 15 },
361+ project_name = "hello" ,
362+ deployment_name = 'test'
363+ )
364+ with pytest .raises (TypeError ):
365+ client .get_answers (
366+ {'qnaId' : 15 },
367+ question = 'Why?' ,
368+ project_name = "hello" ,
369+ deployment_name = 'test'
370+ )
358371
359372 def test_query_knowledgebase_question_or_qna_id (self ):
360373 with QuestionAnsweringClient ("http://fake.com" , AzureKeyCredential ("123" )) as client :
Original file line number Diff line number Diff line change @@ -187,3 +187,29 @@ def test_query_text_overload_positional_and_kwarg(self):
187187 client .get_answers_from_text ("positional_one" , "positional_two" )
188188 with pytest .raises (TypeError ):
189189 client .get_answers_from_text ("positional_options_bag" , options = "options bag by name" )
190+
191+ params = AnswersFromTextOptions (
192+ question = "What is the meaning of life?" ,
193+ text_documents = [
194+ TextDocument (
195+ text = "foo" ,
196+ id = "doc1"
197+ ),
198+ TextDocument (
199+ text = "bar" ,
200+ id = "doc2"
201+ )
202+ ],
203+ language = "en"
204+ )
205+ with pytest .raises (TypeError ):
206+ client .get_answers_from_text (options = params )
207+
208+ with pytest .raises (TypeError ):
209+ client .get_answers_from_text (
210+ question = "why?" ,
211+ text_documents = ["foo" , "bar" ],
212+ options = params )
213+
214+ with pytest .raises (TypeError ):
215+ client .get_answers_from_text (params , question = "Why?" )
You can’t perform that action at this time.
0 commit comments