mirror of
https://github.com/ansible/awx.git
synced 2026-03-09 13:39:27 -02:30
Generate schema suitable for comparing for schema changes
This commit is contained in:
committed by
Elijah DeLee
parent
9b992c971e
commit
f737fc066f
6
Makefile
6
Makefile
@@ -338,6 +338,12 @@ pyflakes: reports
|
|||||||
pylint: reports
|
pylint: reports
|
||||||
@(set -o pipefail && $@ | reports/$@.report)
|
@(set -o pipefail && $@ | reports/$@.report)
|
||||||
|
|
||||||
|
genschema: reports
|
||||||
|
@if [ "$(VENV_BASE)" ]; then \
|
||||||
|
. $(VENV_BASE)/awx/bin/activate; \
|
||||||
|
fi; \
|
||||||
|
(set -o pipefail && py.test --genschema awx/conf/tests/functional awx/main/tests/functional/api awx/main/tests/docs --release=$(VERSION_TARGET) | tee reports/$@.report)
|
||||||
|
|
||||||
swagger: reports
|
swagger: reports
|
||||||
@if [ "$(VENV_BASE)" ]; then \
|
@if [ "$(VENV_BASE)" ]; then \
|
||||||
. $(VENV_BASE)/awx/bin/activate; \
|
. $(VENV_BASE)/awx/bin/activate; \
|
||||||
|
|||||||
@@ -15,6 +15,12 @@ from awx.main.tests.factories import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def pytest_addoption(parser):
|
||||||
|
parser.addoption(
|
||||||
|
"--genschema", action="store_true", default=False, help="execute schema validator"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def pytest_configure(config):
|
def pytest_configure(config):
|
||||||
import sys
|
import sys
|
||||||
sys._called_from_test = True
|
sys._called_from_test = True
|
||||||
|
|||||||
@@ -49,7 +49,8 @@ class TestSwaggerGeneration():
|
|||||||
data.update(response.accepted_renderer.get_customizations() or {})
|
data.update(response.accepted_renderer.get_customizations() or {})
|
||||||
|
|
||||||
data['host'] = None
|
data['host'] = None
|
||||||
data['modified'] = datetime.datetime.utcnow().isoformat()
|
if not pytest.config.getoption("--genschema"):
|
||||||
|
data['modified'] = datetime.datetime.utcnow().isoformat()
|
||||||
data['schemes'] = ['https']
|
data['schemes'] = ['https']
|
||||||
data['consumes'] = ['application/json']
|
data['consumes'] = ['application/json']
|
||||||
|
|
||||||
@@ -139,11 +140,14 @@ class TestSwaggerGeneration():
|
|||||||
for param in node[method].get('parameters'):
|
for param in node[method].get('parameters'):
|
||||||
if param['in'] == 'body':
|
if param['in'] == 'body':
|
||||||
node[method]['parameters'].remove(param)
|
node[method]['parameters'].remove(param)
|
||||||
node[method].setdefault('parameters', []).append({
|
if pytest.config.getoption("--genschema"):
|
||||||
'name': 'data',
|
pytest.skip("In schema generator skipping swagger generator", allow_module_level=True)
|
||||||
'in': 'body',
|
else:
|
||||||
'schema': {'example': request_data},
|
node[method].setdefault('parameters', []).append({
|
||||||
})
|
'name': 'data',
|
||||||
|
'in': 'body',
|
||||||
|
'schema': {'example': request_data},
|
||||||
|
})
|
||||||
|
|
||||||
# Build response examples
|
# Build response examples
|
||||||
if resp:
|
if resp:
|
||||||
@@ -168,4 +172,9 @@ class TestSwaggerGeneration():
|
|||||||
'2018-02-01T08:00:00.000000Z',
|
'2018-02-01T08:00:00.000000Z',
|
||||||
data
|
data
|
||||||
)
|
)
|
||||||
|
data = re.sub(
|
||||||
|
'''(\s+"client_id": ")([a-zA-Z0-9]{40})("\,\s*)''',
|
||||||
|
'\\1xxxx\\3',
|
||||||
|
data
|
||||||
|
)
|
||||||
f.write(data)
|
f.write(data)
|
||||||
|
|||||||
Reference in New Issue
Block a user