Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
prozorro-sale
Aiohttp Swagger
Commits
696c0c88
Commit
696c0c88
authored
May 27, 2021
by
Viacheslav Sukhovieiev
Browse files
feat: ci implementation
parent
95c22494
Pipeline
#22559
failed with stages
in 8 seconds
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
.flake8
0 → 100644
View file @
696c0c88
[flake8]
max-line-length = 120
ignore = D, VNE, E126, E123, E121, W504, W503
\ No newline at end of file
.gitignore
View file @
696c0c88
...
...
@@ -81,6 +81,7 @@ htmlcov/
.tox/
.coverage
.coverage.*
cover-html
.cache
nosetests.xml
coverage.xml
...
...
.gitlab-ci.yml
0 → 100644
View file @
696c0c88
include
:
-
project
:
'
prozorro-sale/ci-build-box'
file
:
'
/template-ci.yml'
stages
:
-
lint
-
build
-
test
-
publish
code-style-check
:
extends
:
.lint-template
build-wheel
:
extends
:
.build-wheel-template
test-unit-pytest
:
stage
:
test
script
:
-
make test-unit-pytest
artifacts
:
paths
:
-
.coverage
publish-wheel
:
extends
:
.publish-wheel-template
publish-coverage-report
:
extends
:
.publish-coverage-report-template
\ No newline at end of file
Makefile
View file @
696c0c88
# Some simple testing tasks (sorry, UNIX only).
CI_COMMIT_REF_NAME
?=
''
cov
:
@
py.test
--cov
=
aiohttp_swagger
--cov-report
=
term
--cov-report
=
html tests
ifeq
($(CI_COMMIT_REF_NAME), master)
EGG_INFO
=
egg_info
--tag-date
else
ifeq
($(shell echo ${CI_COMMIT_REF_NAME} | grep -o "^epic/"), epic/)
EGG_INFO
=
egg_info
--tag-date
--tag-build
=
DEV
else
EGG_INFO
=
endif
clean
:
@
rm
-rf
`
find
.
-name
__pycache__
`
...
...
@@ -23,3 +29,24 @@ clean:
install
:
@
pip
install
-U
pip
@
pip
install
-Ur
requirements-dev.txt
## Run pytest
test-unit-pytest
:
@
pip
install
-r
requirements.txt
-r
requirements-dev.txt
@
pytest
-v
\
-W
ignore::DeprecationWarning
\
--doctest-modules
\
--cov
=
.
\
-o
testpaths
=
"tests"
\
## Build python package
build-wheel
:
@
python3 setup.py
$(EGG_INFO)
sdist bdist_wheel
## Publish python package
publish-wheel
:
twine upload
--skip-existing
dist/
*
## Publish coverage report
publish-coverage
:
coverage report
&&
coverage html
-d
cover-html
aiohttp_swagger/__init__.py
View file @
696c0c88
...
...
@@ -96,9 +96,9 @@ async def setup_swagger(app: web.Application,
with
open
(
join
(
STATIC_PATH
,
"index.html"
),
"r"
)
as
f
:
app
[
"SWAGGER_TEMPLATE_CONTENT"
]
=
(
f
.
read
()
.
replace
(
"##SWAGGER_CONFIG##"
,
f
"
{
api_base_url
.
rstrip
(
'/'
)
}{
_swagger_def_url
}
"
)
.
replace
(
"##STATIC_PATH##"
,
f
"
{
api_base_url
.
rstrip
(
'/'
)
}{
statics_path
}
"
)
.
replace
(
"##SWAGGER_VALIDATOR_URL##"
,
swagger_validator_url
)
.
replace
(
"##SWAGGER_CONFIG##"
,
f
"
{
api_base_url
.
rstrip
(
'/'
)
}{
_swagger_def_url
}
"
)
.
replace
(
"##STATIC_PATH##"
,
f
"
{
api_base_url
.
rstrip
(
'/'
)
}{
statics_path
}
"
)
.
replace
(
"##SWAGGER_VALIDATOR_URL##"
,
swagger_validator_url
)
)
...
...
aiohttp_swagger/helpers/builders.py
View file @
696c0c88
...
...
@@ -86,7 +86,8 @@ async def generate_doc_from_each_end_point(
contact
:
str
=
""
,
template_path
:
str
=
None
,
definitions
:
dict
=
None
,
security_definitions
:
dict
=
None
):
security_definitions
:
dict
=
None
):
# Clean description
_start_desc
=
0
for
i
,
word
in
enumerate
(
description
):
...
...
tests/test_openapi.py
View file @
696c0c88
...
...
@@ -5,7 +5,7 @@ import pytest
import
yaml
from
aiohttp
import
web
from
aiohttp_swagger
import
*
from
aiohttp_swagger
import
setup_swagger
,
swagger_path
async
def
ping
(
request
):
...
...
@@ -218,6 +218,7 @@ async def test_swagger_info(aiohttp_client, loop, swagger_info):
await
setup_swagger
(
app
,
ui_version
=
3
,
swagger_url
=
"/api/v1/doc"
,
description
=
description
,
swagger_info
=
swagger_info
)
client
=
await
aiohttp_client
(
app
)
...
...
tests/test_swagger.py
View file @
696c0c88
...
...
@@ -241,6 +241,7 @@ async def test_swagger_info(aiohttp_client, loop, swagger_info):
description
=
"Test Custom Swagger"
await
setup_swagger
(
app
,
swagger_url
=
"/api/v1/doc"
,
description
=
description
,
swagger_info
=
swagger_info
)
client
=
await
aiohttp_client
(
app
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment