@@ -170,19 +170,45 @@ def spec(self, info, paths):
170170class BaseTestServerNotFound :
171171 @pytest .fixture
172172 def servers (self ):
173- return []
173+ return [
174+ SchemaPath .from_dict (
175+ {"url" : "http://petstore.swagger.io/resource" }
176+ )
177+ ]
174178
175- @pytest .mark .xfail (
176- reason = "returns default server" ,
177- )
178179 def test_raises (self , finder ):
179180 method = "get"
180- full_url = "http://petstore.swagger.io /resource"
181+ full_url = "http://invalidserver /resource"
181182
182183 with pytest .raises (ServerNotFound ):
183184 finder .find (method , full_url )
184185
185186
187+ class BaseTestDefaultServer :
188+ @pytest .fixture
189+ def servers (self ):
190+ return []
191+
192+ def test_returns_default_server (self , finder , spec ):
193+ method = "get"
194+ full_url = "http://petstore.swagger.io/resource"
195+
196+ result = finder .find (method , full_url )
197+
198+ path = spec / "paths" / self .path_name
199+ operation = spec / "paths" / self .path_name / method
200+ server = SchemaPath .from_dict ({"url" : "/" })
201+ path_result = TemplateResult (self .path_name , {})
202+ server_result = TemplateResult ("/" , {})
203+ assert result == (
204+ path ,
205+ operation ,
206+ server ,
207+ path_result ,
208+ server_result ,
209+ )
210+
211+
186212class BaseTestOperationNotFound :
187213 @pytest .fixture
188214 def operations (self ):
@@ -290,6 +316,15 @@ def test_raises(self, finder):
290316 finder .find (method , full_url )
291317
292318
319+ class TestSpecSimpleServerDefaultServer (
320+ BaseTestDefaultServer ,
321+ BaseTestSpecServer ,
322+ BaseTestSimplePath ,
323+ BaseTestSimpleServer ,
324+ ):
325+ pass
326+
327+
293328class TestSpecSimpleServerServerNotFound (
294329 BaseTestServerNotFound ,
295330 BaseTestSpecServer ,
@@ -325,6 +360,15 @@ class TestSpecSimpleServerPathsNotFound(
325360 pass
326361
327362
363+ class TestOperationSimpleServerDefaultServer (
364+ BaseTestDefaultServer ,
365+ BaseTestOperationServer ,
366+ BaseTestSimplePath ,
367+ BaseTestSimpleServer ,
368+ ):
369+ pass
370+
371+
328372class TestOperationSimpleServerServerNotFound (
329373 BaseTestServerNotFound ,
330374 BaseTestOperationServer ,
@@ -360,6 +404,15 @@ class TestOperationSimpleServerPathsNotFound(
360404 pass
361405
362406
407+ class TestPathSimpleServerDefaultServer (
408+ BaseTestDefaultServer ,
409+ BaseTestPathServer ,
410+ BaseTestSimplePath ,
411+ BaseTestSimpleServer ,
412+ ):
413+ pass
414+
415+
363416class TestPathSimpleServerServerNotFound (
364417 BaseTestServerNotFound ,
365418 BaseTestPathServer ,
@@ -443,6 +496,15 @@ class TestPathSimpleServerVariablePathValid(
443496 pass
444497
445498
499+ class TestSpecVariableServerDefaultServer (
500+ BaseTestDefaultServer ,
501+ BaseTestSpecServer ,
502+ BaseTestSimplePath ,
503+ BaseTestVariableServer ,
504+ ):
505+ pass
506+
507+
446508class TestSpecVariableServerServerNotFound (
447509 BaseTestServerNotFound ,
448510 BaseTestSpecServer ,
@@ -478,6 +540,15 @@ class TestSpecVariableServerPathsNotFound(
478540 pass
479541
480542
543+ class TestOperationVariableServerDefaultServer (
544+ BaseTestDefaultServer ,
545+ BaseTestOperationServer ,
546+ BaseTestSimplePath ,
547+ BaseTestVariableServer ,
548+ ):
549+ pass
550+
551+
481552class TestOperationVariableServerServerNotFound (
482553 BaseTestServerNotFound ,
483554 BaseTestOperationServer ,
@@ -513,6 +584,15 @@ class TestOperationVariableServerPathsNotFound(
513584 pass
514585
515586
587+ class TestPathVariableServerDefaultServer (
588+ BaseTestDefaultServer ,
589+ BaseTestPathServer ,
590+ BaseTestSimplePath ,
591+ BaseTestVariableServer ,
592+ ):
593+ pass
594+
595+
516596class TestPathVariableServerServerNotFound (
517597 BaseTestServerNotFound ,
518598 BaseTestPathServer ,
0 commit comments