@@ -170,19 +170,45 @@ def spec(self, info, paths):
170
170
class BaseTestServerNotFound :
171
171
@pytest .fixture
172
172
def servers (self ):
173
- return []
173
+ return [
174
+ SchemaPath .from_dict (
175
+ {"url" : "http://petstore.swagger.io/resource" }
176
+ )
177
+ ]
174
178
175
- @pytest .mark .xfail (
176
- reason = "returns default server" ,
177
- )
178
179
def test_raises (self , finder ):
179
180
method = "get"
180
- full_url = "http://petstore.swagger.io /resource"
181
+ full_url = "http://invalidserver /resource"
181
182
182
183
with pytest .raises (ServerNotFound ):
183
184
finder .find (method , full_url )
184
185
185
186
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
+
186
212
class BaseTestOperationNotFound :
187
213
@pytest .fixture
188
214
def operations (self ):
@@ -290,6 +316,15 @@ def test_raises(self, finder):
290
316
finder .find (method , full_url )
291
317
292
318
319
+ class TestSpecSimpleServerDefaultServer (
320
+ BaseTestDefaultServer ,
321
+ BaseTestSpecServer ,
322
+ BaseTestSimplePath ,
323
+ BaseTestSimpleServer ,
324
+ ):
325
+ pass
326
+
327
+
293
328
class TestSpecSimpleServerServerNotFound (
294
329
BaseTestServerNotFound ,
295
330
BaseTestSpecServer ,
@@ -325,6 +360,15 @@ class TestSpecSimpleServerPathsNotFound(
325
360
pass
326
361
327
362
363
+ class TestOperationSimpleServerDefaultServer (
364
+ BaseTestDefaultServer ,
365
+ BaseTestOperationServer ,
366
+ BaseTestSimplePath ,
367
+ BaseTestSimpleServer ,
368
+ ):
369
+ pass
370
+
371
+
328
372
class TestOperationSimpleServerServerNotFound (
329
373
BaseTestServerNotFound ,
330
374
BaseTestOperationServer ,
@@ -360,6 +404,15 @@ class TestOperationSimpleServerPathsNotFound(
360
404
pass
361
405
362
406
407
+ class TestPathSimpleServerDefaultServer (
408
+ BaseTestDefaultServer ,
409
+ BaseTestPathServer ,
410
+ BaseTestSimplePath ,
411
+ BaseTestSimpleServer ,
412
+ ):
413
+ pass
414
+
415
+
363
416
class TestPathSimpleServerServerNotFound (
364
417
BaseTestServerNotFound ,
365
418
BaseTestPathServer ,
@@ -443,6 +496,15 @@ class TestPathSimpleServerVariablePathValid(
443
496
pass
444
497
445
498
499
+ class TestSpecVariableServerDefaultServer (
500
+ BaseTestDefaultServer ,
501
+ BaseTestSpecServer ,
502
+ BaseTestSimplePath ,
503
+ BaseTestVariableServer ,
504
+ ):
505
+ pass
506
+
507
+
446
508
class TestSpecVariableServerServerNotFound (
447
509
BaseTestServerNotFound ,
448
510
BaseTestSpecServer ,
@@ -478,6 +540,15 @@ class TestSpecVariableServerPathsNotFound(
478
540
pass
479
541
480
542
543
+ class TestOperationVariableServerDefaultServer (
544
+ BaseTestDefaultServer ,
545
+ BaseTestOperationServer ,
546
+ BaseTestSimplePath ,
547
+ BaseTestVariableServer ,
548
+ ):
549
+ pass
550
+
551
+
481
552
class TestOperationVariableServerServerNotFound (
482
553
BaseTestServerNotFound ,
483
554
BaseTestOperationServer ,
@@ -513,6 +584,15 @@ class TestOperationVariableServerPathsNotFound(
513
584
pass
514
585
515
586
587
+ class TestPathVariableServerDefaultServer (
588
+ BaseTestDefaultServer ,
589
+ BaseTestPathServer ,
590
+ BaseTestSimplePath ,
591
+ BaseTestVariableServer ,
592
+ ):
593
+ pass
594
+
595
+
516
596
class TestPathVariableServerServerNotFound (
517
597
BaseTestServerNotFound ,
518
598
BaseTestPathServer ,
0 commit comments