Skip to content

Commit 1efb92f

Browse files
committed
Paths finder paths order test
1 parent 187b3d6 commit 1efb92f

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

tests/unit/templating/test_paths_finders.py

+50
Original file line numberDiff line numberDiff line change
@@ -390,3 +390,53 @@ class TestPathVariableServerValid(
390390
BaseTestVariableValid, BaseTestPathServer,
391391
BaseTestSimplePath, BaseTestVariableServer):
392392
pass
393+
394+
395+
class TestPathsFindersFind(
396+
BaseTestSpecServer, BaseTestSimpleServer):
397+
398+
path_name = '/articles/{slug}/comments'
399+
400+
@pytest.fixture
401+
def operation_2(self):
402+
return Operation('get', '/articles/{slug}/favorite', {}, {})
403+
404+
@pytest.fixture
405+
def operations_2(self, operation_2):
406+
return {
407+
'get': operation_2,
408+
}
409+
410+
@pytest.fixture
411+
def path(self):
412+
return Path('/articles/{slug}/', {})
413+
414+
@pytest.fixture
415+
def path_2(self, operations):
416+
return Path('/articles/{slug}/comments', operations)
417+
418+
@pytest.fixture
419+
def path_3(self, operations_2):
420+
return Path('/articles/{slug}/favorite', operations_2)
421+
422+
@pytest.fixture
423+
def paths(self, path, path_2, path_3):
424+
return {
425+
path.name: path,
426+
path_2.name: path_2,
427+
path_3.name: path_3,
428+
}
429+
430+
def test_paths_order(self, finder, path_2, operation, server):
431+
slug = 'test'
432+
request_uri = '/articles/{0}/comments'.format(slug)
433+
request = MockRequest(
434+
'http://petstore.swagger.io', 'get', request_uri)
435+
436+
result = finder.find(request)
437+
438+
path_result = TemplateResult(path_2.name, {'slug': slug})
439+
server_result = TemplateResult(self.server_url, {})
440+
assert result == (
441+
path_2, operation, server, path_result, server_result,
442+
)

0 commit comments

Comments
 (0)