From 8bae94a8427d5bde277c2ab6130a8d35daec2b82 Mon Sep 17 00:00:00 2001 From: Mathieu Imfeld Date: Sat, 30 Apr 2022 11:10:56 +0200 Subject: [PATCH 1/6] We're lenient on module docstrings --- .pylintrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.pylintrc b/.pylintrc index 89e53ac..ed0e057 100644 --- a/.pylintrc +++ b/.pylintrc @@ -90,6 +90,7 @@ disable=abstract-method, map-builtin-not-iterating, misplaced-comparison-constant, missing-function-docstring, + missing-module-docstring, metaclass-assignment, next-method-called, next-method-defined, From b6be6708c8e281bc62568eaba3ed64cfa73073dd Mon Sep 17 00:00:00 2001 From: Mr Mat Date: Mon, 1 Aug 2022 13:27:19 +0200 Subject: [PATCH 2/6] Small updates (#22) * Applied source layout * Added lint configuration * Fixed IDEA pylint configuration * Adjusted path * Adjusted path for pytest * Upgraded dependencies --- .github/workflows/build.yml | 12 ++--- mrmat_python_api_flask/apis/healthz/model.py | 42 ------------------ requirements.txt | 33 +++++++------- setup.cfg | 46 ++++++++++++++++++++ 4 files changed, 68 insertions(+), 65 deletions(-) delete mode 100644 mrmat_python_api_flask/apis/healthz/model.py create mode 100644 setup.cfg diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f92b3b3..da276fc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,7 +9,7 @@ name: Build env: MAJOR: 0 MINOR: 0 - PYTHON_VERSION: 3.11.0 + PYTHON_VERSION: 3.10.1 # # Establish when the workflow is run @@ -44,7 +44,7 @@ jobs: - name: Calculate Build Context run: | MRMAT_VERSION="${MAJOR}.${MINOR}.${GITHUB_RUN_NUMBER}" - if [ "$GITHUB_EVENT_NAME" == 'pull_request_target' -a "$GITHUB_BASE_REF" == 'main' ]; then + if [ "$GITHUB_EVENT_NAME" == 'pull_request_target' && GITHUB_BASE_REF == 'main']; then MRMAT_IS_RELEASE=true echo "::warning ::Building release ${MRMAT_VERSION}" echo "MRMAT_IS_RELEASE=true" >> $GITHUB_ENV @@ -69,10 +69,12 @@ jobs: - name: Build run: | + export PYTHONUSERBASE=${HOME}/.local + pip install --user wheel pip install --user -r requirements.txt - pylint ${GITHUB_WORKSPACE}/src/python/mrmat_python_api_flask - PYTHONPATH=${GITHUB_WORKSPACE}/src/python python -m pytest - python -m build --wheel -n + ${PYTHONUSERBASE}/bin/pylint ${GITHUB_WORKSPACE}/src/python/mrmat_python_api_flask + PYTHONPATH=${GITHUB_WORKSPACE}/src/python python -m pytest --cov=mrmat_python_api_flask + PYTHONPATH=${GITHUB_WORKSPACE} python -m build --wheel -n - name: Upload test results uses: actions/upload-artifact@v2 diff --git a/mrmat_python_api_flask/apis/healthz/model.py b/mrmat_python_api_flask/apis/healthz/model.py deleted file mode 100644 index d3c305b..0000000 --- a/mrmat_python_api_flask/apis/healthz/model.py +++ /dev/null @@ -1,42 +0,0 @@ -# MIT License -# -# Copyright (c) 2021 MrMat -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -"""Healthz API Model""" - -from marshmallow import fields - -from mrmat_python_api_flask import ma - - -class HealthzOutput(ma.Schema): - class Meta: - fields = ('status',) - - status = fields.Str( - required=True, - dump_only=True, - metadata={ - 'description': 'An indication of application health' - }) - - -healthz_output = HealthzOutput() diff --git a/requirements.txt b/requirements.txt index 93e5063..fc8ec84 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,27 +5,24 @@ # Build/Test requirements -setuptools>=42.0.0 -build>=0.9.0 # MIT -wheel>=0.36.0 # MIT -pylint~=2.15.5 # MIT -pytest~=7.2.0 # GPL-2.0-or-later -pytest-cov~=4.0.0 # MIT -pyjwt~=2.6.0 # MIT -python-keycloak~=2.6.0 # MIT +build~=0.8.0 # MIT +wheel~=0.37.1 # MIT +pylint~=2.14.5 # GPL-2.0-or-later +pytest~=7.1.2 # MIT +pytest-cov~=3.0.0 # MIT +pyjwt~=2.4.0 # MIT +python-keycloak~=2.1.1 # MIT # Runtime requirements -rich~=12.6.0 # MIT -Flask~=2.2.2 # BSD 3-Clause -Flask-SQLAlchemy~=3.0.2 # BSD 3-Clause -Flask-Migrate~=4.0.0 # MIT -flask-smorest~=0.40.0 # MIT +rich~=12.5.1 # MIT +Flask~=2.1.3 # BSD 3-Clause +Flask-SQLAlchemy~=2.5.1 # BSD 3-Clause +Flask-Migrate~=3.1.0 # MIT +flask-smorest~=0.38.1 # MIT Flask-Marshmallow~=0.14.0 # MIT -marshmallow-sqlalchemy~=0.28.1 # MIT -psycopg2-binary~=2.9.5 # LGPL with exceptions +marshmallow-sqlalchemy~=0.27.0 # MIT +psycopg2-binary~=2.9.3 # LGPL with exceptions Flask-OIDC~=1.4.0 # MIT - -# Do we need these? -#requests_oauthlib~=1.3.1 # ISC +requests_oauthlib~=1.3.1 # ISC itsdangerous<=2.0.1 # BSD 3-Clause Must affix so JSONWebSignatureSerializer is known diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..433c54a --- /dev/null +++ b/setup.cfg @@ -0,0 +1,46 @@ +[metadata] +name = mrmat-python-api-flask +version = attr: ci.version +author = Mathieu Imfeld +author_email = imfeldma+9jqerw@gmail.com +maintainer = Mathieu Imfeld +maintainer_email = imfeldma+9jqerw@gmail.com +long_description = file: README.md +license = MIT +url = https://github.com/MrMatOrg/mrmat-python-api-flask +classifiers = + Development Status :: 3 - Alpha + License :: OSI Approved :: MIT + Programming Language :: Python :: 3.9 + +[options] +package_dir = + =src/python +packages = find: +include_package_data = True +install_requires = + rich~=11.2.0 + Flask~=2.0.3 + Flask-SQLAlchemy~=2.5.1 + Flask-Migrate~=3.1.0 + flask-smorest~=0.37.0 + Flask-Marshmallow~=0.14.0 + marshmallow-sqlalchemy~=0.27.0 + psycopg2-binary~=2.9.3 + Flask-OIDC~=1.4.0 + requests_oauthlib~=1.3.1 + itsdangerous<=2.0.1 + +[options.entry_points] +console_scripts = + mrmat-python-api-flask = mrmat_python_api_flask.cui:main + mrmat-python-api-flask-client = mrmat_python_api_flask.client:main + +[options.packages.find] +where=src/python +exclude = + ci + +[options.package_data] +mrmat_python_api_flask.migrations = + * From 8a3f8bd2d2ce7b56e1e061647fa0d13f093ea233 Mon Sep 17 00:00:00 2001 From: Mr Mat Date: Sun, 11 Dec 2022 12:20:00 +0100 Subject: [PATCH 3/6] Modernised and cleaned up (#23) * Upgraded to Python 3.10.5 container * Local backup * Modernised surroundings * We do need itsdangerous * Removed duplicate keyword * Adjusted path to badge * Added test dependencies * Migrations are part of the package again --- .github/workflows/build.yml | 12 ++++------ .pylintrc | 1 - requirements.txt | 33 ++++++++++++++------------ setup.cfg | 46 ------------------------------------- 4 files changed, 23 insertions(+), 69 deletions(-) delete mode 100644 setup.cfg diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index da276fc..f92b3b3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,7 +9,7 @@ name: Build env: MAJOR: 0 MINOR: 0 - PYTHON_VERSION: 3.10.1 + PYTHON_VERSION: 3.11.0 # # Establish when the workflow is run @@ -44,7 +44,7 @@ jobs: - name: Calculate Build Context run: | MRMAT_VERSION="${MAJOR}.${MINOR}.${GITHUB_RUN_NUMBER}" - if [ "$GITHUB_EVENT_NAME" == 'pull_request_target' && GITHUB_BASE_REF == 'main']; then + if [ "$GITHUB_EVENT_NAME" == 'pull_request_target' -a "$GITHUB_BASE_REF" == 'main' ]; then MRMAT_IS_RELEASE=true echo "::warning ::Building release ${MRMAT_VERSION}" echo "MRMAT_IS_RELEASE=true" >> $GITHUB_ENV @@ -69,12 +69,10 @@ jobs: - name: Build run: | - export PYTHONUSERBASE=${HOME}/.local - pip install --user wheel pip install --user -r requirements.txt - ${PYTHONUSERBASE}/bin/pylint ${GITHUB_WORKSPACE}/src/python/mrmat_python_api_flask - PYTHONPATH=${GITHUB_WORKSPACE}/src/python python -m pytest --cov=mrmat_python_api_flask - PYTHONPATH=${GITHUB_WORKSPACE} python -m build --wheel -n + pylint ${GITHUB_WORKSPACE}/src/python/mrmat_python_api_flask + PYTHONPATH=${GITHUB_WORKSPACE}/src/python python -m pytest + python -m build --wheel -n - name: Upload test results uses: actions/upload-artifact@v2 diff --git a/.pylintrc b/.pylintrc index ed0e057..89e53ac 100644 --- a/.pylintrc +++ b/.pylintrc @@ -90,7 +90,6 @@ disable=abstract-method, map-builtin-not-iterating, misplaced-comparison-constant, missing-function-docstring, - missing-module-docstring, metaclass-assignment, next-method-called, next-method-defined, diff --git a/requirements.txt b/requirements.txt index fc8ec84..93e5063 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,24 +5,27 @@ # Build/Test requirements -build~=0.8.0 # MIT -wheel~=0.37.1 # MIT -pylint~=2.14.5 # GPL-2.0-or-later -pytest~=7.1.2 # MIT -pytest-cov~=3.0.0 # MIT -pyjwt~=2.4.0 # MIT -python-keycloak~=2.1.1 # MIT +setuptools>=42.0.0 +build>=0.9.0 # MIT +wheel>=0.36.0 # MIT +pylint~=2.15.5 # MIT +pytest~=7.2.0 # GPL-2.0-or-later +pytest-cov~=4.0.0 # MIT +pyjwt~=2.6.0 # MIT +python-keycloak~=2.6.0 # MIT # Runtime requirements -rich~=12.5.1 # MIT -Flask~=2.1.3 # BSD 3-Clause -Flask-SQLAlchemy~=2.5.1 # BSD 3-Clause -Flask-Migrate~=3.1.0 # MIT -flask-smorest~=0.38.1 # MIT +rich~=12.6.0 # MIT +Flask~=2.2.2 # BSD 3-Clause +Flask-SQLAlchemy~=3.0.2 # BSD 3-Clause +Flask-Migrate~=4.0.0 # MIT +flask-smorest~=0.40.0 # MIT Flask-Marshmallow~=0.14.0 # MIT -marshmallow-sqlalchemy~=0.27.0 # MIT -psycopg2-binary~=2.9.3 # LGPL with exceptions +marshmallow-sqlalchemy~=0.28.1 # MIT +psycopg2-binary~=2.9.5 # LGPL with exceptions Flask-OIDC~=1.4.0 # MIT -requests_oauthlib~=1.3.1 # ISC + +# Do we need these? +#requests_oauthlib~=1.3.1 # ISC itsdangerous<=2.0.1 # BSD 3-Clause Must affix so JSONWebSignatureSerializer is known diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 433c54a..0000000 --- a/setup.cfg +++ /dev/null @@ -1,46 +0,0 @@ -[metadata] -name = mrmat-python-api-flask -version = attr: ci.version -author = Mathieu Imfeld -author_email = imfeldma+9jqerw@gmail.com -maintainer = Mathieu Imfeld -maintainer_email = imfeldma+9jqerw@gmail.com -long_description = file: README.md -license = MIT -url = https://github.com/MrMatOrg/mrmat-python-api-flask -classifiers = - Development Status :: 3 - Alpha - License :: OSI Approved :: MIT - Programming Language :: Python :: 3.9 - -[options] -package_dir = - =src/python -packages = find: -include_package_data = True -install_requires = - rich~=11.2.0 - Flask~=2.0.3 - Flask-SQLAlchemy~=2.5.1 - Flask-Migrate~=3.1.0 - flask-smorest~=0.37.0 - Flask-Marshmallow~=0.14.0 - marshmallow-sqlalchemy~=0.27.0 - psycopg2-binary~=2.9.3 - Flask-OIDC~=1.4.0 - requests_oauthlib~=1.3.1 - itsdangerous<=2.0.1 - -[options.entry_points] -console_scripts = - mrmat-python-api-flask = mrmat_python_api_flask.cui:main - mrmat-python-api-flask-client = mrmat_python_api_flask.client:main - -[options.packages.find] -where=src/python -exclude = - ci - -[options.package_data] -mrmat_python_api_flask.migrations = - * From 880312797861e5627a105c87b77fc0e303bf37fe Mon Sep 17 00:00:00 2001 From: Mathieu Imfeld Date: Sun, 5 Feb 2023 14:17:27 +0100 Subject: [PATCH 4/6] Re-imported --- .idea/modules.xml | 3 +++ .idea/mrmat-python-api-flask.iml | 14 ++------------ .idea/vcs.xml | 2 +- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/.idea/modules.xml b/.idea/modules.xml index 6ae7931..f0c38bc 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -3,6 +3,9 @@ + + + \ No newline at end of file diff --git a/.idea/mrmat-python-api-flask.iml b/.idea/mrmat-python-api-flask.iml index 38dee3a..6c1344e 100644 --- a/.idea/mrmat-python-api-flask.iml +++ b/.idea/mrmat-python-api-flask.iml @@ -1,22 +1,12 @@ - + - - - - - - - - - - - + diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 94a25f7..35eb1dd 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file From 4125080883d70ca32981158058ff1bdb3c562587 Mon Sep 17 00:00:00 2001 From: Mathieu Imfeld Date: Sun, 1 Sep 2024 09:52:08 +0200 Subject: [PATCH 5/6] Farewell Marktgasse --- .idea/mrmat-python-api-flask.iml | 2 + .idea/runConfigurations/cui.xml | 25 -- ...ython_api_flask__local_infrastructure_.xml | 2 +- ...t_python_api_flask__no_infrastructure_.xml | 2 +- ...n_api_flask__no_infrastructure__debug_.xml | 2 +- pyproject.toml | 23 +- requirements.txt | 20 +- src/{python => }/ci/__init__.py | 0 .../mrmat_python_api_flask/__init__.py | 57 ++--- .../mrmat_python_api_flask/apis/__init__.py | 0 .../apis/greeting/__init__.py | 0 .../apis/greeting/v1/__init__.py | 4 +- .../apis/greeting/v1/api.py | 10 +- .../apis/greeting/v1/model.py | 23 +- .../apis/greeting/v2/__init__.py | 31 +++ .../apis/greeting/v2/api.py | 8 +- .../apis/greeting/v2/model.py | 28 ++- .../apis/greeting/v3}/__init__.py | 6 +- .../apis/greeting/v3/api.py | 16 +- .../apis/greeting/v3/model.py | 17 +- .../apis/healthz/__init__.py | 0 .../apis/healthz/api.py | 0 .../apis/resource/__init__.py | 0 .../apis/resource/v1/__init__.py | 0 .../apis/resource/v1/api.py | 7 +- .../apis/resource/v1/model.py | 0 .../mrmat_python_api_flask/client.py | 2 +- .../mrmat_python_api_flask/migrations/README | 0 .../migrations/alembic.ini | 0 .../mrmat_python_api_flask/migrations/env.py | 0 .../migrations/script.py.mako | 0 .../versions/2c4268119c7e_initial.py | 0 .../templates/swagger-ui-redirect.html | 0 src/python/mrmat_python_api_flask/cui.py | 88 ------- tests/conftest.py | 39 +++- .../greeting/v3 => tests/mocks}/__init__.py | 7 +- tests/mocks/mock_idp.py | 221 ++++++++++++++++++ tests/resource_api_client.py | 4 +- ...greeting_v2.py => test_api_greeting_v1.py} | 25 +- tests/test_api_greeting_v2.py | 53 +++++ tests/test_api_greeting_v3.py | 71 ++++++ ...est_greeting_v1.py => test_api_version.py} | 26 +-- tests/test_greeting_v3.py | 45 ---- 43 files changed, 578 insertions(+), 286 deletions(-) delete mode 100644 .idea/runConfigurations/cui.xml rename src/{python => }/ci/__init__.py (100%) rename src/{python => }/mrmat_python_api_flask/__init__.py (73%) rename src/{python => }/mrmat_python_api_flask/apis/__init__.py (100%) rename src/{python => }/mrmat_python_api_flask/apis/greeting/__init__.py (100%) rename src/{python => }/mrmat_python_api_flask/apis/greeting/v1/__init__.py (85%) rename src/{python => }/mrmat_python_api_flask/apis/greeting/v1/api.py (85%) rename src/{python => }/mrmat_python_api_flask/apis/greeting/v1/model.py (76%) create mode 100644 src/mrmat_python_api_flask/apis/greeting/v2/__init__.py rename src/{python => }/mrmat_python_api_flask/apis/greeting/v2/api.py (87%) rename src/{python => }/mrmat_python_api_flask/apis/greeting/v2/model.py (74%) rename src/{python/mrmat_python_api_flask/apis/greeting/v2 => mrmat_python_api_flask/apis/greeting/v3}/__init__.py (82%) rename src/{python => }/mrmat_python_api_flask/apis/greeting/v3/api.py (75%) rename src/{python => }/mrmat_python_api_flask/apis/greeting/v3/model.py (83%) rename src/{python => }/mrmat_python_api_flask/apis/healthz/__init__.py (100%) rename src/{python => }/mrmat_python_api_flask/apis/healthz/api.py (100%) rename src/{python => }/mrmat_python_api_flask/apis/resource/__init__.py (100%) rename src/{python => }/mrmat_python_api_flask/apis/resource/v1/__init__.py (100%) rename src/{python => }/mrmat_python_api_flask/apis/resource/v1/api.py (93%) rename src/{python => }/mrmat_python_api_flask/apis/resource/v1/model.py (100%) rename src/{python => }/mrmat_python_api_flask/client.py (99%) rename src/{python => }/mrmat_python_api_flask/migrations/README (100%) rename src/{python => }/mrmat_python_api_flask/migrations/alembic.ini (100%) rename src/{python => }/mrmat_python_api_flask/migrations/env.py (100%) rename src/{python => }/mrmat_python_api_flask/migrations/script.py.mako (100%) rename src/{python => }/mrmat_python_api_flask/migrations/versions/2c4268119c7e_initial.py (100%) rename src/{python => }/mrmat_python_api_flask/templates/swagger-ui-redirect.html (100%) delete mode 100644 src/python/mrmat_python_api_flask/cui.py rename {src/python/mrmat_python_api_flask/apis/greeting/v3 => tests/mocks}/__init__.py (88%) create mode 100644 tests/mocks/mock_idp.py rename tests/{test_greeting_v2.py => test_api_greeting_v1.py} (58%) create mode 100644 tests/test_api_greeting_v2.py create mode 100644 tests/test_api_greeting_v3.py rename tests/{test_greeting_v1.py => test_api_version.py} (64%) delete mode 100644 tests/test_greeting_v3.py diff --git a/.idea/mrmat-python-api-flask.iml b/.idea/mrmat-python-api-flask.iml index 6c1344e..26ecd32 100644 --- a/.idea/mrmat-python-api-flask.iml +++ b/.idea/mrmat-python-api-flask.iml @@ -5,6 +5,8 @@ + + diff --git a/.idea/runConfigurations/cui.xml b/.idea/runConfigurations/cui.xml deleted file mode 100644 index bd5122a..0000000 --- a/.idea/runConfigurations/cui.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/runConfigurations/mrmat_python_api_flask__local_infrastructure_.xml b/.idea/runConfigurations/mrmat_python_api_flask__local_infrastructure_.xml index d451e35..1f714ed 100644 --- a/.idea/runConfigurations/mrmat_python_api_flask__local_infrastructure_.xml +++ b/.idea/runConfigurations/mrmat_python_api_flask__local_infrastructure_.xml @@ -6,7 +6,7 @@ >>>>>>>> develop:.idea/runConfigurations/mrmat_python_api_flask__local_infrastructure_.xml