openapi-core/tests/integration/schema/test_link_spec.py

40 lines
1.2 KiB
Python
Raw Normal View History

2021-04-27 21:39:28 +00:00
from __future__ import division
2019-03-08 13:12:11 +00:00
from openapi_core.shortcuts import create_spec
class TestLinkSpec(object):
def test_no_param(self, factory):
spec_dict = factory.spec_from_file("data/v3.0/links.yaml")
spec = create_spec(spec_dict)
2021-04-23 11:36:27 +00:00
resp = spec / 'paths#/status#get#responses#default'
2019-03-08 13:12:11 +00:00
2021-04-23 11:36:27 +00:00
links = resp / 'links'
assert len(links) == 1
2019-03-08 13:12:11 +00:00
2021-04-23 11:36:27 +00:00
link = links / 'noParamLink'
assert link['operationId'] == 'noParOp'
assert 'server' not in link
assert 'requestBody' not in link
assert 'parameters' not in link
2019-03-08 13:12:11 +00:00
def test_param(self, factory):
spec_dict = factory.spec_from_file("data/v3.0/links.yaml")
spec = create_spec(spec_dict)
2021-04-23 11:36:27 +00:00
resp = spec / 'paths#/status/{resourceId}#get#responses#default'
2019-03-08 13:12:11 +00:00
2021-04-23 11:36:27 +00:00
links = resp / 'links'
assert len(links) == 1
2019-03-08 13:12:11 +00:00
2021-04-23 11:36:27 +00:00
link = links / 'paramLink'
assert link['operationId'] == 'paramOp'
assert 'server' not in link
assert link['requestBody'] == 'test'
2019-03-08 13:12:11 +00:00
2021-04-23 11:36:27 +00:00
parameters = link['parameters']
assert len(parameters) == 1
2019-03-08 13:12:11 +00:00
2021-04-23 11:36:27 +00:00
param = parameters['opParam']
2019-03-08 13:12:11 +00:00
assert param == '$request.path.resourceId'