forked from loafle/openapi-generator-original
[POSTMAN] Add Samples GitHub workflow (#17412)
* Add Python tests * Add workflow to verify Postman samples * Correct path
This commit is contained in:
32
.github/workflows/samples-postman.yaml
vendored
Normal file
32
.github/workflows/samples-postman.yaml
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
name: Samples Postman
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- samples/schema/postman-collection/python/**
|
||||
- .github/workflows/samples-postman.yaml
|
||||
jobs:
|
||||
build:
|
||||
name: Test Python client
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
sample:
|
||||
# schema
|
||||
- samples/schema/postman-collection
|
||||
python-version:
|
||||
- "3.11"
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install
|
||||
working-directory: ${{ matrix.sample }}
|
||||
run: |
|
||||
pip install -r python/requirements.txt
|
||||
pip install -r python/test-requirements.txt
|
||||
- name: Test
|
||||
working-directory: ${{ matrix.sample }}
|
||||
run: python -m pytest
|
||||
@@ -0,0 +1,3 @@
|
||||
python_dateutil >= 2.5.3
|
||||
setuptools >= 21.0.0
|
||||
pydantic >= 2
|
||||
2
samples/schema/postman-collection/python/setup.cfg
Normal file
2
samples/schema/postman-collection/python/setup.cfg
Normal file
@@ -0,0 +1,2 @@
|
||||
[flake8]
|
||||
max-line-length=99
|
||||
@@ -0,0 +1,3 @@
|
||||
pytest~=7.1.3
|
||||
pytest-cov>=2.8.1
|
||||
pytest-randomly>=3.12.0
|
||||
25
samples/schema/postman-collection/python/test/test_info.py
Normal file
25
samples/schema/postman-collection/python/test/test_info.py
Normal file
@@ -0,0 +1,25 @@
|
||||
"""
|
||||
Testing Postman generator output
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import unittest
|
||||
|
||||
import json
|
||||
|
||||
|
||||
class TestInfo(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
with open('./postman.json', 'r') as file:
|
||||
self.json_data = json.load(file)
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def test_collection_name(self):
|
||||
self.assertEqual(self.json_data['info']['name'], 'Sample project')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,32 @@
|
||||
"""
|
||||
Testing Postman generator output
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import unittest
|
||||
|
||||
import json
|
||||
|
||||
|
||||
class TestParameters(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
with open('./postman.json', 'r') as file:
|
||||
self.json_data = json.load(file)
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def test_request_parameter_description(self):
|
||||
# request url
|
||||
request = self.json_data['item'][2]['item'][1]['item'][0]['request']
|
||||
self.assertEqual(request['url']['raw'], '{{baseUrl}}/users/')
|
||||
# first query parameter
|
||||
self.assertEqual(request['url']['query'][0]['key'], 'pUserId')
|
||||
self.assertEqual(request['url']['query'][0]['value'], '888')
|
||||
self.assertEqual(request['url']['query'][0]['description'], 'Query Id.')
|
||||
self.assertEqual(request['url']['query'][0]['disabled'], False)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user