Skip to content

Paths finder paths order test #221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions tests/unit/templating/test_paths_finders.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,3 +390,53 @@ class TestPathVariableServerValid(
BaseTestVariableValid, BaseTestPathServer,
BaseTestSimplePath, BaseTestVariableServer):
pass


class TestPathsFindersFind(
BaseTestSpecServer, BaseTestSimpleServer):

path_name = '/articles/{slug}/comments'

@pytest.fixture
def operation_2(self):
return Operation('get', '/articles/{slug}/favorite', {}, {})

@pytest.fixture
def operations_2(self, operation_2):
return {
'get': operation_2,
}

@pytest.fixture
def path(self):
return Path('/articles/{slug}/', {})

@pytest.fixture
def path_2(self, operations):
return Path('/articles/{slug}/comments', operations)

@pytest.fixture
def path_3(self, operations_2):
return Path('/articles/{slug}/favorite', operations_2)

@pytest.fixture
def paths(self, path, path_2, path_3):
return {
path.name: path,
path_2.name: path_2,
path_3.name: path_3,
}

def test_paths_order(self, finder, path_2, operation, server):
slug = 'test'
request_uri = '/articles/{0}/comments'.format(slug)
request = MockRequest(
'http://petstore.swagger.io', 'get', request_uri)

result = finder.find(request)

path_result = TemplateResult(path_2.name, {'slug': slug})
server_result = TemplateResult(self.server_url, {})
assert result == (
path_2, operation, server, path_result, server_result,
)