From 7481e8a4833b2cdb1538ce04fbb51afddb484ffe Mon Sep 17 00:00:00 2001 From: Dominik Lenoch Date: Fri, 5 Nov 2021 13:59:20 +0100 Subject: [PATCH 1/8] RM requirements.txt dev_requirements.txt --- dev_requirements.txt | 143 ------------------------------------------- requirements.txt | 4 -- 2 files changed, 147 deletions(-) delete mode 100644 dev_requirements.txt delete mode 100644 requirements.txt diff --git a/dev_requirements.txt b/dev_requirements.txt deleted file mode 100644 index 59d8c44c..00000000 --- a/dev_requirements.txt +++ /dev/null @@ -1,143 +0,0 @@ -alabaster==0.7.12; python_version >= "3.6" -anyio==3.1.0; python_full_version >= "3.6.2" and python_version >= "3.6" -appdirs==1.4.4; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" -appnope==0.1.2; sys_platform == "darwin" and python_version >= "3.7" and platform_system == "Darwin" -argon2-cffi==20.1.0; python_version >= "3.6" -async-generator==1.10; python_full_version >= "3.6.1" and python_version >= "3.6" -atomicwrites==1.4.0; python_version >= "3.6" and python_full_version < "3.0.0" and sys_platform == "win32" and (python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6") or sys_platform == "win32" and python_version >= "3.6" and python_full_version >= "3.4.0" and (python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6") -attrs==20.3.0; python_version >= "3.6" and python_full_version < "3.0.0" and python_version < "4.0" or python_full_version >= "3.5.0" and python_version >= "3.6" and python_version < "4.0" -babel==2.9.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.6" -backcall==0.2.0; python_version >= "3.7" -beautifulsoup4==4.9.3; python_version >= "3.6" -bleach==3.3.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" -certifi==2021.5.30; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" -cffi==1.14.5; python_full_version >= "3.6.1" and python_version >= "3.6" and implementation_name == "pypy" -cfgv==3.3.0; python_full_version >= "3.6.1" -chardet==4.0.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" -click==7.1.2; python_version >= "3.6" and python_full_version < "3.0.0" and python_version < "4.0" or python_full_version >= "3.5.0" and python_version >= "3.6" and python_version < "4.0" -colorama==0.4.4; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0") -coverage==5.5; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0" and python_version < "4") -decorator==5.0.9; python_version >= "3.7" -defusedxml==0.7.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" -distlib==0.3.2; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" -docutils==0.16; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" -entrypoints==0.3; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" -filelock==3.0.12; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" -flake8==3.9.2; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0") -gitdb==4.0.7; python_version >= "3.6" -gitpython==3.1.17; python_version >= "3.6" -identify==2.2.10; python_full_version >= "3.6.1" -idna==2.10; python_full_version >= "3.6.2" and python_version >= "3.6" -imagesize==1.2.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.6" -importlib-metadata==4.5.0; python_version >= "3.6" -importlib-resources==5.1.4; python_version < "3.9" and python_version >= "3.6" -iniconfig==1.1.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" -ipykernel==5.5.5; python_version >= "3.6" -ipython-genutils==0.2.0; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7" -ipython==7.24.1; python_version >= "3.7" -ipywidgets==7.6.3; python_version >= "3.6" -jedi==0.18.0; python_version >= "3.7" -jinja2==2.11.3; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0") -jsonschema==3.2.0; python_version >= "3.6" -jupyter-book==0.11.1; python_version >= "3.6" -jupyter-cache==0.4.2; python_version >= "3.6" -jupyter-client==6.2.0; python_full_version >= "3.6.1" and python_version >= "3.6" -jupyter-core==4.7.1; python_full_version >= "3.6.1" and python_version >= "3.6" -jupyter-server-mathjax==0.2.3; python_version >= "3.6" -jupyter-server==1.8.0; python_version >= "3.6" -jupyter-sphinx==0.3.2; python_version >= "3.6" -jupyterbook-latex==0.3.1; python_version >= "3.6" -jupyterlab-widgets==1.0.0; python_version >= "3.6" -jupytext==1.10.3; python_version >= "3.6" and python_version < "4.0" -latexcodec==2.0.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.6" -linkify-it-py==1.0.1; python_version >= "3.6" -markdown-it-py==0.6.2; python_version >= "3.6" and python_version < "4.0" -markupsafe==2.0.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" -matplotlib-inline==0.1.2; python_version >= "3.7" -mccabe==0.6.1; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" -mdit-py-plugins==0.2.6; python_version >= "3.6" and python_version < "4.0" -mistune==0.8.4; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" -mock==4.0.3; python_version >= "3.6" -mypy-extensions==0.4.3; python_version >= "3.5" -mypy==0.901; python_version >= "3.5" -myst-nb==0.12.3; python_version >= "3.6" -myst-parser==0.13.7; python_version >= "3.6" -nbclient==0.5.3; python_full_version >= "3.6.1" and python_version >= "3.6" -nbconvert==5.6.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" -nbdime==3.1.0; python_version >= "3.6" -nbformat==5.1.3; python_version >= "3.6" and python_version < "4.0" and (python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6") and python_full_version >= "3.6.1" -nest-asyncio==1.5.1; python_full_version >= "3.6.1" and python_version >= "3.6" -nodeenv==1.6.0; python_full_version >= "3.6.1" -notebook==6.4.0; python_version >= "3.6" -packaging==20.9; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" -pandocfilters==1.4.3; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" -parso==0.8.2; python_version >= "3.7" -pathspec==0.8.1; python_version >= "3.5" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.5" -pexpect==4.8.0; sys_platform != "win32" and python_version >= "3.7" -pickleshare==0.7.5; python_version >= "3.7" -pluggy==0.13.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" -pre-commit==2.13.0; python_full_version >= "3.6.1" -prometheus-client==0.11.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.6" -prompt-toolkit==3.0.18; python_full_version >= "3.6.1" and python_version >= "3.7" -ptyprocess==0.7.0; sys_platform != "win32" and python_version >= "3.7" and os_name != "nt" -py==1.10.0; python_full_version >= "3.6.1" and python_version >= "3.6" and implementation_name == "pypy" -pyaml==21.8.3 -pybtex-docutils==1.0.0; python_version >= "3.6" -pybtex==0.24.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.6" -pycodestyle==2.7.0; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" -pycparser==2.20; python_full_version >= "3.6.1" and python_version >= "3.6" and implementation_name == "pypy" -pydata-sphinx-theme==0.6.3; python_version >= "3.6" -pyflakes==2.3.1; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" -pygments==2.9.0; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7" -pyparsing==2.4.7; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.6" -pyrsistent==0.17.3; python_version >= "3.6" -pytest-cov==2.12.1; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0") -pytest==6.2.4; python_version >= "3.6" -python-dateutil==2.8.1; python_full_version >= "3.6.1" and python_version >= "3.6" -pytz==2021.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.6" -pywin32==301; python_version >= "3.6" and python_full_version < "3.0.0" and sys_platform == "win32" or python_full_version >= "3.5.0" and python_version >= "3.6" and sys_platform == "win32" -pywinpty==1.1.1; os_name == "nt" and python_version >= "3.6" -pyyaml==5.4.1; python_full_version >= "3.6.1" and python_version >= "3.5" and (python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.6") and (python_version >= "3.6" and python_full_version < "3.0.0" and python_version < "4.0" or python_version >= "3.6" and python_version < "4.0" and python_full_version >= "3.6.0") -pyzmq==22.1.0; python_full_version >= "3.6.1" and python_version >= "3.6" -requests==2.25.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" -send2trash==1.5.0; python_version >= "3.6" -six==1.16.0; python_full_version >= "3.6.1" and python_version >= "3.6" and (python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.6") -smmap==4.0.0; python_version >= "3.6" -sniffio==1.2.0; python_full_version >= "3.6.2" and python_version >= "3.6" -snowballstemmer==2.1.0; python_version >= "3.6" -soupsieve==2.2.1; python_version >= "3.6" -sphinx-book-theme==0.1.0; python_version >= "3.6" -sphinx-comments==0.0.3; python_version >= "3.6" -sphinx-copybutton==0.3.1; python_version >= "3.6" -sphinx-external-toc==0.2.0; python_version >= "3.6" and python_version < "4.0" -sphinx-panels==0.5.2; python_version >= "3.6" -sphinx-thebe==0.0.8; python_version >= "3.6" -sphinx-togglebutton==0.2.3; python_version >= "3.6" -sphinx==3.5.4; python_version >= "3.6" and python_version < "4.0" -sphinxcontrib-applehelp==1.0.2; python_version >= "3.6" -sphinxcontrib-bibtex==2.2.1; python_version >= "3.6" -sphinxcontrib-devhelp==1.0.2; python_version >= "3.6" -sphinxcontrib-htmlhelp==2.0.0; python_version >= "3.6" -sphinxcontrib-jsmath==1.0.1; python_version >= "3.6" -sphinxcontrib-qthelp==1.0.3; python_version >= "3.6" -sphinxcontrib-serializinghtml==1.1.5; python_version >= "3.6" -sqlalchemy==1.3.24; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.6" -terminado==0.10.0; python_version >= "3.6" -testpath==0.5.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" -toml==0.10.2; python_full_version >= "3.6.1" and python_version >= "3.6" and (python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6") and (python_version >= "3.6" and python_full_version < "3.0.0" and python_version < "4.0" or python_version >= "3.6" and python_version < "4.0" and python_full_version >= "3.3.0") -tornado==6.1; python_full_version >= "3.6.1" and python_version >= "3.6" -tox==3.23.1; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0") -traitlets==5.0.5; python_full_version >= "3.6.1" and python_version >= "3.7" -types-jinja2==0.1.3 -types-markupsafe==0.1.5 -types-pyyaml==0.1.5 -typing-extensions==3.10.0.0; python_version >= "3.5" -uc-micro-py==1.0.1; python_version >= "3.6" -urllib3==1.26.5; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version < "4" and python_version >= "3.6" -virtualenv==20.4.7; python_full_version >= "3.6.1" -wcwidth==0.2.5; python_full_version >= "3.6.1" and python_version >= "3.7" -webencodings==0.5.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" -websocket-client==1.0.1; python_version >= "3.6" -widgetsnbextension==3.5.1; python_version >= "3.6" -yamllint==1.26.1; python_version >= "3.5" -zipp==3.4.1; python_version < "3.9" and python_version >= "3.6" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 129cc092..00000000 --- a/requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -colorama==0.4.4; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0") -jinja2==2.11.3; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0") -markupsafe==2.0.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" -pyyaml==5.4.1; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" From f9cd7b33e43db322caf8b191398254420297e9bf Mon Sep 17 00:00:00 2001 From: Dominik Lenoch Date: Fri, 5 Nov 2021 14:02:37 +0100 Subject: [PATCH 2/8] RM setup.py --- setup.py | 398 ------------------------------------------------------- 1 file changed, 398 deletions(-) delete mode 100755 setup.py diff --git a/setup.py b/setup.py deleted file mode 100755 index 4aee8421..00000000 --- a/setup.py +++ /dev/null @@ -1,398 +0,0 @@ -# -*- coding: utf-8 -*- -from setuptools import setup - -package_dir = \ -{'': 'src'} - -packages = \ -['yacfg', 'yacfg_batch'] - -package_data = \ -{'': ['*'], - 'yacfg': ['profiles/_libs/*', - 'profiles/amq_broker/7.2.0/*', - 'profiles/amq_broker/7.2.0/_modules/bootstrap_xml/*', - 'profiles/amq_broker/7.2.0/cluster/*', - 'profiles/amq_broker/7.2.0/ha/*', - 'profiles/amq_broker/7.2.0/performance/*', - 'profiles/amq_broker/7.2.0/security/gssapi/*', - 'profiles/amq_broker/7.2.0/security/gssapi_ldap/*', - 'profiles/amq_broker/7.2.0/security/ssl/*', - 'profiles/amq_broker/7.2.0/store/jdbc/*', - 'profiles/amq_broker/7.4.0/*', - 'profiles/amq_broker/7.4.0/_modules/bootstrap_xml/*', - 'profiles/amq_broker/7.4.0/_modules/broker_xml/store/*', - 'profiles/amq_broker/7.4.0/cluster/*', - 'profiles/amq_broker/7.4.0/ha/*', - 'profiles/amq_broker/7.4.0/performance/*', - 'profiles/amq_broker/7.4.0/security/gssapi/*', - 'profiles/amq_broker/7.4.0/security/gssapi_ldap/*', - 'profiles/amq_broker/7.4.0/store/jdbc/*', - 'profiles/amq_broker/7.6.0/*', - 'profiles/amq_broker/7.6.0/_modules/bootstrap_xml/*', - 'profiles/amq_broker/7.6.0/_modules/broker_xml/store/*', - 'profiles/amq_broker/7.6.0/cluster/*', - 'profiles/amq_broker/7.6.0/ha/*', - 'profiles/amq_broker/7.6.0/performance/*', - 'profiles/amq_broker/7.6.0/security/gssapi/*', - 'profiles/amq_broker/7.6.0/security/gssapi_ldap/*', - 'profiles/amq_broker/7.6.0/store/jdbc/*', - 'profiles/amq_broker/7.7.0/*', - 'profiles/amq_broker/7.7.0/_modules/bootstrap_xml/*', - 'profiles/amq_broker/7.7.0/_modules/broker_xml/store/*', - 'profiles/amq_broker/7.7.0/cluster/*', - 'profiles/amq_broker/7.7.0/ha/*', - 'profiles/amq_broker/7.7.0/performance/*', - 'profiles/amq_broker/7.7.0/security/gssapi/*', - 'profiles/amq_broker/7.7.0/security/gssapi_ldap/*', - 'profiles/amq_broker/7.7.0/store/jdbc/*', - 'profiles/amq_broker/7.8.0/*', - 'profiles/amq_broker/7.8.0/_modules/bootstrap_xml/*', - 'profiles/amq_broker/7.8.0/_modules/broker_xml/store/*', - 'profiles/amq_broker/7.8.0/cluster/*', - 'profiles/amq_broker/7.8.0/ha/*', - 'profiles/amq_broker/7.8.0/performance/*', - 'profiles/amq_broker/7.8.0/security/gssapi/*', - 'profiles/amq_broker/7.8.0/security/gssapi_ldap/*', - 'profiles/amq_broker/7.8.0/store/jdbc/*', - 'profiles/amq_broker/7.8.1/*', - 'profiles/amq_broker/7.8.1/_modules/bootstrap_xml/*', - 'profiles/amq_broker/7.8.1/_modules/broker_xml/store/*', - 'profiles/amq_broker/7.8.1/cluster/*', - 'profiles/amq_broker/7.8.1/ha/*', - 'profiles/amq_broker/7.8.1/performance/*', - 'profiles/amq_broker/7.8.1/security/gssapi/*', - 'profiles/amq_broker/7.8.1/security/gssapi_ldap/*', - 'profiles/amq_broker/7.8.1/store/jdbc/*', - 'profiles/amq_broker/7.8.2/*', - 'profiles/amq_broker/7.8.2/_modules/bootstrap_xml/*', - 'profiles/amq_broker/7.8.2/_modules/broker_xml/store/*', - 'profiles/amq_broker/7.8.2/cluster/*', - 'profiles/amq_broker/7.8.2/ha/*', - 'profiles/amq_broker/7.8.2/performance/*', - 'profiles/amq_broker/7.8.2/security/gssapi/*', - 'profiles/amq_broker/7.8.2/security/gssapi_ldap/*', - 'profiles/amq_broker/7.8.2/store/jdbc/*', - 'profiles/amq_broker/7.9.0/*', - 'profiles/amq_broker/7.9.0/_modules/bootstrap_xml/*', - 'profiles/amq_broker/7.9.0/_modules/broker_xml/store/*', - 'profiles/amq_broker/7.9.0/cluster/*', - 'profiles/amq_broker/7.9.0/ha/*', - 'profiles/amq_broker/7.9.0/performance/*', - 'profiles/amq_broker/7.9.0/security/gssapi/*', - 'profiles/amq_broker/7.9.0/security/gssapi_ldap/*', - 'profiles/amq_broker/7.9.0/store/jdbc/*', - 'profiles/artemis/2.13.0/*', - 'profiles/artemis/2.13.0/_modules/artemis_profile/*', - 'profiles/artemis/2.13.0/_modules/artemis_profile/performance/*', - 'profiles/artemis/2.13.0/_modules/bootstrap_xml/*', - 'profiles/artemis/2.13.0/_modules/broker_xml/*', - 'profiles/artemis/2.13.0/_modules/broker_xml/acceptors/*', - 'profiles/artemis/2.13.0/_modules/broker_xml/address_settings/*', - 'profiles/artemis/2.13.0/_modules/broker_xml/addresses/*', - 'profiles/artemis/2.13.0/_modules/broker_xml/cluster/*', - 'profiles/artemis/2.13.0/_modules/broker_xml/ha_policy/replication/*', - 'profiles/artemis/2.13.0/_modules/broker_xml/ha_policy/shared_store/*', - 'profiles/artemis/2.13.0/_modules/broker_xml/journal/*', - 'profiles/artemis/2.13.0/_modules/broker_xml/store/*', - 'profiles/artemis/2.13.0/_modules/jolokia_access/*', - 'profiles/artemis/2.13.0/_modules/logging_properties/*', - 'profiles/artemis/2.13.0/_modules/login_config/*', - 'profiles/artemis/2.13.0/_modules/management_xml/*', - 'profiles/artemis/2.13.0/_modules/security/jdk_gssapi/*', - 'profiles/artemis/2.13.0/_modules/users_roles_security/*', - 'profiles/artemis/2.13.0/cluster/*', - 'profiles/artemis/2.13.0/ha/*', - 'profiles/artemis/2.13.0/performance/*', - 'profiles/artemis/2.13.0/security/gssapi/*', - 'profiles/artemis/2.13.0/security/gssapi/ssl_tls/*', - 'profiles/artemis/2.13.0/security/gssapi_ldap/*', - 'profiles/artemis/2.13.0/store/jdbc/*', - 'profiles/artemis/2.14.0/*', - 'profiles/artemis/2.14.0/_modules/artemis_profile/*', - 'profiles/artemis/2.14.0/_modules/artemis_profile/performance/*', - 'profiles/artemis/2.14.0/_modules/bootstrap_xml/*', - 'profiles/artemis/2.14.0/_modules/broker_xml/*', - 'profiles/artemis/2.14.0/_modules/broker_xml/acceptors/*', - 'profiles/artemis/2.14.0/_modules/broker_xml/address_settings/*', - 'profiles/artemis/2.14.0/_modules/broker_xml/addresses/*', - 'profiles/artemis/2.14.0/_modules/broker_xml/cluster/*', - 'profiles/artemis/2.14.0/_modules/broker_xml/ha_policy/replication/*', - 'profiles/artemis/2.14.0/_modules/broker_xml/ha_policy/shared_store/*', - 'profiles/artemis/2.14.0/_modules/broker_xml/journal/*', - 'profiles/artemis/2.14.0/_modules/broker_xml/store/*', - 'profiles/artemis/2.14.0/_modules/jolokia_access/*', - 'profiles/artemis/2.14.0/_modules/logging_properties/*', - 'profiles/artemis/2.14.0/_modules/login_config/*', - 'profiles/artemis/2.14.0/_modules/management_xml/*', - 'profiles/artemis/2.14.0/_modules/security/jdk_gssapi/*', - 'profiles/artemis/2.14.0/_modules/users_roles_security/*', - 'profiles/artemis/2.14.0/cluster/*', - 'profiles/artemis/2.14.0/ha/*', - 'profiles/artemis/2.14.0/performance/*', - 'profiles/artemis/2.14.0/security/gssapi/*', - 'profiles/artemis/2.14.0/security/gssapi/ssl_tls/*', - 'profiles/artemis/2.14.0/security/gssapi_ldap/*', - 'profiles/artemis/2.14.0/store/jdbc/*', - 'profiles/artemis/2.15.0/*', - 'profiles/artemis/2.15.0/_modules/artemis_profile/*', - 'profiles/artemis/2.15.0/_modules/artemis_profile/performance/*', - 'profiles/artemis/2.15.0/_modules/bootstrap_xml/*', - 'profiles/artemis/2.15.0/_modules/broker_xml/*', - 'profiles/artemis/2.15.0/_modules/broker_xml/acceptors/*', - 'profiles/artemis/2.15.0/_modules/broker_xml/address_settings/*', - 'profiles/artemis/2.15.0/_modules/broker_xml/addresses/*', - 'profiles/artemis/2.15.0/_modules/broker_xml/cluster/*', - 'profiles/artemis/2.15.0/_modules/broker_xml/ha_policy/replication/*', - 'profiles/artemis/2.15.0/_modules/broker_xml/ha_policy/shared_store/*', - 'profiles/artemis/2.15.0/_modules/broker_xml/journal/*', - 'profiles/artemis/2.15.0/_modules/broker_xml/store/*', - 'profiles/artemis/2.15.0/_modules/jolokia_access/*', - 'profiles/artemis/2.15.0/_modules/logging_properties/*', - 'profiles/artemis/2.15.0/_modules/login_config/*', - 'profiles/artemis/2.15.0/_modules/management_xml/*', - 'profiles/artemis/2.15.0/_modules/security/jdk_gssapi/*', - 'profiles/artemis/2.15.0/_modules/users_roles_security/*', - 'profiles/artemis/2.15.0/cluster/*', - 'profiles/artemis/2.15.0/ha/*', - 'profiles/artemis/2.15.0/performance/*', - 'profiles/artemis/2.15.0/security/gssapi/*', - 'profiles/artemis/2.15.0/security/gssapi/ssl_tls/*', - 'profiles/artemis/2.15.0/security/gssapi_ldap/*', - 'profiles/artemis/2.15.0/store/jdbc/*', - 'profiles/artemis/2.16.0/*', - 'profiles/artemis/2.16.0/_modules/artemis_profile/*', - 'profiles/artemis/2.16.0/_modules/artemis_profile/performance/*', - 'profiles/artemis/2.16.0/_modules/bootstrap_xml/*', - 'profiles/artemis/2.16.0/_modules/broker_xml/*', - 'profiles/artemis/2.16.0/_modules/broker_xml/acceptors/*', - 'profiles/artemis/2.16.0/_modules/broker_xml/address_settings/*', - 'profiles/artemis/2.16.0/_modules/broker_xml/addresses/*', - 'profiles/artemis/2.16.0/_modules/broker_xml/cluster/*', - 'profiles/artemis/2.16.0/_modules/broker_xml/ha_policy/replication/*', - 'profiles/artemis/2.16.0/_modules/broker_xml/ha_policy/shared_store/*', - 'profiles/artemis/2.16.0/_modules/broker_xml/journal/*', - 'profiles/artemis/2.16.0/_modules/broker_xml/store/*', - 'profiles/artemis/2.16.0/_modules/jolokia_access/*', - 'profiles/artemis/2.16.0/_modules/logging_properties/*', - 'profiles/artemis/2.16.0/_modules/login_config/*', - 'profiles/artemis/2.16.0/_modules/management_xml/*', - 'profiles/artemis/2.16.0/_modules/security/jdk_gssapi/*', - 'profiles/artemis/2.16.0/_modules/users_roles_security/*', - 'profiles/artemis/2.16.0/cluster/*', - 'profiles/artemis/2.16.0/ha/*', - 'profiles/artemis/2.16.0/performance/*', - 'profiles/artemis/2.16.0/security/gssapi/*', - 'profiles/artemis/2.16.0/security/gssapi/ssl_tls/*', - 'profiles/artemis/2.16.0/security/gssapi_ldap/*', - 'profiles/artemis/2.16.0/store/jdbc/*', - 'profiles/artemis/2.17.0/*', - 'profiles/artemis/2.17.0/_modules/artemis_profile/*', - 'profiles/artemis/2.17.0/_modules/artemis_profile/performance/*', - 'profiles/artemis/2.17.0/_modules/bootstrap_xml/*', - 'profiles/artemis/2.17.0/_modules/broker_xml/*', - 'profiles/artemis/2.17.0/_modules/broker_xml/acceptors/*', - 'profiles/artemis/2.17.0/_modules/broker_xml/address_settings/*', - 'profiles/artemis/2.17.0/_modules/broker_xml/addresses/*', - 'profiles/artemis/2.17.0/_modules/broker_xml/cluster/*', - 'profiles/artemis/2.17.0/_modules/broker_xml/ha_policy/replication/*', - 'profiles/artemis/2.17.0/_modules/broker_xml/ha_policy/shared_store/*', - 'profiles/artemis/2.17.0/_modules/broker_xml/journal/*', - 'profiles/artemis/2.17.0/_modules/broker_xml/store/*', - 'profiles/artemis/2.17.0/_modules/jolokia_access/*', - 'profiles/artemis/2.17.0/_modules/logging_properties/*', - 'profiles/artemis/2.17.0/_modules/login_config/*', - 'profiles/artemis/2.17.0/_modules/management_xml/*', - 'profiles/artemis/2.17.0/_modules/security/jdk_gssapi/*', - 'profiles/artemis/2.17.0/_modules/users_roles_security/*', - 'profiles/artemis/2.17.0/cluster/*', - 'profiles/artemis/2.17.0/ha/*', - 'profiles/artemis/2.17.0/performance/*', - 'profiles/artemis/2.17.0/security/gssapi/*', - 'profiles/artemis/2.17.0/security/gssapi/ssl_tls/*', - 'profiles/artemis/2.17.0/security/gssapi_ldap/*', - 'profiles/artemis/2.17.0/store/jdbc/*', - 'profiles/artemis/2.18.0/*', - 'profiles/artemis/2.18.0/_modules/artemis_profile/*', - 'profiles/artemis/2.18.0/_modules/artemis_profile/performance/*', - 'profiles/artemis/2.18.0/_modules/bootstrap_xml/*', - 'profiles/artemis/2.18.0/_modules/broker_xml/*', - 'profiles/artemis/2.18.0/_modules/broker_xml/acceptors/*', - 'profiles/artemis/2.18.0/_modules/broker_xml/address_settings/*', - 'profiles/artemis/2.18.0/_modules/broker_xml/addresses/*', - 'profiles/artemis/2.18.0/_modules/broker_xml/cluster/*', - 'profiles/artemis/2.18.0/_modules/broker_xml/ha_policy/replication/*', - 'profiles/artemis/2.18.0/_modules/broker_xml/ha_policy/shared_store/*', - 'profiles/artemis/2.18.0/_modules/broker_xml/journal/*', - 'profiles/artemis/2.18.0/_modules/broker_xml/security_settings/*', - 'profiles/artemis/2.18.0/_modules/broker_xml/store/*', - 'profiles/artemis/2.18.0/_modules/jolokia_access/*', - 'profiles/artemis/2.18.0/_modules/logging_properties/*', - 'profiles/artemis/2.18.0/_modules/login_config/*', - 'profiles/artemis/2.18.0/_modules/management_xml/*', - 'profiles/artemis/2.18.0/_modules/security/jdk_gssapi/*', - 'profiles/artemis/2.18.0/_modules/users_roles_security/*', - 'profiles/artemis/2.18.0/cluster/*', - 'profiles/artemis/2.18.0/ha/*', - 'profiles/artemis/2.18.0/performance/*', - 'profiles/artemis/2.18.0/security/gssapi/*', - 'profiles/artemis/2.18.0/security/gssapi/ssl_tls/*', - 'profiles/artemis/2.18.0/security/gssapi_ldap/*', - 'profiles/artemis/2.18.0/store/jdbc/*', - 'profiles/artemis/2.5.0/*', - 'profiles/artemis/2.5.0/_modules/artemis_profile/*', - 'profiles/artemis/2.5.0/_modules/artemis_profile/performance/*', - 'profiles/artemis/2.5.0/_modules/bootstrap_xml/*', - 'profiles/artemis/2.5.0/_modules/broker_xml/*', - 'profiles/artemis/2.5.0/_modules/broker_xml/acceptors/*', - 'profiles/artemis/2.5.0/_modules/broker_xml/address_settings/*', - 'profiles/artemis/2.5.0/_modules/broker_xml/addresses/*', - 'profiles/artemis/2.5.0/_modules/broker_xml/cluster/*', - 'profiles/artemis/2.5.0/_modules/broker_xml/ha_policy/replication/*', - 'profiles/artemis/2.5.0/_modules/broker_xml/ha_policy/shared_store/*', - 'profiles/artemis/2.5.0/_modules/broker_xml/journal/*', - 'profiles/artemis/2.5.0/_modules/broker_xml/store/*', - 'profiles/artemis/2.5.0/_modules/jolokia_access/*', - 'profiles/artemis/2.5.0/_modules/logging_properties/*', - 'profiles/artemis/2.5.0/_modules/login_config/*', - 'profiles/artemis/2.5.0/_modules/management_xml/*', - 'profiles/artemis/2.5.0/_modules/security/jdk_gssapi/*', - 'profiles/artemis/2.5.0/_modules/users_roles_security/*', - 'profiles/artemis/2.5.0/cluster/*', - 'profiles/artemis/2.5.0/ha/*', - 'profiles/artemis/2.5.0/performance/*', - 'profiles/artemis/2.5.0/security/gssapi/*', - 'profiles/artemis/2.5.0/store/jdbc/*', - 'profiles/artemis/2.6.0/*', - 'profiles/artemis/2.6.0/_modules/artemis_profile/*', - 'profiles/artemis/2.6.0/_modules/artemis_profile/performance/*', - 'profiles/artemis/2.6.0/_modules/bootstrap_xml/*', - 'profiles/artemis/2.6.0/_modules/broker_xml/*', - 'profiles/artemis/2.6.0/_modules/broker_xml/acceptors/*', - 'profiles/artemis/2.6.0/_modules/broker_xml/address_settings/*', - 'profiles/artemis/2.6.0/_modules/broker_xml/addresses/*', - 'profiles/artemis/2.6.0/_modules/broker_xml/cluster/*', - 'profiles/artemis/2.6.0/_modules/broker_xml/ha_policy/replication/*', - 'profiles/artemis/2.6.0/_modules/broker_xml/ha_policy/shared_store/*', - 'profiles/artemis/2.6.0/_modules/broker_xml/journal/*', - 'profiles/artemis/2.6.0/_modules/broker_xml/store/*', - 'profiles/artemis/2.6.0/_modules/jolokia_access/*', - 'profiles/artemis/2.6.0/_modules/logging_properties/*', - 'profiles/artemis/2.6.0/_modules/login_config/*', - 'profiles/artemis/2.6.0/_modules/management_xml/*', - 'profiles/artemis/2.6.0/_modules/security/jdk_gssapi/*', - 'profiles/artemis/2.6.0/_modules/users_roles_security/*', - 'profiles/artemis/2.6.0/cluster/*', - 'profiles/artemis/2.6.0/ha/*', - 'profiles/artemis/2.6.0/performance/*', - 'profiles/artemis/2.6.0/security/gssapi/*', - 'profiles/artemis/2.6.0/security/gssapi/ssl_tls/*', - 'profiles/artemis/2.6.0/security/gssapi_ldap/*', - 'profiles/artemis/2.6.0/store/jdbc/*', - 'profiles/artemis/2.9.0/*', - 'profiles/artemis/2.9.0/_modules/artemis_profile/*', - 'profiles/artemis/2.9.0/_modules/artemis_profile/performance/*', - 'profiles/artemis/2.9.0/_modules/bootstrap_xml/*', - 'profiles/artemis/2.9.0/_modules/broker_xml/*', - 'profiles/artemis/2.9.0/_modules/broker_xml/acceptors/*', - 'profiles/artemis/2.9.0/_modules/broker_xml/address_settings/*', - 'profiles/artemis/2.9.0/_modules/broker_xml/addresses/*', - 'profiles/artemis/2.9.0/_modules/broker_xml/cluster/*', - 'profiles/artemis/2.9.0/_modules/broker_xml/ha_policy/replication/*', - 'profiles/artemis/2.9.0/_modules/broker_xml/ha_policy/shared_store/*', - 'profiles/artemis/2.9.0/_modules/broker_xml/journal/*', - 'profiles/artemis/2.9.0/_modules/broker_xml/store/*', - 'profiles/artemis/2.9.0/_modules/jolokia_access/*', - 'profiles/artemis/2.9.0/_modules/logging_properties/*', - 'profiles/artemis/2.9.0/_modules/login_config/*', - 'profiles/artemis/2.9.0/_modules/management_xml/*', - 'profiles/artemis/2.9.0/_modules/security/jdk_gssapi/*', - 'profiles/artemis/2.9.0/_modules/users_roles_security/*', - 'profiles/artemis/2.9.0/cluster/*', - 'profiles/artemis/2.9.0/ha/*', - 'profiles/artemis/2.9.0/performance/*', - 'profiles/artemis/2.9.0/security/gssapi/*', - 'profiles/artemis/2.9.0/security/gssapi/ssl_tls/*', - 'profiles/artemis/2.9.0/security/gssapi_ldap/*', - 'profiles/artemis/2.9.0/store/jdbc/*', - 'templates/artemis/2.13.0/*', - 'templates/artemis/2.13.0/modules/broker_xml/*', - 'templates/artemis/2.13.0/modules/broker_xml/ha_policy/*', - 'templates/artemis/2.13.0/modules/broker_xml/security_settings/*', - 'templates/artemis/2.13.0/modules/broker_xml/store/*', - 'templates/artemis/2.14.0/*', - 'templates/artemis/2.14.0/modules/broker_xml/*', - 'templates/artemis/2.14.0/modules/broker_xml/ha_policy/*', - 'templates/artemis/2.14.0/modules/broker_xml/security_settings/*', - 'templates/artemis/2.14.0/modules/broker_xml/store/*', - 'templates/artemis/2.15.0/*', - 'templates/artemis/2.15.0/modules/broker_xml/*', - 'templates/artemis/2.15.0/modules/broker_xml/ha_policy/*', - 'templates/artemis/2.15.0/modules/broker_xml/security_settings/*', - 'templates/artemis/2.15.0/modules/broker_xml/store/*', - 'templates/artemis/2.16.0/*', - 'templates/artemis/2.16.0/modules/broker_xml/*', - 'templates/artemis/2.16.0/modules/broker_xml/ha_policy/*', - 'templates/artemis/2.16.0/modules/broker_xml/security_settings/*', - 'templates/artemis/2.16.0/modules/broker_xml/store/*', - 'templates/artemis/2.17.0/*', - 'templates/artemis/2.17.0/modules/broker_xml/*', - 'templates/artemis/2.17.0/modules/broker_xml/ha_policy/*', - 'templates/artemis/2.17.0/modules/broker_xml/security_settings/*', - 'templates/artemis/2.17.0/modules/broker_xml/store/*', - 'templates/artemis/2.18.0/*', - 'templates/artemis/2.18.0/modules/broker_xml/*', - 'templates/artemis/2.18.0/modules/broker_xml/ha_policy/*', - 'templates/artemis/2.18.0/modules/broker_xml/security_settings/*', - 'templates/artemis/2.18.0/modules/broker_xml/store/*', - 'templates/artemis/2.5.0/*', - 'templates/artemis/2.5.0/modules/broker_xml/*', - 'templates/artemis/2.5.0/modules/broker_xml/ha_policy/*', - 'templates/artemis/2.5.0/modules/broker_xml/security_settings/*', - 'templates/artemis/2.5.0/modules/broker_xml/store/*', - 'templates/artemis/2.6.0/*', - 'templates/artemis/2.6.0/modules/broker_xml/*', - 'templates/artemis/2.6.0/modules/broker_xml/ha_policy/*', - 'templates/artemis/2.6.0/modules/broker_xml/security_settings/*', - 'templates/artemis/2.6.0/modules/broker_xml/store/*', - 'templates/artemis/2.9.0/*', - 'templates/artemis/2.9.0/modules/broker_xml/*', - 'templates/artemis/2.9.0/modules/broker_xml/ha_policy/*', - 'templates/artemis/2.9.0/modules/broker_xml/security_settings/*', - 'templates/artemis/2.9.0/modules/broker_xml/store/*', - 'templates/libs/*', - 'templates/libs/headers/*', - 'templates/libs/licenses/apache-2.0/*']} - -install_requires = \ -['PyYAML==5.4.1', 'jinja2>=1.10.3,<=2.11.3'] - -extras_require = \ -{':python_version < "3.8"': ['importlib-metadata>=4.6.3,<5.0.0'], - 'color_log': ['colorlog>=5.0.1,<6.0.0', 'colorama>=0.4.4,<0.5.0']} - -entry_points = \ -{'console_scripts': ['yacfg = yacfg.yacfg_cli:main', - 'yacfg-batch = yacfg_batch.yacfg_batch_cli:main']} - -setup_kwargs = { - 'name': 'yacfg', - 'version': '0.9.3', - 'description': 'Template based configuration files generator based on jinja2 and yaml.', - 'long_description': '# yacfg - YAML Configurator\n\nThis tool can generate a set of configuration files mainly needed for\nAMQ Broker, but it is not limited to only generating files for one product.\n\nIt has a user facing Command Line Tool for quick and easy command line usage.\nFurthermore, it is possible to use its API in your python code.\n\n## Getting started\n\n* Python 3.5+\n* Python Poetry\n\n### From git\n\n```bash\ngit clone git@github.com:rh-messaging-qe/yacfg.git\npoetry install\nyacfg --help\n```\n\n### From PyPI\n\n```bash\npip install yacfg\nyacfg --help\n```\n\n## User (CLI) guide\n\n```bash\nyacfg --help\n\nyacfg --list-profiles\nyacfg --list-templates\n\n# perform a generation of a default profile\nyacfg --profile artemis/2.5.0/default.yaml.jinja2\n# also save result to [OUTDIR] directory\nyacfg --profile [PROFILE] --output [OUTDIR]\n```\n\n## Customization\n\nQuickest way to customize data is to use hot-variables, basically variables\nthat the profile itself provides for tuning. Next step is to write (modify) custom\nprofile with completely custom values.\nIf that does not satisfy your needs, then a custom template might be required.\n\n### Profile tuning\n\nSimply export tuning values from profile you want to tune and change those you\nneed to change. Then supply the custom tuning file(s) when generating the profile.\n\n```bash\nyacfg --profile [PROFILE] --export-tuning my_values.yaml\nvim my_values.yaml\nyacfg --profile [PROFILE] --tune my_values.yaml\n\n# multiple tuning files can be overlaid\n# they are updated in sequence, only values present are overwritten\nyacfg --profile [PROFILE] --tune my_values.yaml --tune machine_specific.yaml \\\n --tune logging_debug.yaml --output [OUTDIR]\n```\n\n## Custom profiles\n\nWrite your own, or simply export an existing profile and modify that.\n\nYou can export dynamic version with includes of some modules, that would still\n work. Either you can use imports from package, or your own local files.\n\nOr you can export completely rendered profile file without any includes or\nvariables and modify that as you like.\n\n\n```bash\n# export profile with dynamic includes still active jinja2 files\nyacfg --profile [PROFILE] --new-profile my_new_profile.yaml.jinja2\n# export completely generated profile without any jinja2 fields, plain yaml\nyacfg --profile [PROFILE] --new-profile-static my_new_profile.yaml\nvim my_new_profile.yaml\nyacfg --profile my_new_profile.yaml\n```\n\nProfile is just another jinja2 file that enables customization of profile data\n -- that is tuning. Becuase of that we recommend to keep the extension `.yaml.jinja2`\n unless it is static profile withou any jinja2 capabilities, in that case it could\n be named `.yaml`. That way we can run yaml lint against static profiles and verify\n that they are correct.\n\n All profiles have to be used to generate files without any tuning. That means,\n if they are tune-able, they have to contain all default values in `_defaults` section.\n That section is also used for tuning, so any variable in there will be exported as tuning.\n\n## Custom templates\n\nThe last resort is to export a template and modify that. But remember a template,\nor more correctly a template set is a directory containing a set of main\ntemplates that subsequently generate_via_tuning_files a new file.\n\nOf course feel free to write your own templates. Especially when you need to\ngenerate_via_tuning_files files for something that is not packaged.\n\nJust remember for a template set to be identified the directory must contain\na file named \'_template\' and then main templates ending with \'.jinja2\'.\n\n```bash\nyacfg --template [TEMPLATE] --new-template my_new_template\nvim my_new_template/[MAIN_TEMPLATES].jinja2\nyacfg --template my_new_template --profile [PROFILE]\n\n```\n\n## API guide\n\nDirect use of API is to use `generate()` nearly the same as the CLI.\nWith option to use tuning values directly.\n\nTuning data will be overlaid in order of appearance, using python\ndict.update(), so values that will appear later will overwrite previous\nvalues. We recommend that tuning values are always flat, because update\nis not recursive. The same applies for data from tuning files as well\nas the directly provided data.\n\nData application order:\n\n- profile defaults\n- data from tuning files (in order of appearance) `tuning_files_list`\n- data provided directly (in order of appearance) `tuning_data_list`\n\n\n```python\nimport yacfg\n\n# generating only broker.xml config using default values from profile,\n# no tuning, writing output to a target path\nyacfg.generate(\n profile=\'artemis/2.5.0/default.yaml.jinja2\',\n output_filter=[\'broker.xml\'],\n output_path=\'/opt/artemis-2.5.0-i0/etc/\',\n)\n\n# using both files and direct values, and writing generated configs to\n# a target directory\nyacfg.generate(\n profile=\'artemis/2.5.0/default.yaml.jinja2\',\n tuning_files_list=[\n \'my_values.yaml\',\n \'machine_specific.yaml\',\n \'logging_debug.yaml\'\n ],\n tuning_data_list=[\n {\'name\': \'custom name\', \'config\': \'option_a\'},\n {\'address\': \'10.0.0.1\'},\n {\'LOG_LEVEL\': \'debug\'},\n ],\n output_path=\'/opt/artemis-2.5.0-i0/etc/\',\n)\n\n# just get generated data for further processing, using just tuning files\ndata = yacfg.generate(\n profile=\'artemis/2.5.0/default.yaml.jinja2\',\n tuning_files_list=[\n \'my_values.yaml\',\n \'machine_specific.yaml\',\n \'logging_debug.yaml\'\n ],\n)\nprint(data[\'broker.xml\'])\n```\n\n## Batch configurations\n\nIn case you have multiple services to configure in your environment,\nthat you probably will have at some point, there is a tool for that\nas well. The tool is called yacfg-batch. It has only yaml input and\nit uses yacfg to generate configurations as you are already used to.\n\nInput yaml file defines all services you need to generate, what\nprofiles to use, and what tuning to provide to `yacfg`.\nIt allows you to configure defaults and common for services.\n\n### Batch profile file\n\nAs said it is YAML. It has two special sections: `_default` and `_common`.\nAs the name suggests, `_default` values are used when values are not\ndefined per specific section. Where `_common` is added to the values\nof all sections. The important thing here is that `_default` has lower\npriority than `_common` and that has lower priority than specific section\nvalues.\n\nEvery section has 4 values: `profile`, `template`, `tuning_files`,\n and `tuning`. As the name suggests, `profile` defines what generation profile\n to select, and it directly correlates with `yacfg`\'s `--profile`.\n `template` defines what generation template to use\n (overrides one in the profile if defined), and it directly correlates with\n `--template` from `yacfg`. `tuning_files` option is a list of tuning\n files to use, when combining defaults, commons, and specific values,\n tuning_files list is concatenated. Finally `tuning` is a map of\n specific tuning values, correlates with `--opt` of `yacfg`. When combining\n defaults, commons, and specifics, it will be updated over using python\n dict.update() and it will work only on first level, so it is recommended\n to use flat values for tuning only.\n\nExample:\n```yaml\n\n_default:\n profile: artemis/2.5.0/default.yaml.jinja2\n tuning_files:\n - defaults/broker_default.yaml\n\n_common:\n tuning_files:\n - common/security.yaml\n - common/logging.yaml\n tuning_values:\n LOG_LEVEL_ALL: INFO\n\nbrokerA/opt/artemis/etc:\n pass: true\n\nbrokerB/opt/artemis/etc:\n profile: artemis/2.5.0/AIOBasic.yaml.jinja2\n tuning_files:\n - brokerB/queues.yaml\n\n---\n\n_default:\n profile: amq_broker/7.2.0/default.yaml.jinja2\n tuning_files:\n - defaults/amq_broker_default.yaml\n\nbrokerC/opt/amq/etc:\n tuning:\n LOG_LEVEL_ALL: DEBUG\n\n```\n\nAs you can see, `yacfg-batch` supports multiple sections, in single\nbatch profile file, that allows you to generate multiple groups using\nseparated `_default` and `_common` sections for that.\n\n### executing batch\n\nWhen you have defined all tuning files you need, and in the root of this\nbatch configuration you have your batch profile file, you can now simply\nrun `yacfg-batch`:\n\n```bash\n\nyacfg-batch --input [batch_profile_file] --output [output_path]\n```\n\nYou can use multiple input files and all of those will be generated\nconsecutively. In the output path, new subdirectories will be created\nfor every item you configure (every section), section key will be used\nfor that subdirectory. If the section name resembles a path, whole\npath will be created. For example for `brokerA/opt/artemis/etc`\nthe configuration will be generated into\n`[output_path]/brokerA/opt/artemis/etc/`.\n\n## Documentation\nFormatted documentation can be viewed at [rh-messaging-qe.github.io/yacfg/](https://rh-messaging-qe.github.io/yacfg/).\n\n\n## Contributing\n\nIf you find a bug or room for improvement, submit either a ticket or PR.\n\n## Contributors\n\n_Alphabetically ordered_\n\n* Dominik Lenoch (maintainer)\n* Michal Tóth \n* Otavio Piske \n* Sean Davey \n* Zdenek Kraus (author)\n\n## License\n\nCopyright 2018-2021 Red Hat Inc.\n\nLicensed under the Apache License, Version 2.0 (the "License");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an "AS IS" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n## Acknowledgments\n\n* [jinja2](http://jinja.pocoo.org/docs/2.10/) -- awesome templating engine\n* [yaml](http://yaml.org/) -- very convenient user readable format\n* [learn_yaml](https://learnxinyminutes.com/docs/yaml/) -- great YAML cheat sheet\n* [pyyaml](https://github.com/yaml/pyyaml) -- python YAML parser\n* [jq](https://stedolan.github.io/jq/) -- great tool for working with structured data (JSON)\n* [yq](https://yq.readthedocs.io/en/latest/) -- YAML variant of jq\n* [github templates examples](https://github.com/stevemao/github-issue-templates/tree/master/simple) -- Nice set of ISSUE_TEMPLATE.md and PULL_REQUESTS_TEMPLATE.md examples\n* [contributing example](https://gist.github.com/PurpleBooth/b24679402957c63ec426) -- example/template of CONTRIBUTING.md\n* [Fedora Project code-of-conduct](https://docs.fedoraproject.org/en-US/project/code-of-conduct/) -- the inspiration for CODE_OF_CONDUCT.md\n', - 'author': 'Zdenek Kraus', - 'author_email': 'zkraus@redhat.com', - 'maintainer': 'Dominik Lenoch', - 'maintainer_email': 'dlenoch@redhat.com', - 'url': 'https://github.com/rh-messaging-qe/yacfg', - 'package_dir': package_dir, - 'packages': packages, - 'package_data': package_data, - 'install_requires': install_requires, - 'extras_require': extras_require, - 'entry_points': entry_points, - 'python_requires': '>=3.8,<4.0', -} - - -setup(**setup_kwargs) \ No newline at end of file From bd1690f20099b9051f68cb7c195fda497520c6e7 Mon Sep 17 00:00:00 2001 From: Dominik Lenoch Date: Fri, 5 Nov 2021 14:31:58 +0100 Subject: [PATCH 3/8] ADD Black to dev dependency --- poetry.lock | 145 ++++++++++++++++++++++++++++++++++--------------- pyproject.toml | 1 + 2 files changed, 103 insertions(+), 43 deletions(-) diff --git a/poetry.lock b/poetry.lock index f5fb8394..c8648862 100644 --- a/poetry.lock +++ b/poetry.lock @@ -116,6 +116,33 @@ soupsieve = {version = ">1.2", markers = "python_version >= \"3.0\""} html5lib = ["html5lib"] lxml = ["lxml"] +[[package]] +name = "black" +version = "21.10b0" +description = "The uncompromising code formatter." +category = "dev" +optional = false +python-versions = ">=3.6.2" + +[package.dependencies] +click = ">=7.1.2" +mypy-extensions = ">=0.4.3" +pathspec = ">=0.9.0,<1" +platformdirs = ">=2" +regex = ">=2020.1.8" +tomli = ">=0.2.6,<2.0.0" +typing-extensions = [ + {version = ">=3.10.0.0", markers = "python_version < \"3.10\""}, + {version = "!=3.10.0.1", markers = "python_version >= \"3.10\""}, +] + +[package.extras] +colorama = ["colorama (>=0.4.3)"] +d = ["aiohttp (>=3.7.4)"] +jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] +python2 = ["typed-ast (>=1.4.3)"] +uvloop = ["uvloop (>=0.15.2)"] + [[package]] name = "bleach" version = "4.0.0" @@ -1314,6 +1341,14 @@ python-versions = ">=3.6" cffi = {version = "*", markers = "implementation_name == \"pypy\""} py = {version = "*", markers = "implementation_name == \"pypy\""} +[[package]] +name = "regex" +version = "2021.11.2" +description = "Alternative regular expression module, to replace re." +category = "dev" +optional = false +python-versions = "*" + [[package]] name = "requests" version = "2.26.0" @@ -1820,6 +1855,14 @@ category = "dev" optional = false python-versions = "*" +[[package]] +name = "typing-extensions" +version = "3.10.0.2" +description = "Backported and Experimental Type Hints for Python 3.5+" +category = "dev" +optional = false +python-versions = "*" + [[package]] name = "uc-micro-py" version = "1.0.1" @@ -1932,7 +1975,7 @@ color_log = ["colorama", "colorlog"] [metadata] lock-version = "1.1" python-versions = "^3.8" -content-hash = "25ea989ceaef6cb57faec472ac346f5639b7d6ee021bc3812000cd282407895e" +content-hash = "4c8e9f544744854afe020a0456ac46d74f1029e75328e0f911421adde3818cdc" [metadata.files] alabaster = [ @@ -1996,6 +2039,10 @@ beautifulsoup4 = [ {file = "beautifulsoup4-4.9.3-py3-none-any.whl", hash = "sha256:fff47e031e34ec82bf17e00da8f592fe7de69aeea38be00523c04623c04fb666"}, {file = "beautifulsoup4-4.9.3.tar.gz", hash = "sha256:84729e322ad1d5b4d25f805bfa05b902dd96450f43842c4e99067d5e1369eb25"}, ] +black = [ + {file = "black-21.10b0-py3-none-any.whl", hash = "sha256:6eb7448da9143ee65b856a5f3676b7dda98ad9abe0f87fce8c59291f15e82a5b"}, + {file = "black-21.10b0.tar.gz", hash = "sha256:a9952229092e325fe5f3dae56d81f639b23f7131eb840781947e4b2886030f33"}, +] bleach = [ {file = "bleach-4.0.0-py2.py3-none-any.whl", hash = "sha256:c1685a132e6a9a38bf93752e5faab33a9517a6c0bb2f37b785e47bf253bdb51d"}, {file = "bleach-4.0.0.tar.gz", hash = "sha256:ffa9221c6ac29399cc50fcc33473366edd0cf8d5e2cbbbb63296dc327fb67cc8"}, @@ -2366,28 +2413,12 @@ markdown-it-py = [ {file = "markdown_it_py-1.1.0-py3-none-any.whl", hash = "sha256:98080fc0bc34c4f2bcf0846a096a9429acbd9d5d8e67ed34026c03c61c464389"}, ] markupsafe = [ - {file = "MarkupSafe-2.0.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:d8446c54dc28c01e5a2dbac5a25f071f6653e6e40f3a8818e8b45d790fe6ef53"}, - {file = "MarkupSafe-2.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:36bc903cbb393720fad60fc28c10de6acf10dc6cc883f3e24ee4012371399a38"}, - {file = "MarkupSafe-2.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2d7d807855b419fc2ed3e631034685db6079889a1f01d5d9dac950f764da3dad"}, - {file = "MarkupSafe-2.0.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:add36cb2dbb8b736611303cd3bfcee00afd96471b09cda130da3581cbdc56a6d"}, - {file = "MarkupSafe-2.0.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:168cd0a3642de83558a5153c8bd34f175a9a6e7f6dc6384b9655d2697312a646"}, - {file = "MarkupSafe-2.0.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:4dc8f9fb58f7364b63fd9f85013b780ef83c11857ae79f2feda41e270468dd9b"}, - {file = "MarkupSafe-2.0.1-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:20dca64a3ef2d6e4d5d615a3fd418ad3bde77a47ec8a23d984a12b5b4c74491a"}, - {file = "MarkupSafe-2.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:cdfba22ea2f0029c9261a4bd07e830a8da012291fbe44dc794e488b6c9bb353a"}, - {file = "MarkupSafe-2.0.1-cp310-cp310-win32.whl", hash = "sha256:99df47edb6bda1249d3e80fdabb1dab8c08ef3975f69aed437cb69d0a5de1e28"}, - {file = "MarkupSafe-2.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:e0f138900af21926a02425cf736db95be9f4af72ba1bb21453432a07f6082134"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:f9081981fe268bd86831e5c75f7de206ef275defcb82bc70740ae6dc507aee51"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:0955295dd5eec6cb6cc2fe1698f4c6d84af2e92de33fbcac4111913cd100a6ff"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:0446679737af14f45767963a1a9ef7620189912317d095f2d9ffa183a4d25d2b"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux2010_i686.whl", hash = "sha256:f826e31d18b516f653fe296d967d700fddad5901ae07c622bb3705955e1faa94"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:fa130dd50c57d53368c9d59395cb5526eda596d3ffe36666cd81a44d56e48872"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:905fec760bd2fa1388bb5b489ee8ee5f7291d692638ea5f67982d968366bef9f"}, - {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bf5d821ffabf0ef3533c39c518f3357b171a1651c1ff6827325e4489b0e46c3c"}, - {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:0d4b31cc67ab36e3392bbf3862cfbadac3db12bdd8b02a2731f509ed5b829724"}, - {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:baa1a4e8f868845af802979fcdbf0bb11f94f1cb7ced4c4b8a351bb60d108145"}, - {file = "MarkupSafe-2.0.1-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:deb993cacb280823246a026e3b2d81c493c53de6acfd5e6bfe31ab3402bb37dd"}, - {file = "MarkupSafe-2.0.1-cp36-cp36m-musllinux_1_1_i686.whl", hash = "sha256:63f3268ba69ace99cab4e3e3b5840b03340efed0948ab8f78d2fd87ee5442a4f"}, - {file = "MarkupSafe-2.0.1-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:8d206346619592c6200148b01a2142798c989edcb9c896f9ac9722a99d4e77e6"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-win32.whl", hash = "sha256:6c4ca60fa24e85fe25b912b01e62cb969d69a23a5d5867682dd3e80b5b02581d"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-win_amd64.whl", hash = "sha256:b2f4bf27480f5e5e8ce285a8c8fd176c0b03e93dcc6646477d4630e83440c6a9"}, {file = "MarkupSafe-2.0.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:0717a7390a68be14b8c793ba258e075c6f4ca819f15edfc2a3a027c823718567"}, @@ -2396,27 +2427,14 @@ markupsafe = [ {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux2010_i686.whl", hash = "sha256:d7f9850398e85aba693bb640262d3611788b1f29a79f0c93c565694658f4071f"}, {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:6a7fae0dd14cf60ad5ff42baa2e95727c3d81ded453457771d02b7d2b3f9c0c2"}, {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:b7f2d075102dc8c794cbde1947378051c4e5180d52d276987b8d28a3bd58c17d"}, - {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e9936f0b261d4df76ad22f8fee3ae83b60d7c3e871292cd42f40b81b70afae85"}, - {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:2a7d351cbd8cfeb19ca00de495e224dea7e7d919659c2841bbb7f420ad03e2d6"}, - {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:60bf42e36abfaf9aff1f50f52644b336d4f0a3fd6d8a60ca0d054ac9f713a864"}, - {file = "MarkupSafe-2.0.1-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:d6c7ebd4e944c85e2c3421e612a7057a2f48d478d79e61800d81468a8d842207"}, - {file = "MarkupSafe-2.0.1-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:f0567c4dc99f264f49fe27da5f735f414c4e7e7dd850cfd8e69f0862d7c74ea9"}, - {file = "MarkupSafe-2.0.1-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:89c687013cb1cd489a0f0ac24febe8c7a666e6e221b783e53ac50ebf68e45d86"}, {file = "MarkupSafe-2.0.1-cp37-cp37m-win32.whl", hash = "sha256:a30e67a65b53ea0a5e62fe23682cfe22712e01f453b95233b25502f7c61cb415"}, {file = "MarkupSafe-2.0.1-cp37-cp37m-win_amd64.whl", hash = "sha256:611d1ad9a4288cf3e3c16014564df047fe08410e628f89805e475368bd304914"}, - {file = "MarkupSafe-2.0.1-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:5bb28c636d87e840583ee3adeb78172efc47c8b26127267f54a9c0ec251d41a9"}, {file = "MarkupSafe-2.0.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:be98f628055368795d818ebf93da628541e10b75b41c559fdf36d104c5787066"}, {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux1_i686.whl", hash = "sha256:1d609f577dc6e1aa17d746f8bd3c31aa4d258f4070d61b2aa5c4166c1539de35"}, {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:7d91275b0245b1da4d4cfa07e0faedd5b0812efc15b702576d103293e252af1b"}, {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux2010_i686.whl", hash = "sha256:01a9b8ea66f1658938f65b93a85ebe8bc016e6769611be228d797c9d998dd298"}, {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:47ab1e7b91c098ab893b828deafa1203de86d0bc6ab587b160f78fe6c4011f75"}, {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:97383d78eb34da7e1fa37dd273c20ad4320929af65d156e35a5e2d89566d9dfb"}, - {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6fcf051089389abe060c9cd7caa212c707e58153afa2c649f00346ce6d260f1b"}, - {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:5855f8438a7d1d458206a2466bf82b0f104a3724bf96a1c781ab731e4201731a"}, - {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:3dd007d54ee88b46be476e293f48c85048603f5f516008bee124ddd891398ed6"}, - {file = "MarkupSafe-2.0.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:aca6377c0cb8a8253e493c6b451565ac77e98c2951c45f913e0b52facdcff83f"}, - {file = "MarkupSafe-2.0.1-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:04635854b943835a6ea959e948d19dcd311762c5c0c6e1f0e16ee57022669194"}, - {file = "MarkupSafe-2.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:6300b8454aa6930a24b9618fbb54b5a68135092bc666f7b06901f897fa5c2fee"}, {file = "MarkupSafe-2.0.1-cp38-cp38-win32.whl", hash = "sha256:023cb26ec21ece8dc3907c0e8320058b2e0cb3c55cf9564da612bc325bed5e64"}, {file = "MarkupSafe-2.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:984d76483eb32f1bcb536dc27e4ad56bba4baa70be32fa87152832cdd9db0833"}, {file = "MarkupSafe-2.0.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:2ef54abee730b502252bcdf31b10dacb0a416229b72c18b19e24a4509f273d26"}, @@ -2426,12 +2444,6 @@ markupsafe = [ {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux2010_i686.whl", hash = "sha256:4efca8f86c54b22348a5467704e3fec767b2db12fc39c6d963168ab1d3fc9135"}, {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux2010_x86_64.whl", hash = "sha256:ab3ef638ace319fa26553db0624c4699e31a28bb2a835c5faca8f8acf6a5a902"}, {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:f8ba0e8349a38d3001fae7eadded3f6606f0da5d748ee53cc1dab1d6527b9509"}, - {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c47adbc92fc1bb2b3274c4b3a43ae0e4573d9fbff4f54cd484555edbf030baf1"}, - {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:37205cac2a79194e3750b0af2a5720d95f786a55ce7df90c3af697bfa100eaac"}, - {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:1f2ade76b9903f39aa442b4aadd2177decb66525062db244b35d71d0ee8599b6"}, - {file = "MarkupSafe-2.0.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:4296f2b1ce8c86a6aea78613c34bb1a672ea0e3de9c6ba08a960efe0b0a09047"}, - {file = "MarkupSafe-2.0.1-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:9f02365d4e99430a12647f09b6cc8bab61a6564363f313126f775eb4f6ef798e"}, - {file = "MarkupSafe-2.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:5b6d930f030f8ed98e3e6c98ffa0652bdb82601e7a016ec2ab5d7ff23baa78d1"}, {file = "MarkupSafe-2.0.1-cp39-cp39-win32.whl", hash = "sha256:10f82115e21dc0dfec9ab5c0223652f7197feb168c940f3ef61563fc2d6beb74"}, {file = "MarkupSafe-2.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:693ce3f9e70a6cf7d2fb9e6c9d8b204b6b39897a2c4a1aa65728d5ac97dcc1d8"}, {file = "MarkupSafe-2.0.1.tar.gz", hash = "sha256:594c67807fb16238b30c44bdf74f36c02cdf22d1c8cda91ef8a0ed8dabf5620a"}, @@ -2698,13 +2710,6 @@ pyyaml = [ {file = "PyYAML-6.0.tar.gz", hash = "sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2"}, ] pyzmq = [ - {file = "pyzmq-22.2.1-cp310-cp310-macosx_10_15_universal2.whl", hash = "sha256:d60a407663b7c2af781ab7f49d94a3d379dd148bb69ea8d9dd5bc69adf18097c"}, - {file = "pyzmq-22.2.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:631f932fb1fa4b76f31adf976f8056519bc6208a3c24c184581c3dd5be15066e"}, - {file = "pyzmq-22.2.1-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:0471d634c7fe48ff7d3849798da6c16afc71676dd890b5ae08eb1efe735c6fec"}, - {file = "pyzmq-22.2.1-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:f520e9fee5d7a2e09b051d924f85b977c6b4e224e56c0551c3c241bbeeb0ad8d"}, - {file = "pyzmq-22.2.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c1b6619ceb33a8907f1cb82ff8afc8a133e7a5f16df29528e919734718600426"}, - {file = "pyzmq-22.2.1-cp310-cp310-win32.whl", hash = "sha256:31c5dfb6df5148789835128768c01bf6402eb753d06f524f12f6786caf96fb44"}, - {file = "pyzmq-22.2.1-cp310-cp310-win_amd64.whl", hash = "sha256:4842a8263cbaba6fce401bbe4e2b125321c401a01714e42624dabc554bfc2629"}, {file = "pyzmq-22.2.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:b921758f8b5098faa85f341bbdd5e36d5339de5e9032ca2b07d8c8e7bec5069b"}, {file = "pyzmq-22.2.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:240b83b3a8175b2f616f80092cbb019fcd5c18598f78ffc6aa0ae9034b300f14"}, {file = "pyzmq-22.2.1-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:da7f7f3bb08bcf59a6b60b4e53dd8f08bb00c9e61045319d825a906dbb3c8fb7"}, @@ -2736,6 +2741,57 @@ pyzmq = [ {file = "pyzmq-22.2.1-pp37-pypy37_pp73-win_amd64.whl", hash = "sha256:b3f57bee62e36be5c97712de32237c5589caee0d1154c2ad01a888accfae20bc"}, {file = "pyzmq-22.2.1.tar.gz", hash = "sha256:6d18c76676771fd891ca8e0e68da0bbfb88e30129835c0ade748016adb3b6242"}, ] +regex = [ + {file = "regex-2021.11.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:897c539f0f3b2c3a715be651322bef2167de1cdc276b3f370ae81a3bda62df71"}, + {file = "regex-2021.11.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:886f459db10c0f9d17c87d6594e77be915f18d343ee138e68d259eb385f044a8"}, + {file = "regex-2021.11.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:075b0fdbaea81afcac5a39a0d1bb91de887dd0d93bf692a5dd69c430e7fc58cb"}, + {file = "regex-2021.11.2-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c6238d30dcff141de076344cf7f52468de61729c2f70d776fce12f55fe8df790"}, + {file = "regex-2021.11.2-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7fab29411d75c2eb48070020a40f80255936d7c31357b086e5931c107d48306e"}, + {file = "regex-2021.11.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f0148988af0182a0a4e5020e7c168014f2c55a16d11179610f7883dd48ac0ebe"}, + {file = "regex-2021.11.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:be30cd315db0168063a1755fa20a31119da91afa51da2907553493516e165640"}, + {file = "regex-2021.11.2-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:e9cec3a62d146e8e122d159ab93ac32c988e2ec0dcb1e18e9e53ff2da4fbd30c"}, + {file = "regex-2021.11.2-cp310-cp310-win32.whl", hash = "sha256:41c66bd6750237a8ed23028a6c9173dc0c92dc24c473e771d3bfb9ee817700c3"}, + {file = "regex-2021.11.2-cp310-cp310-win_amd64.whl", hash = "sha256:0075fe4e2c2720a685fef0f863edd67740ff78c342cf20b2a79bc19388edf5db"}, + {file = "regex-2021.11.2-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:0ed3465acf8c7c10aa2e0f3d9671da410ead63b38a77283ef464cbb64275df58"}, + {file = "regex-2021.11.2-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ab1fea8832976ad0bebb11f652b692c328043057d35e9ebc78ab0a7a30cf9a70"}, + {file = "regex-2021.11.2-cp36-cp36m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:cb1e44d860345ab5d4f533b6c37565a22f403277f44c4d2d5e06c325da959883"}, + {file = "regex-2021.11.2-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9486ebda015913909bc28763c6b92fcc3b5e5a67dee4674bceed112109f5dfb8"}, + {file = "regex-2021.11.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:20605bfad484e1341b2cbfea0708e4b211d233716604846baa54b94821f487cb"}, + {file = "regex-2021.11.2-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f20f9f430c33597887ba9bd76635476928e76cad2981643ca8be277b8e97aa96"}, + {file = "regex-2021.11.2-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:1d85ca137756d62c8138c971453cafe64741adad1f6a7e63a22a5a8abdbd19fa"}, + {file = "regex-2021.11.2-cp36-cp36m-win32.whl", hash = "sha256:af23b9ca9a874ef0ec20e44467b8edd556c37b0f46f93abfa93752ea7c0e8d1e"}, + {file = "regex-2021.11.2-cp36-cp36m-win_amd64.whl", hash = "sha256:070336382ca92c16c45b4066c4ba9fa83fb0bd13d5553a82e07d344df8d58a84"}, + {file = "regex-2021.11.2-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:ef4e53e2fdc997d91f5b682f81f7dc9661db9a437acce28745d765d251902d85"}, + {file = "regex-2021.11.2-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:35ed5714467fc606551db26f80ee5d6aa1f01185586a7bccd96f179c4b974a11"}, + {file = "regex-2021.11.2-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:7ee36d5113b6506b97f45f2e8447cb9af146e60e3f527d93013d19f6d0405f3b"}, + {file = "regex-2021.11.2-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4fba661a4966adbd2c3c08d3caad6822ecb6878f5456588e2475ae23a6e47929"}, + {file = "regex-2021.11.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:77f9d16f7970791f17ecce7e7f101548314ed1ee2583d4268601f30af3170856"}, + {file = "regex-2021.11.2-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f6a28e87ba69f3a4f30d775b179aac55be1ce59f55799328a0d9b6df8f16b39d"}, + {file = "regex-2021.11.2-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:9267e4fba27e6dd1008c4f2983cc548c98b4be4444e3e342db11296c0f45512f"}, + {file = "regex-2021.11.2-cp37-cp37m-win32.whl", hash = "sha256:d4bfe3bc3976ccaeb4ae32f51e631964e2f0e85b2b752721b7a02de5ce3b7f27"}, + {file = "regex-2021.11.2-cp37-cp37m-win_amd64.whl", hash = "sha256:2bb7cae741de1aa03e3dd3a7d98c304871eb155921ca1f0d7cc11f5aade913fd"}, + {file = "regex-2021.11.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:23f93e74409c210de4de270d4bf88fb8ab736a7400f74210df63a93728cf70d6"}, + {file = "regex-2021.11.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:d8ee91e1c295beb5c132ebd78616814de26fedba6aa8687ea460c7f5eb289b72"}, + {file = "regex-2021.11.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2e3ff69ab203b54ce5c480c3ccbe959394ea5beef6bd5ad1785457df7acea92e"}, + {file = "regex-2021.11.2-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e3c00cb5c71da655e1e5161481455479b613d500dd1bd252aa01df4f037c641f"}, + {file = "regex-2021.11.2-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4abf35e16f4b639daaf05a2602c1b1d47370e01babf9821306aa138924e3fe92"}, + {file = "regex-2021.11.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bb11c982a849dc22782210b01d0c1b98eb3696ce655d58a54180774e4880ac66"}, + {file = "regex-2021.11.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:07e3755e0f070bc31567dfe447a02011bfa8444239b3e9e5cca6773a22133839"}, + {file = "regex-2021.11.2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:0621c90f28d17260b41838b22c81a79ff436141b322960eb49c7b3f91d1cbab6"}, + {file = "regex-2021.11.2-cp38-cp38-win32.whl", hash = "sha256:8fbe1768feafd3d0156556677b8ff234c7bf94a8110e906b2d73506f577a3269"}, + {file = "regex-2021.11.2-cp38-cp38-win_amd64.whl", hash = "sha256:f9ee98d658a146cb6507be720a0ce1b44f2abef8fb43c2859791d91aace17cd5"}, + {file = "regex-2021.11.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:b3794cea825f101fe0df9af8a00f9fad8e119c91e39a28636b95ee2b45b6c2e5"}, + {file = "regex-2021.11.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:3576e173e7b4f88f683b4de7db0c2af1b209bb48b2bf1c827a6f3564fad59a97"}, + {file = "regex-2021.11.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:48b4f4810117a9072a5aa70f7fea5f86fa9efbe9a798312e0a05044bd707cc33"}, + {file = "regex-2021.11.2-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f5930d334c2f607711d54761956aedf8137f83f1b764b9640be21d25a976f3a4"}, + {file = "regex-2021.11.2-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:956187ff49db7014ceb31e88fcacf4cf63371e6e44d209cf8816cd4a2d61e11a"}, + {file = "regex-2021.11.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:17e095f7f96a4b9f24b93c2c915f31a5201a6316618d919b0593afb070a5270e"}, + {file = "regex-2021.11.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a56735c35a3704603d9d7b243ee06139f0837bcac2171d9ba1d638ce1df0742a"}, + {file = "regex-2021.11.2-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:adf35d88d9cffc202e6046e4c32e1e11a1d0238b2fcf095c94f109e510ececea"}, + {file = "regex-2021.11.2-cp39-cp39-win32.whl", hash = "sha256:30fe317332de0e50195665bc61a27d46e903d682f94042c36b3f88cb84bd7958"}, + {file = "regex-2021.11.2-cp39-cp39-win_amd64.whl", hash = "sha256:85289c25f658e3260b00178757c87f033f3d4b3e40aa4abdd4dc875ff11a94fb"}, + {file = "regex-2021.11.2.tar.gz", hash = "sha256:5e85dcfc5d0f374955015ae12c08365b565c6f1eaf36dd182476a4d8e5a1cdb7"}, +] requests = [ {file = "requests-2.26.0-py2.py3-none-any.whl", hash = "sha256:6c1246513ecd5ecd4528a0906f910e8f0f9c6b8ec72030dc9fd154dc1a6efd24"}, {file = "requests-2.26.0.tar.gz", hash = "sha256:b8aa58f8cf793ffd8782d3d8cb19e66ef36f7aba4353eec859e74678b01b07a7"}, @@ -2951,6 +3007,9 @@ typing-extensions = [ {file = "typing_extensions-3.10.0.0-py2-none-any.whl", hash = "sha256:0ac0f89795dd19de6b97debb0c6af1c70987fd80a2d62d1958f7e56fcc31b497"}, {file = "typing_extensions-3.10.0.0-py3-none-any.whl", hash = "sha256:779383f6086d90c99ae41cf0ff39aac8a7937a9283ce0a414e5dd782f4c94a84"}, {file = "typing_extensions-3.10.0.0.tar.gz", hash = "sha256:50b6f157849174217d0656f99dc82fe932884fb250826c18350e159ec6cdf342"}, + {file = "typing_extensions-3.10.0.2-py2-none-any.whl", hash = "sha256:d8226d10bc02a29bcc81df19a26e56a9647f8b0a6d4a83924139f4a8b01f17b7"}, + {file = "typing_extensions-3.10.0.2-py3-none-any.whl", hash = "sha256:f1d25edafde516b146ecd0613dabcc61409817af4766fbbcfb8d1ad4ec441a34"}, + {file = "typing_extensions-3.10.0.2.tar.gz", hash = "sha256:49f75d16ff11f1cd258e1b988ccff82a3ca5570217d7ad8c5f48205dd99a677e"}, ] uc-micro-py = [ {file = "uc-micro-py-1.0.1.tar.gz", hash = "sha256:b7cdf4ea79433043ddfe2c82210208f26f7962c0cfbe3bacb05ee879a7fdb596"}, diff --git a/pyproject.toml b/pyproject.toml index c8554f99..94aa8604 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,6 +72,7 @@ pre-commit = "^2.15.0" jupyter-book = "^0.12.0" types-Jinja2 = "^2.11.8" types-PyYAML = "^6.0.0" +black = "^21.10b0" [tool.poetry.extras] color_log = ["colorama", "colorlog"] From 795b34774977acfd90d96a5952a9d3704e51fd28 Mon Sep 17 00:00:00 2001 From: Dominik Lenoch Date: Fri, 5 Nov 2021 14:35:07 +0100 Subject: [PATCH 4/8] UPD Black format! --- src/yacfg/__init__.py | 4 +- src/yacfg/cli_arguments.py | 151 +++++----- src/yacfg/config_data.py | 32 +-- src/yacfg/files.py | 28 +- src/yacfg/logger_settings.py | 45 +-- src/yacfg/meta.py | 12 +- src/yacfg/output.py | 19 +- src/yacfg/profiles.py | 44 ++- src/yacfg/query.py | 34 +-- src/yacfg/templates.py | 22 +- src/yacfg/yacfg.py | 65 +++-- src/yacfg/yacfg_cli.py | 28 +- src/yacfg_batch/cli_arguments.py | 45 ++- src/yacfg_batch/meta.py | 12 +- src/yacfg_batch/yacfg_batch.py | 69 +++-- src/yacfg_batch/yacfg_batch_cli.py | 9 +- tests/extras/test_broker_special_char.py | 22 +- tests/files/test_ensure_output_path.py | 22 +- .../test_yacfg/cli_arguments/test_boolize.py | 32 +-- tests/test_yacfg/config_data/test_metadata.py | 22 +- .../config_data/test_render_config.py | 28 +- tests/test_yacfg/files/fakes.py | 4 +- .../files/test_ensure_output_path.py | 22 +- .../files/test_get_output_filename.py | 6 +- tests/test_yacfg/files/test_paths.py | 4 +- .../files/test_select_profile_file.py | 48 ++-- .../files/test_select_template_dir.py | 56 ++-- .../output/test_export_tuning_variables.py | 77 ++--- tests/test_yacfg/output/test_new_profile.py | 48 ++-- .../output/test_new_profile_rendered.py | 84 +++--- tests/test_yacfg/output/test_new_template.py | 35 ++- tests/test_yacfg/output/test_write_output.py | 20 +- tests/test_yacfg/profiles/fakes.py | 36 +-- .../profiles/test_get_profile_template.py | 44 ++- .../profiles/test_get_tuned_profile.py | 80 +++--- .../profiles/test_load_profile_defaults.py | 9 +- .../query/test_filter_template_list.py | 29 +- .../query/test_get_main_template_list.py | 10 +- tests/test_yacfg/query/test_list_profiles.py | 80 ++---- tests/test_yacfg/query/test_list_templates.py | 158 +++++----- .../test_get_template_environment.py | 42 +-- tests/test_yacfg/test_generate.py | 271 +++++++++--------- tests/test_yacfg/test_generate_core.py | 162 ++++++----- tests/test_yacfg/test_generate_outputs.py | 64 ++--- tests/test_yacfg_batch/fakes.py | 32 +-- tests/test_yacfg_batch/test_GenerateData.py | 90 +++--- .../test_extract_generate_data.py | 45 ++- tests/test_yacfg_batch/test_generate.py | 51 ++-- .../test_generate_all_profiles.py | 99 +++---- .../test_iter_gen_profiles.py | 26 +- .../test_prioritize_generate_data.py | 69 +++-- 51 files changed, 1213 insertions(+), 1333 deletions(-) diff --git a/src/yacfg/__init__.py b/src/yacfg/__init__.py index f98473be..ca508d86 100644 --- a/src/yacfg/__init__.py +++ b/src/yacfg/__init__.py @@ -18,8 +18,8 @@ import importlib_metadata as metadata # type: ignore try: - __version__ = metadata.version('yacfg') + __version__ = metadata.version("yacfg") except metadata.PackageNotFoundError: - __version__ = 'devel' + __version__ = "devel" from .yacfg import generate # noqa: F401 diff --git a/src/yacfg/cli_arguments.py b/src/yacfg/cli_arguments.py index d8e3cb08..fc9cb46c 100644 --- a/src/yacfg/cli_arguments.py +++ b/src/yacfg/cli_arguments.py @@ -20,167 +20,156 @@ from . import __version__ parser = argparse.ArgumentParser( - prog='{} {}'.format(NAME, __version__), + prog="{} {}".format(NAME, __version__), description=DESCRIPTION, - epilog='The Cake is a lie.', + epilog="The Cake is a lie.", ) # Group Main -group_main = parser.add_argument_group(title='Main options') +group_main = parser.add_argument_group(title="Main options") group_main.add_argument( - '-t', '--template', - help='Configuration template set name (packaged, or user provided path)' + "-t", + "--template", + help="Configuration template set name (packaged, or user provided path)", ) group_main.add_argument( - '-p', '--profile', - help='Configuration data profile name (packaged, or user provided path)', + "-p", + "--profile", + help="Configuration data profile name (packaged, or user provided path)", ) -group_main.add_argument( - '-o', '--output', - help='Output path to generated files to' -) +group_main.add_argument("-o", "--output", help="Output path to generated files to") group_main.add_argument( - '--tune', + "--tune", help=( - 'Fine tune profile variables by providing a YAML file' - ' with values mapping (if selected profile support variables)' + "Fine tune profile variables by providing a YAML file" + " with values mapping (if selected profile support variables)" ), - action='append', + action="append", ) group_main.add_argument( - '--opt', - metavar='KEY=VALUE', + "--opt", + metavar="KEY=VALUE", help=( - 'Fine tune one tuning value format KEY=VALUE, has higher' - ' priority than tuning files.' + "Fine tune one tuning value format KEY=VALUE, has higher" + " priority than tuning files." ), - action='append' + action="append", ) # Group Extra -group_extra = parser.add_argument_group( - title='Extra Options' -) +group_extra = parser.add_argument_group(title="Extra Options") group_extra.add_argument( - '--extra-properties', - help='Extra properties (key-value pairs) that can be used by specific templates' - ' Example: "{x:y,a:b}"', - type=json.loads + "--extra-properties", + help="Extra properties (key-value pairs) that can be used by specific templates" + ' Example: "{x:y,a:b}"', + type=json.loads, ) group_extra.add_argument( - '-f', '--filter', - help='Regular expression enabled output filename filter,' - ' to generate_via_tuning_files only selected config files', - action='append', + "-f", + "--filter", + help="Regular expression enabled output filename filter," + " to generate_via_tuning_files only selected config files", + action="append", ) group_extra.add_argument( - '--save-effective-profile', - help=( - 'Write used profile data to output directory,' - ' output has to be specified' - ), - action='store_true' + "--save-effective-profile", + help=("Write used profile data to output directory," " output has to be specified"), + action="store_true", ) # Group Render -group_render = parser.add_argument_group(title='Render options') +group_render = parser.add_argument_group(title="Render options") group_render.add_argument( - '--render-generator-notice', - help='Control generator notice (header) to be put into output files' - ' (True/False)' + "--render-generator-notice", + help="Control generator notice (header) to be put into output files" + " (True/False)", ) group_render.add_argument( - '--render-licenses', - help='Control licenses to be put into output files (True/False)' + "--render-licenses", + help="Control licenses to be put into output files (True/False)", ) # Group Query -group_query = parser.add_argument_group(title='Query options') +group_query = parser.add_argument_group(title="Query options") group_query.add_argument( - '--list-templates', - help='Print a list of packaged templates', - action='store_true' + "--list-templates", help="Print a list of packaged templates", action="store_true" ) group_query.add_argument( - '--list-profiles', - help='Print a list of packaged profiles', - action='store_true' + "--list-profiles", help="Print a list of packaged profiles", action="store_true" ) # Group Creator group_creator = parser.add_argument_group( - title='Creator Options', + title="Creator Options", ) group_creator.add_argument( - '--new-profile', - help='Export a local copy of an existing profile for further editing' - ' (local path), you need to use profile option to select a profile' + "--new-profile", + help="Export a local copy of an existing profile for further editing" + " (local path), you need to use profile option to select a profile", ) group_creator.add_argument( - '--new-profile-static', - help='Export a local copy of a static version of an existing profile' - ' for further editing (local path), you need to use profile' - ' option to select a profile' + "--new-profile-static", + help="Export a local copy of a static version of an existing profile" + " for further editing (local path), you need to use profile" + " option to select a profile", ) group_creator.add_argument( - '--new-template', - help='Export a local copy of selected template for further editing' - ' (local path), you need to use template to select a template' + "--new-template", + help="Export a local copy of selected template for further editing" + " (local path), you need to use template to select a template", ) group_creator.add_argument( - '--export-tuning', - help='Export a local copy of profile available variables in yaml' - ' for easy creation of tuning file (local path)' + "--export-tuning", + help="Export a local copy of profile available variables in yaml" + " for easy creation of tuning file (local path)", ) # Group Logging -group_logging = parser.add_argument_group(title='Logging options') +group_logging = parser.add_argument_group(title="Logging options") group_logging.add_argument( - '-q', '--quiet', - help='Keep output to minimum, only requested data (listing) or errors', - action='store_true' + "-q", + "--quiet", + help="Keep output to minimum, only requested data (listing) or errors", + action="store_true", ) group_logging.add_argument( - '-v', '--verbose', - help='Print generation status and user relevant info', - action='store_true' + "-v", + "--verbose", + help="Print generation status and user relevant info", + action="store_true", ) group_logging.add_argument( - '-d', '--debug', - help='Print debugging details', - action='store_true' + "-d", "--debug", help="Print debugging details", action="store_true" ) # Group Misc -group_misc = parser.add_argument_group(title='Miscellaneous') +group_misc = parser.add_argument_group(title="Miscellaneous") group_misc.add_argument( - '--version', - help='Display version information', - action='store_true' + "--version", help="Display version information", action="store_true" ) -REX_BOOL_TRUE = re.compile(r'^(([Tt][Rr][Uu][Ee])|[Yy][Ee][Ss]|(1))$') -REX_BOOL_FALSE = re.compile(r'^(([Ff][Aa][Ll][Ss][Ee])|([Nn][Oo])|(0))$') +REX_BOOL_TRUE = re.compile(r"^(([Tt][Rr][Uu][Ee])|[Yy][Ee][Ss]|(1))$") +REX_BOOL_FALSE = re.compile(r"^(([Ff][Aa][Ll][Ss][Ee])|([Nn][Oo])|(0))$") def boolize(data): @@ -214,7 +203,7 @@ def split_key_value(item): :rtype: str, str """ try: - key, value = item.split('=', 1) + key, value = item.split("=", 1) except ValueError: raise ValueError('Missing KEY=VALUE pair in option "{}"'.format(item)) return key, value diff --git a/src/yacfg/config_data.py b/src/yacfg/config_data.py index 7c9e0397..81b5269b 100644 --- a/src/yacfg/config_data.py +++ b/src/yacfg/config_data.py @@ -28,16 +28,16 @@ def add_template_metadata(config_data): """ now = datetime.datetime.now() - config_data['metadata'] = { - 'tool_name': NAME, - 'tool_version': __version__, - 'datetime': { - 'datetime': now.strftime('%Y-%m-%d %H:%M'), - 'year': now.strftime('%Y'), - 'time': now.strftime('%H:%M'), - 'date': now.strftime('%Y-%m-%d'), - 'unix': time.time(), - } + config_data["metadata"] = { + "tool_name": NAME, + "tool_version": __version__, + "datetime": { + "datetime": now.strftime("%Y-%m-%d %H:%M"), + "year": now.strftime("%Y"), + "time": now.strftime("%H:%M"), + "date": now.strftime("%Y-%m-%d"), + "unix": time.time(), + }, } @@ -52,15 +52,15 @@ def add_render_config(config_data, render_options): render_config = {} if render_options.generator_notice is not None: - render_config['generator_notice'] = render_options.generator_notice + render_config["generator_notice"] = render_options.generator_notice if render_options.licenses is not None: - render_config['licenses'] = render_options.licenses + render_config["licenses"] = render_options.licenses # update loaded config data - if 'render' not in config_data: - config_data['render'] = render_config + if "render" not in config_data: + config_data["render"] = render_config else: - config_data['render'].update(render_config) + config_data["render"].update(render_config) -RenderOptions = namedtuple('RenderOptions', ['generator_notice', 'licenses']) +RenderOptions = namedtuple("RenderOptions", ["generator_notice", "licenses"]) diff --git a/src/yacfg/files.py b/src/yacfg/files.py index ab41268d..379c0d5c 100644 --- a/src/yacfg/files.py +++ b/src/yacfg/files.py @@ -21,7 +21,7 @@ LOG = logging.getLogger(__name__) -REX_TEMPLATE_TO_OUTPUT = re.compile(r'^(.*)(\.jinja2)$') +REX_TEMPLATE_TO_OUTPUT = re.compile(r"^(.*)(\.jinja2)$") def get_module_path(): @@ -32,7 +32,7 @@ def get_module_path(): :rtype: str """ module_path = os.path.dirname(__file__) - LOG.debug('Module path: %s', module_path) + LOG.debug("Module path: %s", module_path) return module_path @@ -43,11 +43,15 @@ def get_profiles_path(): :rtype: str """ - env_profiles = os.getenv('YACFG_PROFILES') # TODO: Add test for YACFG_PROFILES environment variable + env_profiles = os.getenv( + "YACFG_PROFILES" + ) # TODO: Add test for YACFG_PROFILES environment variable if env_profiles: profiles_path = os.path.join(env_profiles) - LOG.debug('Using user defined $YACFG_PROFILES profiles path "%s"', profiles_path) + LOG.debug( + 'Using user defined $YACFG_PROFILES profiles path "%s"', profiles_path + ) else: module_path = get_module_path() @@ -64,11 +68,15 @@ def get_templates_path(): :rtype: str """ - env_templates = os.getenv('YACFG_TEMPLATES') # TODO: Add test for YACFG_TEMPLATES environment variable + env_templates = os.getenv( + "YACFG_TEMPLATES" + ) # TODO: Add test for YACFG_TEMPLATES environment variable if env_templates: templates_path = os.path.join(env_templates) - LOG.debug('Using user defined $YACFG_TEMPLATES template path "%s"', templates_path) + LOG.debug( + 'Using user defined $YACFG_TEMPLATES template path "%s"', templates_path + ) else: module_path = get_module_path() @@ -114,9 +122,7 @@ def select_profile_file(profile_name): complete_path = os.path.join(selected_profile_path, selected_profile_name) if not os.path.isfile(complete_path): - raise ProfileError( - 'Unable to find a requested profile "%s"' % profile_name - ) + raise ProfileError('Unable to find a requested profile "%s"' % profile_name) LOG.debug('Selected profile: "%s"', complete_path) return selected_profile_name, selected_profile_path @@ -155,13 +161,13 @@ def select_template_dir(template_name): 'Unable to load requested template set "%s"' % template_name ) - if not os.path.isfile(os.path.join(selected_template_path, '_template')): + if not os.path.isfile(os.path.join(selected_template_path, "_template")): raise TemplateError( 'Selected template "%s" does not contain' ' "_template" file, so it is not considered a template' ) - LOG.debug('Selected template: %s', selected_template_path) + LOG.debug("Selected template: %s", selected_template_path) return selected_template_path diff --git a/src/yacfg/logger_settings.py b/src/yacfg/logger_settings.py index a4b01442..10e9d855 100644 --- a/src/yacfg/logger_settings.py +++ b/src/yacfg/logger_settings.py @@ -15,17 +15,19 @@ import logging import sys -FORMAT_CONSOLE = '[%(asctime)s] [%(levelname)s] %(name)s :: %(message)s' -FORMAT_CONSOLE_COLOR = '[%(asctime)s] [%(log_color)s%(levelname)s%(reset)s]' \ - ' %(name)s :: %(message)s' +FORMAT_CONSOLE = "[%(asctime)s] [%(levelname)s] %(name)s :: %(message)s" +FORMAT_CONSOLE_COLOR = ( + "[%(asctime)s] [%(log_color)s%(levelname)s%(reset)s]" " %(name)s :: %(message)s" +) -DATE_FORMAT_ISO = '%Y-%m-%d %H:%M:%S,' -DATE_FORMAT_TIME = '%H:%M:%S' +DATE_FORMAT_ISO = "%Y-%m-%d %H:%M:%S," +DATE_FORMAT_TIME = "%H:%M:%S" -def config_console_logger(filename=None, level=None, fmt=None, fmt_color=None, - datefmt=None): - """ configure console logger, if colorlog is installed it will use colorlog +def config_console_logger( + filename=None, level=None, fmt=None, fmt_color=None, datefmt=None +): + """configure console logger, if colorlog is installed it will use colorlog :param filename: stream to log into, default sys.stdout :param level: console log level :param fmt: console log format @@ -37,6 +39,7 @@ def config_console_logger(filename=None, level=None, fmt=None, fmt_color=None, try: # noinspection PyUnresolvedReferences import colorama + colorama.init() except ImportError: try: @@ -44,10 +47,11 @@ def config_console_logger(filename=None, level=None, fmt=None, fmt_color=None, import colorlog except ImportError: import platform - if platform.system() == 'Windows': + + if platform.system() == "Windows": import_error_msg.append( - 'Colorlog without colorama used, expect escape codes,' - ' please install colorama' + "Colorlog without colorama used, expect escape codes," + " please install colorama" ) filename = filename or sys.stdout @@ -65,18 +69,19 @@ def config_console_logger(filename=None, level=None, fmt=None, fmt_color=None, try: # noinspection PyUnresolvedReferences import colorlog # noqa: F811 + console_formatter = colorlog.ColoredFormatter( fmt_color, log_colors={ - 'CRITICAL': 'black,bg_red', - 'ERROR': 'red', - 'WARNING': 'yellow', - 'SKIP': 'blue', - 'FAIL': 'bold_red', - 'PASS': 'bold_green', - 'INFO': 'reset', - 'DOC': 'purple', - 'DEBUG': 'cyan', + "CRITICAL": "black,bg_red", + "ERROR": "red", + "WARNING": "yellow", + "SKIP": "blue", + "FAIL": "bold_red", + "PASS": "bold_green", + "INFO": "reset", + "DOC": "purple", + "DEBUG": "cyan", }, datefmt=datefmt, ) diff --git a/src/yacfg/meta.py b/src/yacfg/meta.py index ed17e12a..ff04a6fb 100644 --- a/src/yacfg/meta.py +++ b/src/yacfg/meta.py @@ -12,11 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -NAME = 'yacfg' -SHORT_DESCRIPTION = 'Template based configuration generator' +NAME = "yacfg" +SHORT_DESCRIPTION = "Template based configuration generator" DESCRIPTION = ( - 'Template based configuration files generator based on jinja2 and yaml' - ' mainly focused on Apache ActiveMQ Artemis and related projects' + "Template based configuration files generator based on jinja2 and yaml" + " mainly focused on Apache ActiveMQ Artemis and related projects" ) -TEMPLATES = 'templates' -PROFILES = 'profiles' +TEMPLATES = "templates" +PROFILES = "profiles" diff --git a/src/yacfg/output.py b/src/yacfg/output.py index 69952c4a..eb0c4e4e 100644 --- a/src/yacfg/output.py +++ b/src/yacfg/output.py @@ -73,8 +73,9 @@ def new_profile(profile, dest_profile): shutil.copyfile(src, dest_profile) -def new_profile_rendered(profile, dest_profile, tuning_files=None, - tuning_data_list=None): +def new_profile_rendered( + profile, dest_profile, tuning_files=None, tuning_data_list=None +): """Export an existing profile in static form, stripped defaults section :param profile: existing profile name (from user or packaged) @@ -97,12 +98,12 @@ def new_profile_rendered(profile, dest_profile, tuning_files=None, if dest_path: ensure_output_path(dest_path) # raises: OSError - if '_defaults' in config_data: - del config_data['_defaults'] + if "_defaults" in config_data: + del config_data["_defaults"] export_data = yaml_dump_wrapper(config_data) - export_data = '# {} tuning file generated from profile {}{}{}'.format( + export_data = "# {} tuning file generated from profile {}{}{}".format( NAME, profile, os.linesep, export_data ) write_output(dest_name, dest_path, export_data) @@ -151,12 +152,12 @@ def export_tuning_variables(profile_name, dest_file): # export_data = yaml.dump_all([defaults_data], default_flow_style=False) export_data = yaml_dump_wrapper(defaults_data) - LOG.debug('Exported tuning data:\n%s', export_data) - export_data = '# {} tuning file generated from profile {}{}{}'.format( + LOG.debug("Exported tuning data:\n%s", export_data) + export_data = "# {} tuning file generated from profile {}{}{}".format( NAME, profile_name, os.linesep, export_data ) write_output(dest_name, dest_path, export_data) - LOG.info('Tuning data exported') + LOG.info("Tuning data exported") def write_output(filename, output_path, data): @@ -170,7 +171,7 @@ def write_output(filename, output_path, data): :type data: str """ filepath = os.path.join(output_path, filename) - with open(filepath, 'w') as fh: + with open(filepath, "w") as fh: fh.write(data) # fh.write(os.linesep) LOG.debug('File writen "%s"', filepath) diff --git a/src/yacfg/profiles.py b/src/yacfg/profiles.py index 307fd850..44e3e42d 100644 --- a/src/yacfg/profiles.py +++ b/src/yacfg/profiles.py @@ -40,28 +40,25 @@ def load_tuning_files(tuning_files=None): if tuning_files: for tuning_file in tuning_files: try: - tuning_values_list.append(yaml.load(stream=open(tuning_file, 'r'), Loader=yaml.SafeLoader)) + tuning_values_list.append( + yaml.load(stream=open(tuning_file, "r"), Loader=yaml.SafeLoader) + ) except IOError as exc: raise ProfileError( - 'Unable to open tuning file "{}" {}'.format( - tuning_file, exc - ) + 'Unable to open tuning file "{}" {}'.format(tuning_file, exc) ) except yaml.YAMLError as exc: raise ProfileError( - 'Unable to parse YAML tuning file "{}" {}'.format( - tuning_files, exc - ) + 'Unable to parse YAML tuning file "{}" {}'.format(tuning_files, exc) ) - LOG.debug('Tuning file {} loaded', tuning_file) + LOG.debug("Tuning file {} loaded", tuning_file) else: - LOG.debug('No tuning files requested.') + LOG.debug("No tuning files requested.") return tuning_values_list -def load_tuning(profile_defaults=None, tuning_files_list=None, - tuning_data_list=None): +def load_tuning(profile_defaults=None, tuning_files_list=None, tuning_data_list=None): """Load and apply all tuning, from profile defaults, from tuning files, and then directly provided tuning data. If provided. All data is applied in order. @@ -113,17 +110,13 @@ def get_tuned_profile(profile, tuning_files_list=None, tuning_data_list=None): ) tuning_profile = get_profile_template(profile) - tuning_data['profile_path'] = tuning_profile.name + tuning_data["profile_path"] = tuning_profile.name tuned_profile = tuning_profile.render(tuning_data) try: config_data = yaml.load(stream=tuned_profile, Loader=yaml.SafeLoader) except yaml.YAMLError as exc: - raise ProfileError( - 'Unable to parse tuned profile "{}" {}'.format( - profile, exc - ) - ) + raise ProfileError('Unable to parse tuned profile "{}" {}'.format(profile, exc)) return config_data, tuned_profile @@ -144,8 +137,8 @@ def load_profile_defaults(profile): scratch_profile = get_profile_template(profile) scratch_profile = scratch_profile.render() tmp_data = yaml.load(stream=scratch_profile, Loader=yaml.SafeLoader) - tuning_data = tmp_data.get('_defaults', {}) - LOG.debug('Tuning data: %s', tuning_data) + tuning_data = tmp_data.get("_defaults", {}) + LOG.debug("Tuning data: %s", tuning_data) return tuning_data @@ -161,8 +154,7 @@ def get_profile_template(profile_name): :rtype: Template """ - selected_template_name, selected_template_path = \ - select_profile_file(profile_name) + selected_template_name, selected_template_path = select_profile_file(profile_name) if not os.path.isdir(selected_template_path): raise TemplateError( @@ -170,10 +162,12 @@ def get_profile_template(profile_name): ) env = Environment( - loader=FileSystemLoader([ - selected_template_path, # selected template - get_profiles_path(), - ]), + loader=FileSystemLoader( + [ + selected_template_path, # selected template + get_profiles_path(), + ] + ), trim_blocks=True, lstrip_blocks=True, ) diff --git a/src/yacfg/query.py b/src/yacfg/query.py index 589c452b..3f59955a 100644 --- a/src/yacfg/query.py +++ b/src/yacfg/query.py @@ -34,11 +34,9 @@ def filter_template_list(template_list, output_filter): """ output_filter = [re.compile(flt) for flt in output_filter] template_list = [ - templ - for templ in template_list - for rex in output_filter if rex.match(templ) + templ for templ in template_list for rex in output_filter if rex.match(templ) ] - LOG.debug('Filtered template files list: %s', template_list) + LOG.debug("Filtered template files list: %s", template_list) return template_list @@ -54,13 +52,13 @@ def list_templates(): """ templates_path = get_templates_path() - LOG.debug('Templates path for query: %s', templates_path) + LOG.debug("Templates path for query: %s", templates_path) result = [] for root, dirs, files in os.walk(templates_path): for fn in files: - if fn == '_template': + if fn == "_template": prefix_path = os.path.relpath(root, templates_path) result.append(prefix_path) break @@ -81,7 +79,7 @@ def list_profiles(): """ profiles_path = get_profiles_path() - LOG.debug('Profiles path for query: %s', profiles_path) + LOG.debug("Profiles path for query: %s", profiles_path) result = [] @@ -89,26 +87,20 @@ def list_profiles(): prefix_path = os.path.relpath(root, profiles_path) # skip over underscored paths path_levels = prefix_path.split(os.path.sep) - if any([x.startswith('_') for x in path_levels]): - LOG.debug('Skipping underscored: %s', path_levels) + if any([x.startswith("_") for x in path_levels]): + LOG.debug("Skipping underscored: %s", path_levels) continue # filter only yaml profiles tmp_files = [ fn - for fn in files if ( - fn.endswith('.yaml') - or fn.endswith('.jinja2') - or fn.endswith('.j2') - ) + for fn in files + if (fn.endswith(".yaml") or fn.endswith(".jinja2") or fn.endswith(".j2")) ] # add relative profile path if it is not profiles root, # it would add './' which is undesirable - if prefix_path != '.': - tmp_files = [ - os.path.join(prefix_path, fn) - for fn in tmp_files - ] + if prefix_path != ".": + tmp_files = [os.path.join(prefix_path, fn) for fn in tmp_files] result += tmp_files result = [posixpath.join(*i.split(os.path.sep)) for i in result] @@ -127,13 +119,13 @@ def get_main_template_list(env): :return: list of main template names :rtype: list[str] """ - rex_main_template = re.compile(r'^[^/]+\.jinja2$') + rex_main_template = re.compile(r"^[^/]+\.jinja2$") def main_template_filter(name): return rex_main_template.match(name) templ_list = env.list_templates(filter_func=main_template_filter) - LOG.debug('Main template files list: %s', templ_list) + LOG.debug("Main template files list: %s", templ_list) return templ_list diff --git a/src/yacfg/templates.py b/src/yacfg/templates.py index 2f62f10a..2a4c5843 100644 --- a/src/yacfg/templates.py +++ b/src/yacfg/templates.py @@ -33,26 +33,26 @@ def get_template_environment(template_name): :return: jinja2 environment :rtype: Environment """ - LOG.debug('Template name: %s', template_name) + LOG.debug("Template name: %s", template_name) templates_path = get_templates_path() - LOG.debug('Template path: %s', templates_path) + LOG.debug("Template path: %s", templates_path) selected_template_path = select_template_dir(template_name) - LOG.debug('Selected template path: %s', selected_template_path) + LOG.debug("Selected template path: %s", selected_template_path) try: env = Environment( - loader=FileSystemLoader([ - selected_template_path, # selected template - templates_path, # all templates for includes - ]), + loader=FileSystemLoader( + [ + selected_template_path, # selected template + templates_path, # all templates for includes + ] + ), trim_blocks=True, lstrip_blocks=True, ) except jinja2.TemplateError: - LOG.exception('Original Error') + LOG.exception("Original Error") # this is yacfg.exceptions.TemplateError - raise TemplateError( - 'There was a problem with templating environment.' - ) + raise TemplateError("There was a problem with templating environment.") return env diff --git a/src/yacfg/yacfg.py b/src/yacfg/yacfg.py index dd56d4ce..823edcbb 100644 --- a/src/yacfg/yacfg.py +++ b/src/yacfg/yacfg.py @@ -37,9 +37,16 @@ LOG = logging.getLogger(__name__) -def generate_core(config_data, tuned_profile=None, template=None, - output_path=None, output_filter=None, render_options=None, - write_profile_data=False, extra_properties_data=None): +def generate_core( + config_data, + tuned_profile=None, + template=None, + output_path=None, + output_filter=None, + render_options=None, + write_profile_data=False, + extra_properties_data=None, +): """Core of the generator, gets complete dataset with selected template in config data or explicitly selected via template parameter at minimum, and generates outputs, if requested writes @@ -80,12 +87,10 @@ def generate_core(config_data, tuned_profile=None, template=None, # template if template is None: - template = config_data.get('render', {}).get('template') - LOG.debug('Profile specified template: %s', template) + template = config_data.get("render", {}).get("template") + LOG.debug("Profile specified template: %s", template) if template is None: - raise TemplateError( - 'Missing template. User nor profile specifies a template.' - ) + raise TemplateError("Missing template. User nor profile specifies a template.") env = get_template_environment(template) @@ -146,27 +151,38 @@ def override_value_map_keys(value): return new_map # Pass empty filter for performance if an extra_properties_data not defined (no more conditions) - env.filters['overridevalue'] = override_value if extra_properties_data else empty_filter - env.filters['overridevalue_listmapkeys'] = override_value_list_map_keys if extra_properties_data else empty_filter + env.filters["overridevalue"] = ( + override_value if extra_properties_data else empty_filter + ) + env.filters["overridevalue_listmapkeys"] = ( + override_value_list_map_keys if extra_properties_data else empty_filter + ) template_list = get_main_template_list(env) if output_filter: template_list = filter_template_list(template_list, output_filter) - LOG.debug('Config data: %s', json.dumps(config_data)) + LOG.debug("Config data: %s", json.dumps(config_data)) if output_path and tuned_profile: ensure_output_path(output_path) if write_profile_data: - write_output('profile_data.yaml', output_path, tuned_profile) + write_output("profile_data.yaml", output_path, tuned_profile) return generate_outputs(config_data, template_list, env, output_path) -def generate(profile, template=None, output_path=None, - output_filter=None, render_options=None, - tuning_files_list=None, tuning_data_list=None, - write_profile_data=False, extra_properties_data=None): +def generate( + profile, + template=None, + output_path=None, + output_filter=None, + render_options=None, + tuning_files_list=None, + tuning_data_list=None, + write_profile_data=False, + extra_properties_data=None, +): """Generate procedure using list of tuning data generate_via_tuning_files output files based on output_filter, from @@ -220,7 +236,7 @@ def generate(profile, template=None, output_path=None, output_filter=output_filter, render_options=render_options, write_profile_data=write_profile_data, - extra_properties_data=extra_properties_data + extra_properties_data=extra_properties_data, ) @@ -260,28 +276,27 @@ def generate_outputs(config_data, template_list, env, output_path=None): # metadata structure initialization, # if called without add_template_metadata() - if 'metadata' not in config_data: - config_data['metadata'] = {} + if "metadata" not in config_data: + config_data["metadata"] = {} for template_name in template_list: out_filename = get_output_filename(template_name) - config_data['metadata']['out_filename'] = template_name + config_data["metadata"]["out_filename"] = template_name try: template = env.get_template(template_name) output_data = template.render(config_data) except jinja2.TemplateError as exc: LOG.error('Config file "%s" generation FAILED', out_filename) - LOG.exception('Original error') + LOG.exception("Original error") if not generate_exception: generate_exception = GenerationError( 'There was a problem generating file "%s" with "%s" ' - 'template: %s' - % (out_filename, template_name, exc) + "template: %s" % (out_filename, template_name, exc) ) else: - LOG.debug('BEGIN %s\n%s', out_filename, output_data) - LOG.debug('END %s' % out_filename) + LOG.debug("BEGIN %s\n%s", out_filename, output_data) + LOG.debug("END %s" % out_filename) LOG.info('Config file "%s" generation PASSED', out_filename) result_data[out_filename] = output_data diff --git a/src/yacfg/yacfg_cli.py b/src/yacfg/yacfg_cli.py index 934f0dc1..99003635 100644 --- a/src/yacfg/yacfg_cli.py +++ b/src/yacfg/yacfg_cli.py @@ -24,8 +24,10 @@ from .exceptions import TemplateError, ProfileError, GenerationError from .meta import NAME from .output import ( - new_profile, new_profile_rendered, - new_template, export_tuning_variables + new_profile, + new_profile_rendered, + new_template, + export_tuning_variables, ) from .query import list_templates, list_profiles @@ -66,7 +68,7 @@ def main(): except ValueError as exc: error(exc, 2) - LOG.debug('Direct Tuning options %s', options.opt) + LOG.debug("Direct Tuning options %s", options.opt) do_not_generate = False @@ -75,12 +77,12 @@ def main(): return if options.list_templates: - LOG.info('Available Templates:') + LOG.info("Available Templates:") print(os.linesep.join(list_templates())) return if options.list_profiles: - LOG.info('Available Profiles:') + LOG.info("Available Profiles:") print(os.linesep.join(list_profiles())) return @@ -89,7 +91,7 @@ def main(): if options.new_profile or options.new_profile_static: do_not_generate = True if not options.profile: - error('Missing parameters profile', 0) + error("Missing parameters profile", 0) error_do_not_generate = True else: try: @@ -109,7 +111,7 @@ def main(): if options.export_tuning: do_not_generate = True if not options.profile: - error('Missing parameters profile', 0) + error("Missing parameters profile", 0) error_do_not_generate = True else: try: @@ -121,7 +123,7 @@ def main(): if options.new_template: do_not_generate = True if not options.template: - error('Missing parameter template, cannot export', 0) + error("Missing parameter template, cannot export", 0) error_do_not_generate = True else: try: @@ -131,19 +133,19 @@ def main(): error_do_not_generate = True if error_do_not_generate: - error('Cannot continue due to existing above problems', 2) + error("Cannot continue due to existing above problems", 2) # Generator barrier for actions that prevents generation if do_not_generate: sys.exit(0) if not options.profile: - error('Missing parameters profile', 0) + error("Missing parameters profile", 0) error_do_not_generate = True if error_do_not_generate: # parser.print_help() - error('Cannot continue due to existing above problems', 2) + error("Cannot continue due to existing above problems", 2) # Tune up render options render_options = RenderOptions( @@ -161,7 +163,7 @@ def main(): tuning_files_list=options.tune, tuning_data_list=options.opt, write_profile_data=options.save_effective_profile, - extra_properties_data=options.extra_properties + extra_properties_data=options.extra_properties, ) except TemplateError as exc: error(exc) @@ -171,5 +173,5 @@ def main(): error(exc, 1) -if __name__ == '__main__': +if __name__ == "__main__": main() diff --git a/src/yacfg_batch/cli_arguments.py b/src/yacfg_batch/cli_arguments.py index 31078288..29491281 100644 --- a/src/yacfg_batch/cli_arguments.py +++ b/src/yacfg_batch/cli_arguments.py @@ -16,52 +16,49 @@ from .meta import NAME, DESCRIPTION from . import __version__ + parser = argparse.ArgumentParser( - prog='{} {}'.format(NAME, __version__), + prog="{} {}".format(NAME, __version__), description=DESCRIPTION, - epilog='The Cake is a lie.', + epilog="The Cake is a lie.", ) -group_main = parser.add_argument_group(title='Main options') +group_main = parser.add_argument_group(title="Main options") group_main.add_argument( - '-i', '--input', - help='Input files to configuration profile set', + "-i", + "--input", + help="Input files to configuration profile set", default=[], - action='append' + action="append", ) -group_main.add_argument( - '-o', '--output', - help='Output path to generated files to' -) +group_main.add_argument("-o", "--output", help="Output path to generated files to") # Group Logging -group_logging = parser.add_argument_group(title='Logging options') +group_logging = parser.add_argument_group(title="Logging options") group_logging.add_argument( - '-q', '--quiet', - help='Keep output to minimum, only requested data (listing) or errors', - action='store_true' + "-q", + "--quiet", + help="Keep output to minimum, only requested data (listing) or errors", + action="store_true", ) group_logging.add_argument( - '-v', '--verbose', - help='Print generation status and user relevant info', - action='store_true' + "-v", + "--verbose", + help="Print generation status and user relevant info", + action="store_true", ) group_logging.add_argument( - '-d', '--debug', - help='Print debugging details', - action='store_true' + "-d", "--debug", help="Print debugging details", action="store_true" ) # Group Misc -group_misc = parser.add_argument_group(title='Miscellaneous') +group_misc = parser.add_argument_group(title="Miscellaneous") group_misc.add_argument( - '--version', - help='Display version information', - action='store_true' + "--version", help="Display version information", action="store_true" ) diff --git a/src/yacfg_batch/meta.py b/src/yacfg_batch/meta.py index d4473a03..8163dd57 100644 --- a/src/yacfg_batch/meta.py +++ b/src/yacfg_batch/meta.py @@ -12,11 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -NAME = 'yacfg-batch' -SHORT_DESCRIPTION = 'Template based configuration generator' +NAME = "yacfg-batch" +SHORT_DESCRIPTION = "Template based configuration generator" DESCRIPTION = ( - 'Batch configuration generator supporting generation of multiple services' - ' from a set of profiles using the template based configuration files' - ' generator \'yacfg\' based on jinja2 and yaml mainly focused on Apache' - ' ActiveMQ Artemis and related projects' + "Batch configuration generator supporting generation of multiple services" + " from a set of profiles using the template based configuration files" + " generator 'yacfg' based on jinja2 and yaml mainly focused on Apache" + " ActiveMQ Artemis and related projects" ) diff --git a/src/yacfg_batch/yacfg_batch.py b/src/yacfg_batch/yacfg_batch.py index 4099bcec..6b57b2da 100644 --- a/src/yacfg_batch/yacfg_batch.py +++ b/src/yacfg_batch/yacfg_batch.py @@ -33,23 +33,20 @@ class GenerateData(object): tuning_data = None def __str__(self): - tmp = ( - 'GenerateData({!r}, {!r}, {}, {})'.format( - self.profile_name, - self.template_name, - self.tuning_files, - self.tuning_data - ) + tmp = "GenerateData({!r}, {!r}, {}, {})".format( + self.profile_name, self.template_name, self.tuning_files, self.tuning_data ) return tmp __repr__ = __str__ def __eq__(self, other): - return (self.profile_name == other.profile_name - and self.template_name == other.template_name - and self.tuning_files == other.tuning_files - and self.tuning_data == other.tuning_data) + return ( + self.profile_name == other.profile_name + and self.template_name == other.template_name + and self.tuning_files == other.tuning_files + and self.tuning_data == other.tuning_data + ) def iter_gen_profiles(filename): @@ -57,7 +54,7 @@ def iter_gen_profiles(filename): profile_data_list = None try: - profile_data_list = yaml.load_all(open(filename, 'r')) + profile_data_list = yaml.load_all(open(filename, "r")) except IOError as exc: raise YacfgBatchException( 'Unable to open gen profile "{}" {}'.format(filename, exc) @@ -82,19 +79,19 @@ def generate(input_files, output_path=None): :type output_path: str | None """ for profile_file in input_files: - LOG.info('- Profile file: {}'.format(profile_file)) + LOG.info("- Profile file: {}".format(profile_file)) for profile_file_data in iter_gen_profiles(profile_file): input_path = os.path.dirname(profile_file) default = extract_generate_data(profile_file_data) - common = extract_generate_data(profile_file_data, '_common') + common = extract_generate_data(profile_file_data, "_common") generate_all_profiles( input_path, output_path, default, common, profile_file_data ) -def extract_generate_data(profile_file_data, section='_default'): +def extract_generate_data(profile_file_data, section="_default"): """Get all relevant data from special sections like _default Data contains profile name, template name, tuning files, and @@ -112,10 +109,10 @@ def extract_generate_data(profile_file_data, section='_default'): section_data = profile_file_data.get(section) result = GenerateData() if section_data: - result.profile_name = section_data.get('profile') - result.template_name = section_data.get('template') - result.tuning_files = section_data.get('tuning_files') - result.tuning_data = section_data.get('tuning') + result.profile_name = section_data.get("profile") + result.template_name = section_data.get("template") + result.tuning_files = section_data.get("tuning_files") + result.tuning_data = section_data.get("tuning") return result @@ -143,7 +140,7 @@ def prioritize_generate_data(profile, common, default): """ result = GenerateData() - for key in ['profile_name', 'template_name']: + for key in ["profile_name", "template_name"]: for conf in [default, common, profile]: value = getattr(conf, key) if value: @@ -176,8 +173,7 @@ def prioritize_generate_data(profile, common, default): return result -def generate_all_profiles(input_path, output_path, default, common, - profiles_file_data): +def generate_all_profiles(input_path, output_path, default, common, profiles_file_data): """Main subroutine for generating all service's profile configs. :param input_path: path of used input yaml file, to pick @@ -194,20 +190,17 @@ def generate_all_profiles(input_path, output_path, default, common, as loaded from YAML :type profiles_file_data: dict """ - profile_list = [ - x for x in profiles_file_data.keys() if not x.startswith('_') - ] + profile_list = [x for x in profiles_file_data.keys() if not x.startswith("_")] for profile in profile_list: - LOG.info('-- Profile: {}'.format(profile)) + LOG.info("-- Profile: {}".format(profile)) profile_data = extract_generate_data(profiles_file_data, profile) generate_data = prioritize_generate_data(profile_data, common, default) if not generate_data.profile_name: raise YacfgBatchException( - 'No selected profile,' - ' cannot generate_via_tuning_files.' + "No selected profile," " cannot generate_via_tuning_files." ) # post process tuning files @@ -216,7 +209,7 @@ def generate_all_profiles(input_path, output_path, default, common, os.path.join(input_path, x) for x in generate_data.tuning_files ] - LOG.debug('tuning data: {}'.format(generate_data.tuning_data)) + LOG.debug("tuning data: {}".format(generate_data.tuning_data)) target_path = None if output_path: @@ -227,13 +220,17 @@ def generate_all_profiles(input_path, output_path, default, common, tuning_data = [generate_data.tuning_data] LOG.debug( - 'CALL: yacfg --profile {} --template {} ' - '--tuning {} --output {} # extra tuning: {} ' - '>> {}'.format( - generate_data.profile_name, generate_data.template_name, - generate_data.tuning_files, target_path, - generate_data.tuning_data, target_path - )) + "CALL: yacfg --profile {} --template {} " + "--tuning {} --output {} # extra tuning: {} " + ">> {}".format( + generate_data.profile_name, + generate_data.template_name, + generate_data.tuning_files, + target_path, + generate_data.tuning_data, + target_path, + ) + ) yacfg.yacfg.generate( profile=generate_data.profile_name, diff --git a/src/yacfg_batch/yacfg_batch_cli.py b/src/yacfg_batch/yacfg_batch_cli.py index 2e7b8c06..ee34e608 100644 --- a/src/yacfg_batch/yacfg_batch_cli.py +++ b/src/yacfg_batch/yacfg_batch_cli.py @@ -51,16 +51,13 @@ def main(): return if not options.input: - error( - 'Missing parameter input, cannot work without input.', - 2 - ) + error("Missing parameter input, cannot work without input.", 2) if options.input: generate(options.input, options.output) - print('have a nice day.') + print("have a nice day.") -if __name__ == '__main__': +if __name__ == "__main__": main() diff --git a/tests/extras/test_broker_special_char.py b/tests/extras/test_broker_special_char.py index bec0825a..a2106f3c 100644 --- a/tests/extras/test_broker_special_char.py +++ b/tests/extras/test_broker_special_char.py @@ -19,35 +19,37 @@ import yacfg -@pytest.mark.skip(reason="Artemis profiles were removed, test needs to be replaced/fixed.") +@pytest.mark.skip( + reason="Artemis profiles were removed, test needs to be replaced/fixed." +) def test_with_special_chars(*_): print("testing 1") dir_path = os.path.dirname(__file__) - tune_file = f'{dir_path}/tune_files/special_address_setting.yaml' + tune_file = f"{dir_path}/tune_files/special_address_setting.yaml" - profile = 'artemis/2.16.0/default_with_user_address_settings.yaml.jinja2' + profile = "artemis/2.16.0/default_with_user_address_settings.yaml.jinja2" tuning_files = [tune_file] - extra_props = {'uuid1': '', 'uuid2': 'OFF'} - output = 'etc' + extra_props = {"uuid1": "", "uuid2": "OFF"} + output = "etc" yacfg.generate( profile=profile, tuning_files_list=tuning_files, extra_properties_data=extra_props, - output_path=output + output_path=output, ) - broker_xml = output + '/broker.xml' - file1 = open(broker_xml, 'r') + broker_xml = output + "/broker.xml" + file1 = open(broker_xml, "r") try: lines = file1.readlines() empty_found = False off_found = False for ln in lines: - if ln.find('') != -1: + if ln.find("") != -1: empty_found = True - if ln.find('OFF') != -1: + if ln.find("OFF") != -1: off_found = True assert empty_found is True diff --git a/tests/files/test_ensure_output_path.py b/tests/files/test_ensure_output_path.py index c5e40667..22cc53f8 100644 --- a/tests/files/test_ensure_output_path.py +++ b/tests/files/test_ensure_output_path.py @@ -20,30 +20,30 @@ from yacfg.files import ensure_output_path -@mock.patch('os.path.isdir', side_effect=(False,)) -@mock.patch('os.path.isfile', side_effect=(False,)) +@mock.patch("os.path.isdir", side_effect=(False,)) +@mock.patch("os.path.isfile", side_effect=(False,)) def test_create_true(*_): - output_path = '/location/group/output/' - with mock.patch('os.makedirs', mock.Mock()): + output_path = "/location/group/output/" + with mock.patch("os.makedirs", mock.Mock()): ensure_output_path(output_path=output_path) # noinspection PyUnresolvedReferences os.makedirs.assert_called() -@mock.patch('os.path.isdir', side_effect=(True,)) +@mock.patch("os.path.isdir", side_effect=(True,)) def test_exists(*_): - output_path = '/location/group/output/' - with mock.patch('os.makedirs', mock.Mock()): + output_path = "/location/group/output/" + with mock.patch("os.makedirs", mock.Mock()): ensure_output_path(output_path=output_path) # noinspection PyUnresolvedReferences os.makedirs.assert_not_called() -@mock.patch('os.path.isdir', side_effect=(False,)) -@mock.patch('os.path.isfile', side_effect=(True,)) +@mock.patch("os.path.isdir", side_effect=(False,)) +@mock.patch("os.path.isfile", side_effect=(True,)) def test_exists_but_file_exception(*_): - output_path = '/location/group/output/' - with mock.patch('os.makedirs', mock.Mock()): + output_path = "/location/group/output/" + with mock.patch("os.makedirs", mock.Mock()): with pytest.raises(IOError): ensure_output_path(output_path=output_path) # noinspection PyUnresolvedReferences diff --git a/tests/test_yacfg/cli_arguments/test_boolize.py b/tests/test_yacfg/cli_arguments/test_boolize.py index 93679925..96850687 100644 --- a/tests/test_yacfg/cli_arguments/test_boolize.py +++ b/tests/test_yacfg/cli_arguments/test_boolize.py @@ -17,28 +17,28 @@ dataset_boolize = ( (None, None), - ('Yes', True), - ('No', False), - ('yes', True), - ('no', False), - ('YES', True), - ('NO', False), - ('True', True), - ('False', False), - ('true', True), - ('false', False), - ('TRUE', True), - ('FALSE', False), - ('1', True), - ('0', False), + ("Yes", True), + ("No", False), + ("yes", True), + ("no", False), + ("YES", True), + ("NO", False), + ("True", True), + ("False", False), + ("true", True), + ("false", False), + ("TRUE", True), + ("FALSE", False), + ("1", True), + ("0", False), ) -@pytest.mark.parametrize('value,result', dataset_boolize) +@pytest.mark.parametrize("value,result", dataset_boolize) def test_boolize_values(value, result): assert yacfg.cli_arguments.boolize(value) == result def test_boolize_exception(): with pytest.raises(ValueError): - yacfg.cli_arguments.boolize('test') + yacfg.cli_arguments.boolize("test") diff --git a/tests/test_yacfg/config_data/test_metadata.py b/tests/test_yacfg/config_data/test_metadata.py index fcc59fd5..20eec1a8 100644 --- a/tests/test_yacfg/config_data/test_metadata.py +++ b/tests/test_yacfg/config_data/test_metadata.py @@ -17,29 +17,29 @@ import yacfg.config_data dataset_metadata_members = ( - 'tool_name', - 'datetime', + "tool_name", + "datetime", ) -@pytest.mark.parametrize('member', dataset_metadata_members) +@pytest.mark.parametrize("member", dataset_metadata_members) def test_add_template_metadata_check_member(member): data = {} yacfg.config_data.add_template_metadata(data) - assert member in data['metadata'] + assert member in data["metadata"] dataset_metadata_datetime_members = ( - 'datetime', - 'year', - 'time', - 'date', - 'unix', + "datetime", + "year", + "time", + "date", + "unix", ) -@pytest.mark.parametrize('member', dataset_metadata_datetime_members) +@pytest.mark.parametrize("member", dataset_metadata_datetime_members) def test_add_template_metadata_datetime_check_member(member): data = {} yacfg.config_data.add_template_metadata(data) - assert member in data['metadata']['datetime'] + assert member in data["metadata"]["datetime"] diff --git a/tests/test_yacfg/config_data/test_render_config.py b/tests/test_yacfg/config_data/test_render_config.py index 82431fb8..a3ed5878 100644 --- a/tests/test_yacfg/config_data/test_render_config.py +++ b/tests/test_yacfg/config_data/test_render_config.py @@ -16,32 +16,30 @@ import yacfg.config_data dataset_render_config = ( - (yacfg.config_data.RenderOptions(None, None), 'generator_notice', None), - (yacfg.config_data.RenderOptions(None, None), 'licenses', None), - (yacfg.config_data.RenderOptions(True, None), 'generator_notice', True), - (yacfg.config_data.RenderOptions(False, None), 'generator_notice', False), - (yacfg.config_data.RenderOptions(None, True), 'licenses', True), - (yacfg.config_data.RenderOptions(None, False), 'licenses', False), + (yacfg.config_data.RenderOptions(None, None), "generator_notice", None), + (yacfg.config_data.RenderOptions(None, None), "licenses", None), + (yacfg.config_data.RenderOptions(True, None), "generator_notice", True), + (yacfg.config_data.RenderOptions(False, None), "generator_notice", False), + (yacfg.config_data.RenderOptions(None, True), "licenses", True), + (yacfg.config_data.RenderOptions(None, False), "licenses", False), ) -@pytest.mark.parametrize('render_options,key,value', dataset_render_config) +@pytest.mark.parametrize("render_options,key,value", dataset_render_config) def test_add_render_config_members(render_options, key, value): data = {} - yacfg.config_data.add_render_config(config_data=data, - render_options=render_options) + yacfg.config_data.add_render_config(config_data=data, render_options=render_options) if value is not None: - assert key in data['render'] + assert key in data["render"] else: - assert key not in data['render'] + assert key not in data["render"] -@pytest.mark.parametrize('render_options,key,value', dataset_render_config) +@pytest.mark.parametrize("render_options,key,value", dataset_render_config) def test_add_render_config_values(render_options, key, value): data = {} - yacfg.config_data.add_render_config(config_data=data, - render_options=render_options) + yacfg.config_data.add_render_config(config_data=data, render_options=render_options) if value is not None: - assert data['render'][key] == value + assert data["render"][key] == value else: assert True diff --git a/tests/test_yacfg/files/fakes.py b/tests/test_yacfg/files/fakes.py index 1d2b3a19..c677b152 100644 --- a/tests/test_yacfg/files/fakes.py +++ b/tests/test_yacfg/files/fakes.py @@ -18,7 +18,7 @@ def fake_module_path(): - return '/module/path' + return "/module/path" def fake_profiles_path(): @@ -30,7 +30,7 @@ def fake_templates_path(): def fake_os_abspath(path): - return os.path.join('/absolute/path/', path) + return os.path.join("/absolute/path/", path) def fake_select_profile_file(name): diff --git a/tests/test_yacfg/files/test_ensure_output_path.py b/tests/test_yacfg/files/test_ensure_output_path.py index c5e40667..22cc53f8 100644 --- a/tests/test_yacfg/files/test_ensure_output_path.py +++ b/tests/test_yacfg/files/test_ensure_output_path.py @@ -20,30 +20,30 @@ from yacfg.files import ensure_output_path -@mock.patch('os.path.isdir', side_effect=(False,)) -@mock.patch('os.path.isfile', side_effect=(False,)) +@mock.patch("os.path.isdir", side_effect=(False,)) +@mock.patch("os.path.isfile", side_effect=(False,)) def test_create_true(*_): - output_path = '/location/group/output/' - with mock.patch('os.makedirs', mock.Mock()): + output_path = "/location/group/output/" + with mock.patch("os.makedirs", mock.Mock()): ensure_output_path(output_path=output_path) # noinspection PyUnresolvedReferences os.makedirs.assert_called() -@mock.patch('os.path.isdir', side_effect=(True,)) +@mock.patch("os.path.isdir", side_effect=(True,)) def test_exists(*_): - output_path = '/location/group/output/' - with mock.patch('os.makedirs', mock.Mock()): + output_path = "/location/group/output/" + with mock.patch("os.makedirs", mock.Mock()): ensure_output_path(output_path=output_path) # noinspection PyUnresolvedReferences os.makedirs.assert_not_called() -@mock.patch('os.path.isdir', side_effect=(False,)) -@mock.patch('os.path.isfile', side_effect=(True,)) +@mock.patch("os.path.isdir", side_effect=(False,)) +@mock.patch("os.path.isfile", side_effect=(True,)) def test_exists_but_file_exception(*_): - output_path = '/location/group/output/' - with mock.patch('os.makedirs', mock.Mock()): + output_path = "/location/group/output/" + with mock.patch("os.makedirs", mock.Mock()): with pytest.raises(IOError): ensure_output_path(output_path=output_path) # noinspection PyUnresolvedReferences diff --git a/tests/test_yacfg/files/test_get_output_filename.py b/tests/test_yacfg/files/test_get_output_filename.py index 881d2c02..9bbfddb8 100644 --- a/tests/test_yacfg/files/test_get_output_filename.py +++ b/tests/test_yacfg/files/test_get_output_filename.py @@ -18,11 +18,11 @@ def test_jinja_suffix(): - assert get_output_filename('my_config.xml.jinja2') == 'my_config.xml' + assert get_output_filename("my_config.xml.jinja2") == "my_config.xml" def test_base_name(): - assert get_output_filename('my_config.xml') == 'my_config.xml' + assert get_output_filename("my_config.xml") == "my_config.xml" dataset_incorrect_values = ( @@ -34,7 +34,7 @@ def test_base_name(): ) -@pytest.mark.parametrize('value', dataset_incorrect_values) +@pytest.mark.parametrize("value", dataset_incorrect_values) def test_int(value): with pytest.raises(TypeError): get_output_filename(value) diff --git a/tests/test_yacfg/files/test_paths.py b/tests/test_yacfg/files/test_paths.py index 2c423020..85293f2c 100644 --- a/tests/test_yacfg/files/test_paths.py +++ b/tests/test_yacfg/files/test_paths.py @@ -18,14 +18,14 @@ from .fakes import fake_module_path, fake_profiles_path, fake_templates_path -@mock.patch('yacfg.files.get_module_path', side_effect=fake_module_path) +@mock.patch("yacfg.files.get_module_path", side_effect=fake_module_path) def test_get_profiles_path(_): expected = fake_profiles_path() result = yacfg.files.get_profiles_path() assert result == expected -@mock.patch('yacfg.files.get_module_path', side_effect=fake_module_path) +@mock.patch("yacfg.files.get_module_path", side_effect=fake_module_path) def test_get_templates_path(_): expected = fake_templates_path() result = yacfg.files.get_templates_path() diff --git a/tests/test_yacfg/files/test_select_profile_file.py b/tests/test_yacfg/files/test_select_profile_file.py index 597fde51..ae61ea7b 100644 --- a/tests/test_yacfg/files/test_select_profile_file.py +++ b/tests/test_yacfg/files/test_select_profile_file.py @@ -23,67 +23,67 @@ from .fakes import fake_profiles_path, fake_os_abspath -@mock.patch('yacfg.files.get_profiles_path', side_effect=fake_profiles_path) -@mock.patch('os.path.isfile', side_effect=(False, False, True)) +@mock.patch("yacfg.files.get_profiles_path", side_effect=fake_profiles_path) +@mock.patch("os.path.isfile", side_effect=(False, False, True)) def test_packaged_true(*_): """Packaged profile selection""" - expected_name = 'packaged_profile.yaml' + expected_name = "packaged_profile.yaml" expected_path = fake_profiles_path() result_name, result_path = yacfg.files.select_profile_file(expected_name) assert result_name == expected_name assert result_path == expected_path -@mock.patch('yacfg.files.get_profiles_path', side_effect=fake_profiles_path) -@mock.patch('os.path.isfile', side_effect=(True, True, True)) -@mock.patch('os.path.abspath', side_effect=fake_os_abspath) +@mock.patch("yacfg.files.get_profiles_path", side_effect=fake_profiles_path) +@mock.patch("os.path.isfile", side_effect=(True, True, True)) +@mock.patch("os.path.abspath", side_effect=fake_os_abspath) def test_user_true(*_): """User Specified profile selection""" - expected_name = 'user_profile.yaml' - expected_path = os.path.dirname(fake_os_abspath('')) + expected_name = "user_profile.yaml" + expected_path = os.path.dirname(fake_os_abspath("")) result_name, result_path = yacfg.files.select_profile_file(expected_name) assert result_name == expected_name assert result_path == expected_path -@mock.patch('yacfg.files.get_profiles_path', side_effect=fake_profiles_path) -@mock.patch('os.path.isfile', side_effect=(True, False, True)) -@mock.patch('os.path.abspath', side_effect=fake_os_abspath) +@mock.patch("yacfg.files.get_profiles_path", side_effect=fake_profiles_path) +@mock.patch("os.path.isfile", side_effect=(True, False, True)) +@mock.patch("os.path.abspath", side_effect=fake_os_abspath) def test_user_basedir_true(*_): """User Specified profile selection""" - expected_name = 'user_profile.yaml' + expected_name = "user_profile.yaml" expected_path = fake_os_abspath(yacfg.meta.PROFILES) result_name, result_path = yacfg.files.select_profile_file(expected_name) assert result_name == expected_name assert result_path == expected_path -@mock.patch('yacfg.files.get_profiles_path', side_effect=fake_profiles_path) -@mock.patch('os.path.isfile', side_effect=(True, True, True)) -@mock.patch('os.path.abspath', side_effect=fake_os_abspath) +@mock.patch("yacfg.files.get_profiles_path", side_effect=fake_profiles_path) +@mock.patch("os.path.isfile", side_effect=(True, True, True)) +@mock.patch("os.path.abspath", side_effect=fake_os_abspath) def test_user_both_true(*_): """User Specified profile selection""" - expected_name = 'user_profile.yaml' - expected_path = os.path.dirname(fake_os_abspath('')) + expected_name = "user_profile.yaml" + expected_path = os.path.dirname(fake_os_abspath("")) result_name, result_path = yacfg.files.select_profile_file(expected_name) assert result_name == expected_name assert result_path == expected_path -@mock.patch('yacfg.files.get_profiles_path', side_effect=fake_profiles_path) -@mock.patch('os.path.isfile', side_effect=(False, False, False)) +@mock.patch("yacfg.files.get_profiles_path", side_effect=fake_profiles_path) +@mock.patch("os.path.isfile", side_effect=(False, False, False)) def test_non_existing(*_): """Non-existing packaged profile selection""" - expected_name = 'non_existing_packaged_profile.yaml' + expected_name = "non_existing_packaged_profile.yaml" with pytest.raises(ProfileError): yacfg.files.select_profile_file(expected_name) -@mock.patch('yacfg.files.get_profiles_path', side_effect=fake_profiles_path) -@mock.patch('os.path.isfile', side_effect=(False, False, False)) -@mock.patch('os.path.abspath', side_effect=fake_os_abspath) +@mock.patch("yacfg.files.get_profiles_path", side_effect=fake_profiles_path) +@mock.patch("os.path.isfile", side_effect=(False, False, False)) +@mock.patch("os.path.abspath", side_effect=fake_os_abspath) def test_user_non_existing(*_): """Non-existing user profile selection""" - expected_name = 'non_existing_user_profile.yaml' + expected_name = "non_existing_user_profile.yaml" with pytest.raises(ProfileError): yacfg.files.select_profile_file(expected_name) diff --git a/tests/test_yacfg/files/test_select_template_dir.py b/tests/test_yacfg/files/test_select_template_dir.py index 91daca7c..d98d1ad7 100644 --- a/tests/test_yacfg/files/test_select_template_dir.py +++ b/tests/test_yacfg/files/test_select_template_dir.py @@ -23,77 +23,77 @@ from .fakes import fake_templates_path -@mock.patch('yacfg.files.get_templates_path', side_effect=fake_templates_path) -@mock.patch('os.path.isdir', side_effect=(False, False, True)) -@mock.patch('os.path.isfile', side_effect=(True,)) +@mock.patch("yacfg.files.get_templates_path", side_effect=fake_templates_path) +@mock.patch("os.path.isdir", side_effect=(False, False, True)) +@mock.patch("os.path.isfile", side_effect=(True,)) def test_packaged_true(*_): """Packaged template selection""" - template_name = 'product/1.0.0' + template_name = "product/1.0.0" expected_dir = os.path.join(fake_templates_path(), template_name) selected_template_path = yacfg.files.select_template_dir(template_name) assert selected_template_path == expected_dir -@mock.patch('yacfg.files.get_templates_path', side_effect=fake_templates_path) -@mock.patch('os.path.isdir', side_effect=(False, True, True)) -@mock.patch('os.path.isfile', side_effect=(True,)) +@mock.patch("yacfg.files.get_templates_path", side_effect=fake_templates_path) +@mock.patch("os.path.isdir", side_effect=(False, True, True)) +@mock.patch("os.path.isfile", side_effect=(True,)) def test_user_true(*_): """User specified template selection""" - template_name = 'custom/user_product/1.0.0' + template_name = "custom/user_product/1.0.0" selected_template_path = yacfg.files.select_template_dir(template_name) assert selected_template_path == template_name -@mock.patch('yacfg.files.get_templates_path', side_effect=fake_templates_path) -@mock.patch('os.path.isdir', side_effect=(True, False, True)) -@mock.patch('os.path.isfile', side_effect=(True,)) +@mock.patch("yacfg.files.get_templates_path", side_effect=fake_templates_path) +@mock.patch("os.path.isdir", side_effect=(True, False, True)) +@mock.patch("os.path.isfile", side_effect=(True,)) def test_user_basedir_true(*_): """User specified template selection""" - template_name = 'user_product/1.0.0' + template_name = "user_product/1.0.0" expected_name = os.path.join(meta.TEMPLATES, template_name) selected_template_path = yacfg.files.select_template_dir(template_name) assert selected_template_path == expected_name -@mock.patch('yacfg.files.get_templates_path', side_effect=fake_templates_path) -@mock.patch('os.path.isdir', side_effect=(True, True, True)) -@mock.patch('os.path.isfile', side_effect=(True,)) +@mock.patch("yacfg.files.get_templates_path", side_effect=fake_templates_path) +@mock.patch("os.path.isdir", side_effect=(True, True, True)) +@mock.patch("os.path.isfile", side_effect=(True,)) def test_user_both_true(*_): """User specified template selection""" - template_name = 'user_product/1.0.0' + template_name = "user_product/1.0.0" expected_name = template_name selected_template_path = yacfg.files.select_template_dir(template_name) assert selected_template_path == expected_name -@mock.patch('yacfg.files.get_templates_path', side_effect=fake_templates_path) -@mock.patch('os.path.isdir', side_effect=(False, False, False)) -@mock.patch('os.path.isfile', side_effect=(True,)) +@mock.patch("yacfg.files.get_templates_path", side_effect=fake_templates_path) +@mock.patch("os.path.isdir", side_effect=(False, False, False)) +@mock.patch("os.path.isfile", side_effect=(True,)) def test_not_directory(*_): """Template set not a directory""" - template_name = 'user_product/1.0.0' + template_name = "user_product/1.0.0" with pytest.raises(TemplateError): selected_template_path = yacfg.files.select_template_dir(template_name) assert selected_template_path == template_name -@mock.patch('yacfg.files.get_templates_path', side_effect=fake_templates_path) -@mock.patch('os.path.isdir', side_effect=(False, False, True)) -@mock.patch('os.path.isfile', side_effect=(False,)) +@mock.patch("yacfg.files.get_templates_path", side_effect=fake_templates_path) +@mock.patch("os.path.isdir", side_effect=(False, False, True)) +@mock.patch("os.path.isfile", side_effect=(False,)) def test_packaged_missing_template_marker(*_): """Packaged Template set not a directory""" - template_name = 'user_product/1.0.0' + template_name = "user_product/1.0.0" with pytest.raises(TemplateError): selected_template_path = yacfg.files.select_template_dir(template_name) assert selected_template_path == template_name -@mock.patch('yacfg.files.get_templates_path', side_effect=fake_templates_path) -@mock.patch('os.path.isdir', side_effect=(True, True, True)) -@mock.patch('os.path.isfile', side_effect=(False,)) +@mock.patch("yacfg.files.get_templates_path", side_effect=fake_templates_path) +@mock.patch("os.path.isdir", side_effect=(True, True, True)) +@mock.patch("os.path.isfile", side_effect=(False,)) def test_user_missing_template_marker(*_): """User specified Template set not a directory""" - template_name = 'user_product/1.0.0' + template_name = "user_product/1.0.0" with pytest.raises(TemplateError): selected_template_path = yacfg.files.select_template_dir(template_name) assert selected_template_path == template_name diff --git a/tests/test_yacfg/output/test_export_tuning_variables.py b/tests/test_yacfg/output/test_export_tuning_variables.py index 986c7439..4350f1d1 100644 --- a/tests/test_yacfg/output/test_export_tuning_variables.py +++ b/tests/test_yacfg/output/test_export_tuning_variables.py @@ -21,22 +21,22 @@ from yacfg.exceptions import ProfileError from yacfg.meta import NAME from yacfg.output import export_tuning_variables -from ..profiles.fakes import fake_load_profile_defaults, \ - fake_profile_defaults_yaml +from ..profiles.fakes import fake_load_profile_defaults, fake_profile_defaults_yaml -@mock.patch('yacfg.output.load_profile_defaults', - side_effect=fake_load_profile_defaults) -@mock.patch('yacfg.output.ensure_output_path', mock.Mock()) -@mock.patch('yacfg.output.write_output', mock.Mock()) +@mock.patch( + "yacfg.output.load_profile_defaults", side_effect=fake_load_profile_defaults +) +@mock.patch("yacfg.output.ensure_output_path", mock.Mock()) +@mock.patch("yacfg.output.write_output", mock.Mock()) def test_true(*_): - profile_name = 'my_profile.yaml' - destination_path = '/destination/path/tuning' - destination_name = 'tuning.yaml' + profile_name = "my_profile.yaml" + destination_path = "/destination/path/tuning" + destination_name = "tuning.yaml" destination = os.path.join(destination_path, destination_name) expected_data = fake_profile_defaults_yaml() - expected_data = '# {} tuning file generated from profile {}{}---{}{}'.format( + expected_data = "# {} tuning file generated from profile {}{}---{}{}".format( NAME, profile_name, os.linesep, os.linesep, expected_data ) @@ -45,19 +45,18 @@ def test_true(*_): # noinspection PyUnresolvedReferences yacfg.output.ensure_output_path.assert_called_with(destination_path) # noinspection PyUnresolvedReferences - yacfg.output.write_output.assert_called_with(destination_name, - destination_path, - expected_data) + yacfg.output.write_output.assert_called_with( + destination_name, destination_path, expected_data + ) -@mock.patch('yacfg.output.load_profile_defaults', - side_effect=({},)) -@mock.patch('yacfg.output.ensure_output_path', mock.Mock()) -@mock.patch('yacfg.output.write_output', mock.Mock()) +@mock.patch("yacfg.output.load_profile_defaults", side_effect=({},)) +@mock.patch("yacfg.output.ensure_output_path", mock.Mock()) +@mock.patch("yacfg.output.write_output", mock.Mock()) def test_no_defaults_exception(*_): - profile_name = 'my_profile.yaml' - destination_path = '/destination/path/tuning' - destination_name = 'tuning.yaml' + profile_name = "my_profile.yaml" + destination_path = "/destination/path/tuning" + destination_name = "tuning.yaml" destination = os.path.join(destination_path, destination_name) with pytest.raises(ProfileError): @@ -69,15 +68,18 @@ def test_no_defaults_exception(*_): yacfg.output.write_output.assert_not_called() -@mock.patch('yacfg.output.load_profile_defaults', - side_effect=fake_load_profile_defaults) -@mock.patch('yacfg.output.ensure_output_path', - side_effect=OSError('[Errno 13] Permission denied: \'path\'')) -@mock.patch('yacfg.output.write_output', mock.Mock()) +@mock.patch( + "yacfg.output.load_profile_defaults", side_effect=fake_load_profile_defaults +) +@mock.patch( + "yacfg.output.ensure_output_path", + side_effect=OSError("[Errno 13] Permission denied: 'path'"), +) +@mock.patch("yacfg.output.write_output", mock.Mock()) def test_bad_destination_exception(*_): - profile_name = 'my_profile.yaml' - destination_path = '/bad/destination' - destination_name = 'tuning.yaml' + profile_name = "my_profile.yaml" + destination_path = "/bad/destination" + destination_name = "tuning.yaml" destination = os.path.join(destination_path, destination_name) with pytest.raises(OSError): @@ -89,15 +91,18 @@ def test_bad_destination_exception(*_): yacfg.output.write_output.assert_not_called() -@mock.patch('yacfg.output.load_profile_defaults', - side_effect=fake_load_profile_defaults) -@mock.patch('yacfg.output.ensure_output_path', mock.Mock()) -@mock.patch('yacfg.output.write_output', - side_effect=OSError('[Errno 13] Permission denied: \'path\'')) +@mock.patch( + "yacfg.output.load_profile_defaults", side_effect=fake_load_profile_defaults +) +@mock.patch("yacfg.output.ensure_output_path", mock.Mock()) +@mock.patch( + "yacfg.output.write_output", + side_effect=OSError("[Errno 13] Permission denied: 'path'"), +) def test_no_destination_exception(*_): - profile_name = 'my_profile.yaml' - destination_path = '' - destination_name = 'tuning.yaml' + profile_name = "my_profile.yaml" + destination_path = "" + destination_name = "tuning.yaml" destination = os.path.join(destination_path, destination_name) with pytest.raises(OSError): diff --git a/tests/test_yacfg/output/test_new_profile.py b/tests/test_yacfg/output/test_new_profile.py index 67e307f0..ec3b8e02 100644 --- a/tests/test_yacfg/output/test_new_profile.py +++ b/tests/test_yacfg/output/test_new_profile.py @@ -20,20 +20,16 @@ from yacfg.output import new_profile import yacfg.output -from ..files.fakes import ( - fake_select_profile_file, - fake_profiles_path -) +from ..files.fakes import fake_select_profile_file, fake_profiles_path -@mock.patch('yacfg.output.select_profile_file', - side_effect=fake_select_profile_file) -@mock.patch('shutil.copyfile', mock.Mock()) -@mock.patch('yacfg.output.ensure_output_path', mock.Mock()) +@mock.patch("yacfg.output.select_profile_file", side_effect=fake_select_profile_file) +@mock.patch("shutil.copyfile", mock.Mock()) +@mock.patch("yacfg.output.ensure_output_path", mock.Mock()) def test_true(*_): """Creating new profile true path""" - profile_name = 'existing_profile.yaml' - destination = '/output/directory/my_new_profile.yaml' + profile_name = "existing_profile.yaml" + destination = "/output/directory/my_new_profile.yaml" expected_source_file = os.path.join(fake_profiles_path(), profile_name) expected_target_file = destination expected_target_dir = os.path.dirname(destination) @@ -42,18 +38,16 @@ def test_true(*_): # noinspection PyUnresolvedReferences yacfg.output.ensure_output_path.assert_called_with(expected_target_dir) # noinspection PyUnresolvedReferences - shutil.copyfile.assert_called_with(expected_source_file, - expected_target_file) + shutil.copyfile.assert_called_with(expected_source_file, expected_target_file) -@mock.patch('yacfg.output.select_profile_file', - side_effect=fake_select_profile_file) -@mock.patch('shutil.copyfile', mock.Mock()) -@mock.patch('yacfg.output.ensure_output_path', mock.Mock()) +@mock.patch("yacfg.output.select_profile_file", side_effect=fake_select_profile_file) +@mock.patch("shutil.copyfile", mock.Mock()) +@mock.patch("yacfg.output.ensure_output_path", mock.Mock()) def test_true_no_destination(*_): """Creating new profile true path""" - profile_name = 'existing_profile.yaml' - destination = 'my_new_profile.yaml' + profile_name = "existing_profile.yaml" + destination = "my_new_profile.yaml" expected_source_file = os.path.join(fake_profiles_path(), profile_name) expected_target_file = destination @@ -61,19 +55,19 @@ def test_true_no_destination(*_): # noinspection PyUnresolvedReferences yacfg.output.ensure_output_path.assert_not_called() # noinspection PyUnresolvedReferences - shutil.copyfile.assert_called_with(expected_source_file, - expected_target_file) + shutil.copyfile.assert_called_with(expected_source_file, expected_target_file) -@mock.patch('yacfg.output.select_profile_file', - side_effect=fake_select_profile_file) -@mock.patch('shutil.copyfile', mock.Mock()) -@mock.patch('yacfg.output.ensure_output_path', - side_effect=OSError('[Errno 13] Permission denied: \'path\'')) +@mock.patch("yacfg.output.select_profile_file", side_effect=fake_select_profile_file) +@mock.patch("shutil.copyfile", mock.Mock()) +@mock.patch( + "yacfg.output.ensure_output_path", + side_effect=OSError("[Errno 13] Permission denied: 'path'"), +) def test_destination_problem_exception(*_): """Creating new profile true path""" - profile_name = 'existing_profile.yaml' - destination = '/problematic/directory/my_new_profile.yaml' + profile_name = "existing_profile.yaml" + destination = "/problematic/directory/my_new_profile.yaml" expected_target_dir = os.path.dirname(destination) with pytest.raises(OSError): diff --git a/tests/test_yacfg/output/test_new_profile_rendered.py b/tests/test_yacfg/output/test_new_profile_rendered.py index cc92c672..13853276 100644 --- a/tests/test_yacfg/output/test_new_profile_rendered.py +++ b/tests/test_yacfg/output/test_new_profile_rendered.py @@ -26,17 +26,18 @@ ) -@mock.patch('yacfg.output.get_tuned_profile', - side_effect=fake_load_tuned_profile_with_defaults) -@mock.patch('yacfg.output.write_output', mock.Mock()) -@mock.patch('yacfg.output.ensure_output_path', mock.Mock()) +@mock.patch( + "yacfg.output.get_tuned_profile", side_effect=fake_load_tuned_profile_with_defaults +) +@mock.patch("yacfg.output.write_output", mock.Mock()) +@mock.patch("yacfg.output.ensure_output_path", mock.Mock()) def test_true_defaults(*_): - profile_name = 'product/1.0.0/my_profile.yaml' - destination_name = 'destination_profile.yaml' - destination_path = '/profile/destination/path' + profile_name = "product/1.0.0/my_profile.yaml" + destination_name = "destination_profile.yaml" + destination_path = "/profile/destination/path" destination = os.path.join(destination_path, destination_name) _, expected_data = fake_load_tuned_profile_no_defaults() - expected_data = '# {} tuning file generated from profile {}{}---{}{}'.format( + expected_data = "# {} tuning file generated from profile {}{}---{}{}".format( NAME, profile_name, os.linesep, os.linesep, expected_data ) @@ -44,22 +45,23 @@ def test_true_defaults(*_): # noinspection PyUnresolvedReferences yacfg.output.ensure_output_path.assert_called_with(destination_path) # noinspection PyUnresolvedReferences - yacfg.output.write_output.assert_called_with(destination_name, - destination_path, - expected_data) + yacfg.output.write_output.assert_called_with( + destination_name, destination_path, expected_data + ) -@mock.patch('yacfg.output.get_tuned_profile', - side_effect=fake_load_tuned_profile_no_defaults) -@mock.patch('yacfg.output.write_output', mock.Mock()) -@mock.patch('yacfg.output.ensure_output_path', mock.Mock()) +@mock.patch( + "yacfg.output.get_tuned_profile", side_effect=fake_load_tuned_profile_no_defaults +) +@mock.patch("yacfg.output.write_output", mock.Mock()) +@mock.patch("yacfg.output.ensure_output_path", mock.Mock()) def test_true_no_defaults(*_): - profile_name = 'product/1.0.0/my_profile.yaml' - destination_name = 'destination_profile.yaml' - destination_path = '/profile/destination/path' + profile_name = "product/1.0.0/my_profile.yaml" + destination_name = "destination_profile.yaml" + destination_path = "/profile/destination/path" destination = os.path.join(destination_path, destination_name) _, expected_data = fake_load_tuned_profile_no_defaults() - expected_data = '# {} tuning file generated from profile {}{}---{}{}'.format( + expected_data = "# {} tuning file generated from profile {}{}---{}{}".format( NAME, profile_name, os.linesep, os.linesep, expected_data ) @@ -67,20 +69,21 @@ def test_true_no_defaults(*_): # noinspection PyUnresolvedReferences yacfg.output.ensure_output_path.assert_called_with(destination_path) # noinspection PyUnresolvedReferences - yacfg.output.write_output.assert_called_with(destination_name, - destination_path, - expected_data) + yacfg.output.write_output.assert_called_with( + destination_name, destination_path, expected_data + ) -@mock.patch('yacfg.output.get_tuned_profile', - side_effect=fake_load_tuned_profile_with_defaults) -@mock.patch('yacfg.output.write_output', mock.Mock()) -@mock.patch('yacfg.output.ensure_output_path', mock.Mock()) +@mock.patch( + "yacfg.output.get_tuned_profile", side_effect=fake_load_tuned_profile_with_defaults +) +@mock.patch("yacfg.output.write_output", mock.Mock()) +@mock.patch("yacfg.output.ensure_output_path", mock.Mock()) def test_true_no_destination(*_): - profile_name = 'product/1.0.0/my_profile.yaml' - destination = '' + profile_name = "product/1.0.0/my_profile.yaml" + destination = "" _, expected_data = fake_load_tuned_profile_no_defaults() - expected_data = '# {} tuning file generated from profile {}{}---{}{}'.format( + expected_data = "# {} tuning file generated from profile {}{}---{}{}".format( NAME, profile_name, os.linesep, os.linesep, expected_data ) @@ -88,19 +91,22 @@ def test_true_no_destination(*_): # noinspection PyUnresolvedReferences yacfg.output.ensure_output_path.assert_not_called() # noinspection PyUnresolvedReferences - yacfg.output.write_output.assert_called_with(destination, - destination, - expected_data) + yacfg.output.write_output.assert_called_with( + destination, destination, expected_data + ) -@mock.patch('yacfg.output.get_tuned_profile', - side_effect=fake_load_tuned_profile_with_defaults) -@mock.patch('yacfg.output.ensure_output_path', - side_effect=OSError('[Errno 13] Permission denied: \'path\'')) -@mock.patch('yacfg.output.write_output', mock.Mock()) +@mock.patch( + "yacfg.output.get_tuned_profile", side_effect=fake_load_tuned_profile_with_defaults +) +@mock.patch( + "yacfg.output.ensure_output_path", + side_effect=OSError("[Errno 13] Permission denied: 'path'"), +) +@mock.patch("yacfg.output.write_output", mock.Mock()) def test_destination_problem_exception(*_): - profile_name = 'product/1.0.0/my_profile.yaml' - destination = '/problematic/destination' + profile_name = "product/1.0.0/my_profile.yaml" + destination = "/problematic/destination" with pytest.raises(OSError): new_profile_rendered(profile_name, destination, None) # noinspection PyUnresolvedReferences diff --git a/tests/test_yacfg/output/test_new_template.py b/tests/test_yacfg/output/test_new_template.py index 07c03795..44bd325b 100644 --- a/tests/test_yacfg/output/test_new_template.py +++ b/tests/test_yacfg/output/test_new_template.py @@ -23,30 +23,28 @@ from ..files.fakes import fake_templates_path, fake_select_template_dir -@mock.patch('yacfg.output.select_template_dir', - side_effect=fake_select_template_dir) -@mock.patch('shutil.copytree', mock.Mock()) +@mock.patch("yacfg.output.select_template_dir", side_effect=fake_select_template_dir) +@mock.patch("shutil.copytree", mock.Mock()) def test_true(*_): - template_name = 'my_template/1.2.3' + template_name = "my_template/1.2.3" template_path = fake_templates_path() template = os.path.join(template_path, template_name) - destination_path = '/output/template/dir/' - destination_name = 'new_template' + destination_path = "/output/template/dir/" + destination_name = "new_template" destination = os.path.join(destination_path, destination_name) new_template(template_name, destination) # noinspection PyUnresolvedReferences - shutil.copytree.assert_called_with(template, destination, - symlinks=False) + shutil.copytree.assert_called_with(template, destination, symlinks=False) -@mock.patch('yacfg.output.select_template_dir', - side_effect=fake_select_template_dir) -@mock.patch('shutil.copytree', - side_effect=OSError('[Errno 13] Permission denied: \'path\'')) +@mock.patch("yacfg.output.select_template_dir", side_effect=fake_select_template_dir) +@mock.patch( + "shutil.copytree", side_effect=OSError("[Errno 13] Permission denied: 'path'") +) def test_bad_destination(*_): - template_name = 'my_template/1.2.3' - destination = '/bad/destination' + template_name = "my_template/1.2.3" + destination = "/bad/destination" with pytest.raises(OSError): new_template(template_name, destination) @@ -54,12 +52,11 @@ def test_bad_destination(*_): shutil.copytree.assert_called() -@mock.patch('yacfg.output.select_template_dir', - side_effect=fake_select_template_dir) -@mock.patch('yacfg.output.ensure_output_path', side_effect=mock.Mock()) +@mock.patch("yacfg.output.select_template_dir", side_effect=fake_select_template_dir) +@mock.patch("yacfg.output.ensure_output_path", side_effect=mock.Mock()) def test_no_destination(*_): - template_name = 'my_template/1.2.3' - destination = '' + template_name = "my_template/1.2.3" + destination = "" with pytest.raises(OSError): new_template(template_name, destination) diff --git a/tests/test_yacfg/output/test_write_output.py b/tests/test_yacfg/output/test_write_output.py index 04120771..b0d21bb0 100644 --- a/tests/test_yacfg/output/test_write_output.py +++ b/tests/test_yacfg/output/test_write_output.py @@ -22,31 +22,31 @@ from yacfg.output import write_output -@mock.patch('yacfg.output.open', mock.MagicMock()) +@mock.patch("yacfg.output.open", mock.MagicMock()) def test_true(*_): - file_name = 'my_output.txt' - file_path = '/output/path' + file_name = "my_output.txt" + file_path = "/output/path" file_pathname = os.path.join(file_path, file_name) - data = 'output data' + data = "output data" write_output(file_name, file_path, data) # noinspection PyUnresolvedReferences - yacfg.output.open.assert_called_with(file_pathname, 'w') + yacfg.output.open.assert_called_with(file_pathname, "w") # noinspection PyUnresolvedReferences fh = yacfg.output.open.return_value.__enter__.return_value fh.write.assert_has_calls([mock.call(data)]) -@mock.patch('yacfg.output.open', side_effect=IOError) +@mock.patch("yacfg.output.open", side_effect=IOError) def test_bad_filename(*_): - file_name = 'my_output.txt' - file_path = '/bad/output/path' + file_name = "my_output.txt" + file_path = "/bad/output/path" file_pathname = os.path.join(file_path, file_name) - data = 'output data' + data = "output data" with pytest.raises(IOError): write_output(file_name, file_path, data) # noinspection PyUnresolvedReferences - yacfg.output.open.assert_called_with(file_pathname, 'w') + yacfg.output.open.assert_called_with(file_pathname, "w") diff --git a/tests/test_yacfg/profiles/fakes.py b/tests/test_yacfg/profiles/fakes.py index 7fec726f..7f3ab5f2 100644 --- a/tests/test_yacfg/profiles/fakes.py +++ b/tests/test_yacfg/profiles/fakes.py @@ -17,33 +17,20 @@ def fake_get_tuned_profile_data(*_): - return {'_defaults': {'default_key': 'default_value'}, 'key': 'value'} + return {"_defaults": {"default_key": "default_value"}, "key": "value"} def fake_get_tuned_profile(*_): - return ( - '_defaults:\n' - ' default_key: default_value\n' - '' - 'key: value\n' - ) + return "_defaults:\n" " default_key: default_value\n" "" "key: value\n" def fake_load_tuned_profile_with_defaults(*_): - return ( - fake_get_tuned_profile_data(), - fake_get_tuned_profile() - ) + return fake_get_tuned_profile_data(), fake_get_tuned_profile() def fake_load_tuned_profile_no_defaults(*_, **kwargs): del kwargs - return ( - {'key': 'value'}, - ( - 'key: value\n' - ) - ) + return {"key": "value"}, "key: value\n" def fake_template_environment(*_): @@ -53,21 +40,14 @@ def fake_template_environment(*_): def fake_load_tuned_profile_w_template(*_, **kwargs): del kwargs return ( - {'render': {'template': 'template/1.0.0'}, 'key': 'value'}, - ( - '_render:\n' - ' template: template/1.0.0\n' - '\n' - 'key: value\n' - ) + {"render": {"template": "template/1.0.0"}, "key": "value"}, + "_render:\n" " template: template/1.0.0\n" "\n" "key: value\n", ) def fake_load_profile_defaults(*_): - return {'default_key': 'default_value'} + return {"default_key": "default_value"} def fake_profile_defaults_yaml(*_): - return ( - 'default_key: default_value\n' - ) + return "default_key: default_value\n" diff --git a/tests/test_yacfg/profiles/test_get_profile_template.py b/tests/test_yacfg/profiles/test_get_profile_template.py index c942a09b..d25c490f 100644 --- a/tests/test_yacfg/profiles/test_get_profile_template.py +++ b/tests/test_yacfg/profiles/test_get_profile_template.py @@ -21,18 +21,17 @@ from ..files.fakes import fake_select_profile_file, fake_profiles_path -@mock.patch('yacfg.profiles.select_profile_file', - side_effect=fake_select_profile_file) -@mock.patch('os.path.isdir', side_effect=(True,)) -@mock.patch('yacfg.profiles.get_profiles_path', - side_effect=fake_profiles_path) -@mock.patch('yacfg.profiles.FileSystemLoader', mock.Mock()) -@mock.patch('yacfg.profiles.Environment', mock.Mock()) +@mock.patch("yacfg.profiles.select_profile_file", side_effect=fake_select_profile_file) +@mock.patch("os.path.isdir", side_effect=(True,)) +@mock.patch("yacfg.profiles.get_profiles_path", side_effect=fake_profiles_path) +@mock.patch("yacfg.profiles.FileSystemLoader", mock.Mock()) +@mock.patch("yacfg.profiles.Environment", mock.Mock()) def test_true(*_): - profile_name = 'profile.yaml' - expected_template = 'my_template' - expected_selected_name, expected_selected_path = \ - fake_select_profile_file(profile_name) + profile_name = "profile.yaml" + expected_template = "my_template" + expected_selected_name, expected_selected_path = fake_select_profile_file( + profile_name + ) fake_env = mock.Mock() yacfg.profiles.Environment.return_value = fake_env @@ -44,23 +43,20 @@ def test_true(*_): # noinspection PyUnresolvedReferences yacfg.profiles.select_profile_file.assert_called_with(profile_name) # noinspection PyUnresolvedReferences - yacfg.profiles.FileSystemLoader.assert_called_with([ - expected_selected_path, - fake_profiles_path() - ]) + yacfg.profiles.FileSystemLoader.assert_called_with( + [expected_selected_path, fake_profiles_path()] + ) fake_env.get_template.assert_called_with(expected_selected_name) -@mock.patch('yacfg.profiles.select_profile_file', - side_effect=fake_select_profile_file) -@mock.patch('os.path.isdir', side_effect=(False,)) -@mock.patch('yacfg.profiles.get_profiles_path', - side_effect=fake_profiles_path) -@mock.patch('yacfg.profiles.FileSystemLoader', mock.Mock()) -@mock.patch('yacfg.profiles.Environment', mock.Mock()) +@mock.patch("yacfg.profiles.select_profile_file", side_effect=fake_select_profile_file) +@mock.patch("os.path.isdir", side_effect=(False,)) +@mock.patch("yacfg.profiles.get_profiles_path", side_effect=fake_profiles_path) +@mock.patch("yacfg.profiles.FileSystemLoader", mock.Mock()) +@mock.patch("yacfg.profiles.Environment", mock.Mock()) def test_bad_profile_exception(*_): - profile_name = 'bad_profile.yaml' - expected_template = 'my_template' + profile_name = "bad_profile.yaml" + expected_template = "my_template" fake_env = mock.Mock() yacfg.profiles.Environment.return_value = fake_env diff --git a/tests/test_yacfg/profiles/test_get_tuned_profile.py b/tests/test_yacfg/profiles/test_get_tuned_profile.py index f52985a0..43070cf0 100644 --- a/tests/test_yacfg/profiles/test_get_tuned_profile.py +++ b/tests/test_yacfg/profiles/test_get_tuned_profile.py @@ -23,11 +23,11 @@ from .fakes import fake_load_tuned_profile_no_defaults -@mock.patch('yacfg.profiles.load_tuning', mock.Mock()) -@mock.patch('yacfg.profiles.load_profile_defaults', mock.Mock()) -@mock.patch('yacfg.profiles.get_profile_template', mock.Mock()) +@mock.patch("yacfg.profiles.load_tuning", mock.Mock()) +@mock.patch("yacfg.profiles.load_profile_defaults", mock.Mock()) +@mock.patch("yacfg.profiles.get_profile_template", mock.Mock()) def test_no_tuning(*_): - profile_name = 'profile.yaml' + profile_name = "profile.yaml" tuning_data = None expected_data = fake_load_tuned_profile_no_defaults() @@ -59,18 +59,16 @@ def test_no_tuning(*_): yacfg.profiles.get_profile_template.assert_called_with(profile_name) expected_data_render = copy.deepcopy(expected_data[0]) - expected_data_render['profile_path'] = profile_name - fake_profile.render.assert_called_with( - expected_data_render - ) + expected_data_render["profile_path"] = profile_name + fake_profile.render.assert_called_with(expected_data_render) -@mock.patch('yacfg.profiles.load_tuning', mock.Mock()) -@mock.patch('yacfg.profiles.load_profile_defaults', mock.Mock()) -@mock.patch('yacfg.profiles.get_profile_template', mock.Mock()) +@mock.patch("yacfg.profiles.load_tuning", mock.Mock()) +@mock.patch("yacfg.profiles.load_profile_defaults", mock.Mock()) +@mock.patch("yacfg.profiles.get_profile_template", mock.Mock()) def test_tuning_data(*_): - profile_name = 'profile.yaml' - tuning_data = [{'a': 1}] + profile_name = "profile.yaml" + tuning_data = [{"a": 1}] expected_data = fake_load_tuned_profile_no_defaults() # mock load_tuning @@ -104,19 +102,17 @@ def test_tuning_data(*_): yacfg.profiles.get_profile_template.assert_called_with(profile_name) expected_data_render = copy.deepcopy(expected_data[0]) - expected_data_render['profile_path'] = profile_name - fake_profile.render.assert_called_with( - expected_data_render - ) + expected_data_render["profile_path"] = profile_name + fake_profile.render.assert_called_with(expected_data_render) -@mock.patch('yacfg.profiles.load_tuning', mock.Mock()) -@mock.patch('yacfg.profiles.load_profile_defaults', mock.Mock()) -@mock.patch('yacfg.profiles.get_profile_template', mock.Mock()) +@mock.patch("yacfg.profiles.load_tuning", mock.Mock()) +@mock.patch("yacfg.profiles.load_profile_defaults", mock.Mock()) +@mock.patch("yacfg.profiles.get_profile_template", mock.Mock()) def test_tuning_files_data(*_): - profile_name = 'profile.yaml' - tuning_data = [{'a': 1}] - tuning_files = ['asdf.yaml'] + profile_name = "profile.yaml" + tuning_data = [{"a": 1}] + tuning_files = ["asdf.yaml"] expected_data = fake_load_tuned_profile_no_defaults() # mock load_tuning @@ -151,19 +147,17 @@ def test_tuning_files_data(*_): yacfg.profiles.get_profile_template.assert_called_with(profile_name) expected_data_render = copy.deepcopy(expected_data[0]) - expected_data_render['profile_path'] = profile_name - fake_profile.render.assert_called_with( - expected_data_render - ) + expected_data_render["profile_path"] = profile_name + fake_profile.render.assert_called_with(expected_data_render) -@mock.patch('yacfg.profiles.load_tuning', mock.Mock()) -@mock.patch('yacfg.profiles.load_profile_defaults', mock.Mock()) -@mock.patch('yacfg.profiles.get_profile_template', mock.Mock()) +@mock.patch("yacfg.profiles.load_tuning", mock.Mock()) +@mock.patch("yacfg.profiles.load_profile_defaults", mock.Mock()) +@mock.patch("yacfg.profiles.get_profile_template", mock.Mock()) def test_tuning_files(*_): - profile_name = 'profile.yaml' + profile_name = "profile.yaml" tuning_data = None - tuning_files = ['asdf.yaml'] + tuning_files = ["asdf.yaml"] expected_data = fake_load_tuned_profile_no_defaults() # mock load_tuning @@ -198,22 +192,18 @@ def test_tuning_files(*_): yacfg.profiles.get_profile_template.assert_called_with(profile_name) expected_data_render = copy.deepcopy(expected_data[0]) - expected_data_render['profile_path'] = profile_name - fake_profile.render.assert_called_with( - expected_data_render - ) + expected_data_render["profile_path"] = profile_name + fake_profile.render.assert_called_with(expected_data_render) -@mock.patch('yacfg.profiles.load_profile_defaults', - side_effect=ProfileError) -@mock.patch('yacfg.profiles.open', - side_effect=('%this is not yaml',)) -@mock.patch('yaml.load', mock.Mock()) -@mock.patch('yacfg.profiles.get_profile_template', mock.Mock()) +@mock.patch("yacfg.profiles.load_profile_defaults", side_effect=ProfileError) +@mock.patch("yacfg.profiles.open", side_effect=("%this is not yaml",)) +@mock.patch("yaml.load", mock.Mock()) +@mock.patch("yacfg.profiles.get_profile_template", mock.Mock()) def test_bad_profile_exception(*_): - profile_name = 'profile.yaml' - tuning_files = ['bad'] - expected_data = 'key: value\n' + profile_name = "profile.yaml" + tuning_files = ["bad"] + expected_data = "key: value\n" # simulating jinja profile rendering fake_profile = mock.Mock() diff --git a/tests/test_yacfg/profiles/test_load_profile_defaults.py b/tests/test_yacfg/profiles/test_load_profile_defaults.py index 42ab2560..a1c0bb52 100644 --- a/tests/test_yacfg/profiles/test_load_profile_defaults.py +++ b/tests/test_yacfg/profiles/test_load_profile_defaults.py @@ -24,9 +24,9 @@ ) -@mock.patch('yacfg.profiles.get_profile_template', mock.Mock()) +@mock.patch("yacfg.profiles.get_profile_template", mock.Mock()) def test_true(*_): - profile_name = 'profile.yaml' + profile_name = "profile.yaml" expected_data = fake_load_profile_defaults() # fake jinja template @@ -41,10 +41,9 @@ def test_true(*_): yacfg.profiles.get_profile_template.assert_called_with(profile_name) -@mock.patch('yacfg.profiles.get_profile_template', - side_effect=TemplateError) +@mock.patch("yacfg.profiles.get_profile_template", side_effect=TemplateError) def test_bad_template(*_): - profile_name = 'bad_profile.yaml' + profile_name = "bad_profile.yaml" with pytest.raises(TemplateError): load_profile_defaults(profile_name) diff --git a/tests/test_yacfg/query/test_filter_template_list.py b/tests/test_yacfg/query/test_filter_template_list.py index fbb7e456..e2d7c960 100644 --- a/tests/test_yacfg/query/test_filter_template_list.py +++ b/tests/test_yacfg/query/test_filter_template_list.py @@ -17,26 +17,25 @@ from yacfg.query import filter_template_list basic_template_list = [ - 'a.xml', - 'a.txt', - 'b.xml', - 'b.txt', - 'c.xml', - 'c.properties', + "a.xml", + "a.txt", + "b.xml", + "b.txt", + "c.xml", + "c.properties", ] dataset_filter_basic = ( - ([''], basic_template_list), - (['a.*'], ['a.xml', 'a.txt']), - (['b.*'], ['b.xml', 'b.txt']), - (['.*xml'], ['a.xml', 'b.xml', 'c.xml']), - (['.*xml', '.*txt'], ['a.xml', 'a.txt', 'b.xml', 'b.txt', 'c.xml']), - (['xxx'], []), + ([""], basic_template_list), + (["a.*"], ["a.xml", "a.txt"]), + (["b.*"], ["b.xml", "b.txt"]), + ([".*xml"], ["a.xml", "b.xml", "c.xml"]), + ([".*xml", ".*txt"], ["a.xml", "a.txt", "b.xml", "b.txt", "c.xml"]), + (["xxx"], []), ) -@pytest.mark.parametrize('output_filter,expected_result', dataset_filter_basic) +@pytest.mark.parametrize("output_filter,expected_result", dataset_filter_basic) def test_filter_basic(output_filter, expected_result): - result = filter_template_list(basic_template_list, - output_filter=output_filter) + result = filter_template_list(basic_template_list, output_filter=output_filter) assert result == expected_result diff --git a/tests/test_yacfg/query/test_get_main_template_list.py b/tests/test_yacfg/query/test_get_main_template_list.py index 98344d8a..6461f783 100644 --- a/tests/test_yacfg/query/test_get_main_template_list.py +++ b/tests/test_yacfg/query/test_get_main_template_list.py @@ -19,17 +19,17 @@ def fake_list_templates(filter_func): file_list = [ - 'broker.xml.jinja2', - 'artemis-users.properties.jinja2', - 'not_a_template.xml', + "broker.xml.jinja2", + "artemis-users.properties.jinja2", + "not_a_template.xml", ] return [i for i in file_list if filter_func(i)] def test_basic(*_): expected = [ - 'broker.xml.jinja2', - 'artemis-users.properties.jinja2', + "broker.xml.jinja2", + "artemis-users.properties.jinja2", ] env = mock.Mock() env.list_templates = fake_list_templates diff --git a/tests/test_yacfg/query/test_list_profiles.py b/tests/test_yacfg/query/test_list_profiles.py index 85eaac79..99ddc59e 100644 --- a/tests/test_yacfg/query/test_list_profiles.py +++ b/tests/test_yacfg/query/test_list_profiles.py @@ -23,52 +23,24 @@ def fake_os_walk_profiles_basic(*_): prefix_path = fake_profiles_path() return [ - ( - os.path.join(prefix_path, ''), - ['a', 'b', 'x', '_not'], - ['profile.yaml'] - ), - ( - os.path.join(prefix_path, 'a'), - ['b'], - ['profile.yaml', 'something.txt'] - ), - ( - os.path.join(prefix_path, 'a', 'b'), - [], - ['profile.yaml'] - ), - ( - os.path.join(prefix_path, 'b'), - [], - ['my_profile.yaml'] - ), - ( - os.path.join(prefix_path, 'x'), - ['_not'], - ['something.txt'] - ), - ( - os.path.join(prefix_path, 'x', '_not'), - [], - ['not_a_profile.yaml'] - ), - ( - os.path.join(prefix_path, '_not'), - [], - ['also_not_a_profile.yaml'] - ), + (os.path.join(prefix_path, ""), ["a", "b", "x", "_not"], ["profile.yaml"]), + (os.path.join(prefix_path, "a"), ["b"], ["profile.yaml", "something.txt"]), + (os.path.join(prefix_path, "a", "b"), [], ["profile.yaml"]), + (os.path.join(prefix_path, "b"), [], ["my_profile.yaml"]), + (os.path.join(prefix_path, "x"), ["_not"], ["something.txt"]), + (os.path.join(prefix_path, "x", "_not"), [], ["not_a_profile.yaml"]), + (os.path.join(prefix_path, "_not"), [], ["also_not_a_profile.yaml"]), ] -@mock.patch('yacfg.query.get_profiles_path', side_effect=fake_profiles_path) -@mock.patch('os.walk', side_effect=fake_os_walk_profiles_basic) +@mock.patch("yacfg.query.get_profiles_path", side_effect=fake_profiles_path) +@mock.patch("os.walk", side_effect=fake_os_walk_profiles_basic) def test_basic(*_): expected = [ - 'profile.yaml', - 'a/profile.yaml', - 'a/b/profile.yaml', - 'b/my_profile.yaml', + "profile.yaml", + "a/profile.yaml", + "a/b/profile.yaml", + "b/my_profile.yaml", ] result = list_profiles() assert result == expected @@ -77,34 +49,22 @@ def test_basic(*_): def fake_os_walk_not_a_profile(*_): prefix_path = fake_profiles_path() return [ - ( - os.path.join(prefix_path, 'x'), - ['_not'], - ['something.txt'] - ), - ( - os.path.join(prefix_path, 'x', '_not'), - [], - ['not_a_profile.yaml'] - ), - ( - os.path.join(prefix_path, '_not'), - [], - ['also_not_a_profile.yaml'] - ), + (os.path.join(prefix_path, "x"), ["_not"], ["something.txt"]), + (os.path.join(prefix_path, "x", "_not"), [], ["not_a_profile.yaml"]), + (os.path.join(prefix_path, "_not"), [], ["also_not_a_profile.yaml"]), ] -@mock.patch('yacfg.query.get_profiles_path', side_effect=fake_module_path) -@mock.patch('os.walk', side_effect=fake_os_walk_not_a_profile) +@mock.patch("yacfg.query.get_profiles_path", side_effect=fake_module_path) +@mock.patch("os.walk", side_effect=fake_os_walk_not_a_profile) def test_not_a_profile(*_): expected = [] result = list_profiles() assert result == expected -@mock.patch('yacfg.query.get_profiles_path', side_effect=fake_module_path) -@mock.patch('os.walk', side_effect=((),)) +@mock.patch("yacfg.query.get_profiles_path", side_effect=fake_module_path) +@mock.patch("os.walk", side_effect=((),)) def test_empty(*_): expected = [] result = list_profiles() diff --git a/tests/test_yacfg/query/test_list_templates.py b/tests/test_yacfg/query/test_list_templates.py index ebff8bad..ad5f8095 100644 --- a/tests/test_yacfg/query/test_list_templates.py +++ b/tests/test_yacfg/query/test_list_templates.py @@ -24,71 +24,69 @@ def fake_walk_templates_basic(*_): prefix_path = fake_templates_path() return [ ( - os.path.join(prefix_path, 'a'), - ['modules'], - ['broker.xml.jinja2', '_template'] + os.path.join(prefix_path, "a"), + ["modules"], + ["broker.xml.jinja2", "_template"], ), + (os.path.join(prefix_path, "a/modules"), ["broker_xml"], ["add-on.jinja2"]), + (os.path.join(prefix_path, "a/modules/broker_xml"), [], ["queues.jinja2"]), + (os.path.join(prefix_path, "b"), ["1.0.0"], []), ( - os.path.join(prefix_path, 'a/modules'), - ['broker_xml'], - ['add-on.jinja2'] + os.path.join(prefix_path, "b/1.0.0"), + ["modules"], + [ + "management.xml.jinja2", + "artemis-roles.properties.jinja2", + "broker.xml.jinja2", + "artemis.profile.jinja2", + "bootstrap.xml.jinja2", + "jolokia-access.xml.jinja2", + "artemis-users.properties.jinja2", + "logging.properties.jinja2", + "login.config.jinja2", + "_template", + ], ), + (os.path.join(prefix_path, "b/1.0.0/modules"), [], ["broker_xml.jinja2"]), ( - os.path.join(prefix_path, 'a/modules/broker_xml'), - [], - ['queues.jinja2'] + os.path.join(prefix_path, "not_a_template"), + ["a"], + [ + "acceptors.jinja2", + "store.jinja2", + "cluster_connections.jinja2", + "security_settings.jinja2", + "journal.jinja2", + "broadcast_group.jinja2", + "discovery_group.jinja2", + "cluster.jinja2", + "addresses.jinja2", + "critical_analyzer.jinja2", + "grouping_handler.jinja2", + "ha_policy.jinja2", + "duplicate_cache.jinja2", + "queue.jinja2", + "broker_plugins.jinja2", + "wildcards_addresses.jinja2", + "address_settings.jinja2", + "connectors.jinja2", + ], ), ( - os.path.join(prefix_path, 'b'), - ['1.0.0'], [] - ), - ( - os.path.join(prefix_path, 'b/1.0.0'), - ['modules'], - ['management.xml.jinja2', 'artemis-roles.properties.jinja2', - 'broker.xml.jinja2', 'artemis.profile.jinja2', - 'bootstrap.xml.jinja2', 'jolokia-access.xml.jinja2', - 'artemis-users.properties.jinja2', - 'logging.properties.jinja2', - 'login.config.jinja2', '_template'] - ), - ( - os.path.join(prefix_path, 'b/1.0.0/modules'), - [], ['broker_xml.jinja2'] - ), - ( - os.path.join(prefix_path, 'not_a_template'), - ['a'], - ['acceptors.jinja2', 'store.jinja2', - 'cluster_connections.jinja2', - 'security_settings.jinja2', 'journal.jinja2', - 'broadcast_group.jinja2', 'discovery_group.jinja2', - 'cluster.jinja2', 'addresses.jinja2', - 'critical_analyzer.jinja2', - 'grouping_handler.jinja2', 'ha_policy.jinja2', - 'duplicate_cache.jinja2', 'queue.jinja2', - 'broker_plugins.jinja2', - 'wildcards_addresses.jinja2', 'address_settings.jinja2', - 'connectors.jinja2']), - ( - os.path.join(prefix_path, 'not_a_template/a'), - ['x'], - ['security_setting.jinja2', 'security_setting_plugin.jinja2'] - ), - ( - os.path.join(prefix_path, 'not_a_template/a/x'), - [], - ['jdbc.jinja2'] + os.path.join(prefix_path, "not_a_template/a"), + ["x"], + ["security_setting.jinja2", "security_setting_plugin.jinja2"], ), + (os.path.join(prefix_path, "not_a_template/a/x"), [], ["jdbc.jinja2"]), ] -@mock.patch('yacfg.query.get_templates_path', side_effect=fake_templates_path) -@mock.patch('os.walk', side_effect=fake_walk_templates_basic) +@mock.patch("yacfg.query.get_templates_path", side_effect=fake_templates_path) +@mock.patch("os.walk", side_effect=fake_walk_templates_basic) def test_true(*_): expected = [ - 'a', - 'b/1.0.0', + "a", + "b/1.0.0", ] result = list_templates() @@ -99,34 +97,40 @@ def fake_walk_templates_not_a_template(*_): prefix_path = fake_templates_path() return [ ( - os.path.join(prefix_path, 'not_a_template'), - ['a'], - ['acceptors.jinja2', 'store.jinja2', - 'cluster_connections.jinja2', - 'security_settings.jinja2', 'journal.jinja2', - 'broadcast_group.jinja2', 'discovery_group.jinja2', - 'cluster.jinja2', 'addresses.jinja2', - 'critical_analyzer.jinja2', - 'grouping_handler.jinja2', 'ha_policy.jinja2', - 'duplicate_cache.jinja2', 'queue.jinja2', - 'broker_plugins.jinja2', - 'wildcards_addresses.jinja2', 'address_settings.jinja2', - 'connectors.jinja2']), - ( - os.path.join(prefix_path, 'not_a_template/a'), - ['x'], - ['security_setting.jinja2', 'security_setting_plugin.jinja2'] + os.path.join(prefix_path, "not_a_template"), + ["a"], + [ + "acceptors.jinja2", + "store.jinja2", + "cluster_connections.jinja2", + "security_settings.jinja2", + "journal.jinja2", + "broadcast_group.jinja2", + "discovery_group.jinja2", + "cluster.jinja2", + "addresses.jinja2", + "critical_analyzer.jinja2", + "grouping_handler.jinja2", + "ha_policy.jinja2", + "duplicate_cache.jinja2", + "queue.jinja2", + "broker_plugins.jinja2", + "wildcards_addresses.jinja2", + "address_settings.jinja2", + "connectors.jinja2", + ], ), ( - os.path.join(prefix_path, 'not_a_template/a/x'), - [], - ['jdbc.jinja2'] + os.path.join(prefix_path, "not_a_template/a"), + ["x"], + ["security_setting.jinja2", "security_setting_plugin.jinja2"], ), + (os.path.join(prefix_path, "not_a_template/a/x"), [], ["jdbc.jinja2"]), ] -@mock.patch('yacfg.query.get_templates_path', side_effect=fake_templates_path) -@mock.patch('os.walk', side_effect=fake_walk_templates_not_a_template) +@mock.patch("yacfg.query.get_templates_path", side_effect=fake_templates_path) +@mock.patch("os.walk", side_effect=fake_walk_templates_not_a_template) def test_not_a_template(*_): expected = [] @@ -134,8 +138,8 @@ def test_not_a_template(*_): assert result == expected -@mock.patch('yacfg.query.get_templates_path', side_effect=fake_templates_path) -@mock.patch('os.walk', side_effect=((),)) +@mock.patch("yacfg.query.get_templates_path", side_effect=fake_templates_path) +@mock.patch("os.walk", side_effect=((),)) def test_empty(*_): expected = [] diff --git a/tests/test_yacfg/templates/test_get_template_environment.py b/tests/test_yacfg/templates/test_get_template_environment.py index 605a954b..b8881102 100644 --- a/tests/test_yacfg/templates/test_get_template_environment.py +++ b/tests/test_yacfg/templates/test_get_template_environment.py @@ -23,13 +23,13 @@ from ..files.fakes import fake_templates_path -@mock.patch('yacfg.templates.get_templates_path', side_effect=fake_templates_path) -@mock.patch('yacfg.templates.select_template_dir', side_effect=fake_select_template_dir) -@mock.patch('yacfg.templates.FileSystemLoader', mock.Mock()) -@mock.patch('yacfg.templates.Environment', mock.Mock()) +@mock.patch("yacfg.templates.get_templates_path", side_effect=fake_templates_path) +@mock.patch("yacfg.templates.select_template_dir", side_effect=fake_select_template_dir) +@mock.patch("yacfg.templates.FileSystemLoader", mock.Mock()) +@mock.patch("yacfg.templates.Environment", mock.Mock()) def test_true(*_): - template_name = 'template/1.0.0' - expected_env = 'template environment' + template_name = "template/1.0.0" + expected_env = "template environment" expected_template_path = fake_templates_path() expected_selected_templates = fake_select_template_dir(template_name) @@ -42,18 +42,18 @@ def test_true(*_): # noinspection PyUnresolvedReferences yacfg.templates.select_template_dir.assert_called_with(template_name) # noinspection PyUnresolvedReferences - yacfg.templates.FileSystemLoader.assert_called_with([ - expected_selected_templates, expected_template_path - ]) + yacfg.templates.FileSystemLoader.assert_called_with( + [expected_selected_templates, expected_template_path] + ) -@mock.patch('yacfg.templates.get_templates_path', side_effect=fake_templates_path) -@mock.patch('yacfg.templates.select_template_dir', side_effect=fake_select_template_dir) -@mock.patch('yacfg.templates.FileSystemLoader', side_effect=jinja2.TemplateError) -@mock.patch('yacfg.templates.Environment', mock.Mock()) +@mock.patch("yacfg.templates.get_templates_path", side_effect=fake_templates_path) +@mock.patch("yacfg.templates.select_template_dir", side_effect=fake_select_template_dir) +@mock.patch("yacfg.templates.FileSystemLoader", side_effect=jinja2.TemplateError) +@mock.patch("yacfg.templates.Environment", mock.Mock()) def test_jinja_loader_exception(*_): - template_name = 'template/1.0.0' - expected_env = 'template environment' + template_name = "template/1.0.0" + expected_env = "template environment" yacfg.templates.Environment.return_value = expected_env @@ -62,13 +62,13 @@ def test_jinja_loader_exception(*_): get_template_environment(template_name) -@mock.patch('yacfg.templates.get_templates_path', side_effect=fake_templates_path) -@mock.patch('yacfg.templates.select_template_dir', side_effect=fake_select_template_dir) -@mock.patch('yacfg.templates.FileSystemLoader', mock.Mock()) -@mock.patch('yacfg.templates.Environment', side_effect=jinja2.TemplateError) +@mock.patch("yacfg.templates.get_templates_path", side_effect=fake_templates_path) +@mock.patch("yacfg.templates.select_template_dir", side_effect=fake_select_template_dir) +@mock.patch("yacfg.templates.FileSystemLoader", mock.Mock()) +@mock.patch("yacfg.templates.Environment", side_effect=jinja2.TemplateError) def test_jinja_environment_exception(*_): - template_name = 'template/1.0.0' - expected_env = 'template environment' + template_name = "template/1.0.0" + expected_env = "template environment" yacfg.templates.Environment.return_value = expected_env diff --git a/tests/test_yacfg/test_generate.py b/tests/test_yacfg/test_generate.py index 42f0a236..70242f37 100644 --- a/tests/test_yacfg/test_generate.py +++ b/tests/test_yacfg/test_generate.py @@ -21,42 +21,39 @@ from .profiles.fakes import ( fake_load_tuned_profile_no_defaults, fake_load_tuned_profile_w_template, - fake_template_environment + fake_template_environment, ) -@mock.patch('yacfg.yacfg.get_tuned_profile', - side_effect=fake_load_tuned_profile_no_defaults) -@mock.patch('yacfg.yacfg.add_template_metadata', mock.Mock()) -@mock.patch('yacfg.yacfg.add_render_config', mock.Mock()) -@mock.patch('yacfg.yacfg.get_template_environment', - side_effect=fake_template_environment) -@mock.patch('yacfg.yacfg.get_main_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.filter_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.ensure_output_path', mock.Mock()) -@mock.patch('yacfg.yacfg.write_output', mock.Mock()) -@mock.patch('yacfg.yacfg.generate_outputs', mock.Mock()) +@mock.patch( + "yacfg.yacfg.get_tuned_profile", side_effect=fake_load_tuned_profile_no_defaults +) +@mock.patch("yacfg.yacfg.add_template_metadata", mock.Mock()) +@mock.patch("yacfg.yacfg.add_render_config", mock.Mock()) +@mock.patch( + "yacfg.yacfg.get_template_environment", side_effect=fake_template_environment +) +@mock.patch("yacfg.yacfg.get_main_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.filter_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.ensure_output_path", mock.Mock()) +@mock.patch("yacfg.yacfg.write_output", mock.Mock()) +@mock.patch("yacfg.yacfg.generate_outputs", mock.Mock()) def test_true_render_options(*_): - profile = 'profile.yaml' - template = 'template/1.0.0' - render_options = 'Render options' - expected_result = 'generated data' + profile = "profile.yaml" + template = "template/1.0.0" + render_options = "Render options" + expected_result = "generated data" config_data, _ = fake_load_tuned_profile_no_defaults() yacfg.yacfg.generate_outputs.return_value = expected_result - result = generate( - profile=profile, - template=template, - render_options=render_options - ) + result = generate(profile=profile, template=template, render_options=render_options) assert expected_result == result # noinspection PyUnresolvedReferences - yacfg.yacfg.add_render_config.assert_called_with(config_data, - render_options) + yacfg.yacfg.add_render_config.assert_called_with(config_data, render_options) # noinspection PyUnresolvedReferences yacfg.yacfg.get_template_environment.assert_called() # noinspection PyUnresolvedReferences @@ -71,22 +68,22 @@ def test_true_render_options(*_): yacfg.yacfg.generate_outputs.assert_called() -@mock.patch('yacfg.yacfg.get_tuned_profile', mock.Mock()) -@mock.patch('yacfg.yacfg.get_template_environment', - side_effect=fake_template_environment) -@mock.patch('yacfg.yacfg.get_main_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.filter_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.ensure_output_path', mock.Mock()) -@mock.patch('yacfg.yacfg.write_output', mock.Mock()) -@mock.patch('yacfg.yacfg.generate_outputs', mock.Mock()) +@mock.patch("yacfg.yacfg.get_tuned_profile", mock.Mock()) +@mock.patch( + "yacfg.yacfg.get_template_environment", side_effect=fake_template_environment +) +@mock.patch("yacfg.yacfg.get_main_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.filter_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.ensure_output_path", mock.Mock()) +@mock.patch("yacfg.yacfg.write_output", mock.Mock()) +@mock.patch("yacfg.yacfg.generate_outputs", mock.Mock()) def test_true_tuning_files(*_): - profile = 'profile.yaml' - template = 'template/1.0.0' - tuning_files = ['tune1.yaml', 'tune2.yaml'] - expected_result = 'generated data' + profile = "profile.yaml" + template = "template/1.0.0" + tuning_files = ["tune1.yaml", "tune2.yaml"] + expected_result = "generated data" - yacfg.yacfg.get_tuned_profile.side_effect = \ - fake_load_tuned_profile_no_defaults + yacfg.yacfg.get_tuned_profile.side_effect = fake_load_tuned_profile_no_defaults yacfg.yacfg.generate_outputs.return_value = expected_result result = generate( @@ -117,26 +114,27 @@ def test_true_tuning_files(*_): yacfg.yacfg.generate_outputs.assert_called() -@mock.patch('yacfg.yacfg.get_tuned_profile', - side_effect=fake_load_tuned_profile_no_defaults) -@mock.patch('yacfg.yacfg.get_template_environment', - side_effect=fake_template_environment) -@mock.patch('yacfg.yacfg.get_main_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.filter_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.ensure_output_path', mock.Mock()) -@mock.patch('yacfg.yacfg.write_output', mock.Mock()) -@mock.patch('yacfg.yacfg.generate_outputs', mock.Mock()) +@mock.patch( + "yacfg.yacfg.get_tuned_profile", side_effect=fake_load_tuned_profile_no_defaults +) +@mock.patch( + "yacfg.yacfg.get_template_environment", side_effect=fake_template_environment +) +@mock.patch("yacfg.yacfg.get_main_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.filter_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.ensure_output_path", mock.Mock()) +@mock.patch("yacfg.yacfg.write_output", mock.Mock()) +@mock.patch("yacfg.yacfg.generate_outputs", mock.Mock()) def test_true_tuning_data(*_): - profile = 'profile.yaml' - template = 'template/1.0.0' + profile = "profile.yaml" + template = "template/1.0.0" tuning_data = [ - {'a': '1'}, - {'b': '2'}, + {"a": "1"}, + {"b": "2"}, ] - expected_result = 'generated data' + expected_result = "generated data" - yacfg.yacfg.get_tuned_profile.side_effect = \ - fake_load_tuned_profile_no_defaults + yacfg.yacfg.get_tuned_profile.side_effect = fake_load_tuned_profile_no_defaults yacfg.yacfg.generate_outputs.return_value = expected_result result = generate( @@ -167,19 +165,21 @@ def test_true_tuning_data(*_): yacfg.yacfg.generate_outputs.assert_called() -@mock.patch('yacfg.yacfg.get_tuned_profile', - side_effect=fake_load_tuned_profile_no_defaults) -@mock.patch('yacfg.yacfg.get_template_environment', - side_effect=fake_template_environment) -@mock.patch('yacfg.yacfg.get_main_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.filter_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.ensure_output_path', mock.Mock()) -@mock.patch('yacfg.yacfg.write_output', mock.Mock()) -@mock.patch('yacfg.yacfg.generate_outputs', mock.Mock()) +@mock.patch( + "yacfg.yacfg.get_tuned_profile", side_effect=fake_load_tuned_profile_no_defaults +) +@mock.patch( + "yacfg.yacfg.get_template_environment", side_effect=fake_template_environment +) +@mock.patch("yacfg.yacfg.get_main_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.filter_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.ensure_output_path", mock.Mock()) +@mock.patch("yacfg.yacfg.write_output", mock.Mock()) +@mock.patch("yacfg.yacfg.generate_outputs", mock.Mock()) def test_true_no_output_path_write_profile(*_): - profile = 'profile.yaml' - template = 'template/1.0.0' - expected_result = 'generated data' + profile = "profile.yaml" + template = "template/1.0.0" + expected_result = "generated data" yacfg.yacfg.generate_outputs.return_value = expected_result @@ -205,20 +205,22 @@ def test_true_no_output_path_write_profile(*_): yacfg.yacfg.generate_outputs.assert_called() -@mock.patch('yacfg.yacfg.get_tuned_profile', - side_effect=fake_load_tuned_profile_no_defaults) -@mock.patch('yacfg.yacfg.get_template_environment', - side_effect=fake_template_environment) -@mock.patch('yacfg.yacfg.get_main_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.filter_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.ensure_output_path', mock.Mock()) -@mock.patch('yacfg.yacfg.write_output', mock.Mock()) -@mock.patch('yacfg.yacfg.generate_outputs', mock.Mock()) +@mock.patch( + "yacfg.yacfg.get_tuned_profile", side_effect=fake_load_tuned_profile_no_defaults +) +@mock.patch( + "yacfg.yacfg.get_template_environment", side_effect=fake_template_environment +) +@mock.patch("yacfg.yacfg.get_main_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.filter_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.ensure_output_path", mock.Mock()) +@mock.patch("yacfg.yacfg.write_output", mock.Mock()) +@mock.patch("yacfg.yacfg.generate_outputs", mock.Mock()) def test_true_output_path_write_profile(*_): - profile = 'profile.yaml' - template = 'template/1.0.0' - output_path = '/out/directory' - expected_result = 'generated data' + profile = "profile.yaml" + template = "template/1.0.0" + output_path = "/out/directory" + expected_result = "generated data" yacfg.yacfg.generate_outputs.return_value = expected_result @@ -245,20 +247,22 @@ def test_true_output_path_write_profile(*_): yacfg.yacfg.generate_outputs.assert_called() -@mock.patch('yacfg.yacfg.get_tuned_profile', - side_effect=fake_load_tuned_profile_no_defaults) -@mock.patch('yacfg.yacfg.get_template_environment', - side_effect=fake_template_environment) -@mock.patch('yacfg.yacfg.get_main_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.filter_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.ensure_output_path', mock.Mock()) -@mock.patch('yacfg.yacfg.write_output', mock.Mock()) -@mock.patch('yacfg.yacfg.generate_outputs', mock.Mock()) +@mock.patch( + "yacfg.yacfg.get_tuned_profile", side_effect=fake_load_tuned_profile_no_defaults +) +@mock.patch( + "yacfg.yacfg.get_template_environment", side_effect=fake_template_environment +) +@mock.patch("yacfg.yacfg.get_main_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.filter_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.ensure_output_path", mock.Mock()) +@mock.patch("yacfg.yacfg.write_output", mock.Mock()) +@mock.patch("yacfg.yacfg.generate_outputs", mock.Mock()) def test_true_output_path(*_): - profile = 'profile.yaml' - template = 'template/1.0.0' - output_path = '/out/directory' - expected_result = 'generated data' + profile = "profile.yaml" + template = "template/1.0.0" + output_path = "/out/directory" + expected_result = "generated data" yacfg.yacfg.generate_outputs.return_value = expected_result @@ -284,19 +288,21 @@ def test_true_output_path(*_): yacfg.yacfg.generate_outputs.assert_called() -@mock.patch('yacfg.yacfg.get_tuned_profile', - side_effect=fake_load_tuned_profile_no_defaults) -@mock.patch('yacfg.yacfg.get_template_environment', - side_effect=fake_template_environment) -@mock.patch('yacfg.yacfg.get_main_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.filter_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.ensure_output_path', mock.Mock()) -@mock.patch('yacfg.yacfg.write_output', mock.Mock()) -@mock.patch('yacfg.yacfg.generate_outputs', mock.Mock()) +@mock.patch( + "yacfg.yacfg.get_tuned_profile", side_effect=fake_load_tuned_profile_no_defaults +) +@mock.patch( + "yacfg.yacfg.get_template_environment", side_effect=fake_template_environment +) +@mock.patch("yacfg.yacfg.get_main_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.filter_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.ensure_output_path", mock.Mock()) +@mock.patch("yacfg.yacfg.write_output", mock.Mock()) +@mock.patch("yacfg.yacfg.generate_outputs", mock.Mock()) def test_true_template(*_): - profile = 'profile.yaml' - template = 'template/1.0.0' - expected_result = 'generated data' + profile = "profile.yaml" + template = "template/1.0.0" + expected_result = "generated data" yacfg.yacfg.generate_outputs.return_value = expected_result @@ -321,18 +327,20 @@ def test_true_template(*_): yacfg.yacfg.generate_outputs.assert_called() -@mock.patch('yacfg.yacfg.get_tuned_profile', - side_effect=fake_load_tuned_profile_w_template) -@mock.patch('yacfg.yacfg.get_template_environment', - side_effect=fake_template_environment) -@mock.patch('yacfg.yacfg.get_main_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.filter_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.ensure_output_path', mock.Mock()) -@mock.patch('yacfg.yacfg.write_output', mock.Mock()) -@mock.patch('yacfg.yacfg.generate_outputs', mock.Mock()) +@mock.patch( + "yacfg.yacfg.get_tuned_profile", side_effect=fake_load_tuned_profile_w_template +) +@mock.patch( + "yacfg.yacfg.get_template_environment", side_effect=fake_template_environment +) +@mock.patch("yacfg.yacfg.get_main_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.filter_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.ensure_output_path", mock.Mock()) +@mock.patch("yacfg.yacfg.write_output", mock.Mock()) +@mock.patch("yacfg.yacfg.generate_outputs", mock.Mock()) def test_true_profile_template(*_): - profile = 'profile.yaml' - expected_result = 'generated data' + profile = "profile.yaml" + expected_result = "generated data" yacfg.yacfg.generate_outputs.return_value = expected_result @@ -354,16 +362,17 @@ def test_true_profile_template(*_): yacfg.yacfg.generate_outputs.assert_called() -@mock.patch('yacfg.yacfg.get_tuned_profile', - side_effect=fake_load_tuned_profile_no_defaults) -@mock.patch('yacfg.yacfg.get_template_environment', mock.Mock()) -@mock.patch('yacfg.yacfg.get_main_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.filter_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.ensure_output_path', mock.Mock()) -@mock.patch('yacfg.yacfg.write_output', mock.Mock()) -@mock.patch('yacfg.yacfg.generate_outputs', mock.Mock()) +@mock.patch( + "yacfg.yacfg.get_tuned_profile", side_effect=fake_load_tuned_profile_no_defaults +) +@mock.patch("yacfg.yacfg.get_template_environment", mock.Mock()) +@mock.patch("yacfg.yacfg.get_main_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.filter_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.ensure_output_path", mock.Mock()) +@mock.patch("yacfg.yacfg.write_output", mock.Mock()) +@mock.patch("yacfg.yacfg.generate_outputs", mock.Mock()) def test_no_template_exception(*_): - profile = 'profile.yaml' + profile = "profile.yaml" with pytest.raises(TemplateError): generate(profile=profile) @@ -382,15 +391,15 @@ def test_no_template_exception(*_): yacfg.yacfg.generate_outputs.assert_not_called() -@mock.patch('yacfg.yacfg.get_tuned_profile', side_effect=ProfileError) -@mock.patch('yacfg.yacfg.get_template_environment', mock.Mock()) -@mock.patch('yacfg.yacfg.get_main_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.filter_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.ensure_output_path', mock.Mock()) -@mock.patch('yacfg.yacfg.write_output', mock.Mock()) -@mock.patch('yacfg.yacfg.generate_outputs', mock.Mock()) +@mock.patch("yacfg.yacfg.get_tuned_profile", side_effect=ProfileError) +@mock.patch("yacfg.yacfg.get_template_environment", mock.Mock()) +@mock.patch("yacfg.yacfg.get_main_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.filter_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.ensure_output_path", mock.Mock()) +@mock.patch("yacfg.yacfg.write_output", mock.Mock()) +@mock.patch("yacfg.yacfg.generate_outputs", mock.Mock()) def test_bad_profile_exception(*_): - profile = 'bad_profile.yaml' + profile = "bad_profile.yaml" with pytest.raises(ProfileError): generate(profile=profile) diff --git a/tests/test_yacfg/test_generate_core.py b/tests/test_yacfg/test_generate_core.py index 1abeb94a..ed288b82 100644 --- a/tests/test_yacfg/test_generate_core.py +++ b/tests/test_yacfg/test_generate_core.py @@ -21,39 +21,37 @@ from .profiles.fakes import ( fake_load_tuned_profile_no_defaults, fake_load_tuned_profile_w_template, - fake_template_environment + fake_template_environment, ) -@mock.patch('yacfg.yacfg.add_template_metadata', mock.Mock()) -@mock.patch('yacfg.yacfg.add_render_config', mock.Mock()) -@mock.patch('yacfg.yacfg.get_template_environment', - side_effect=fake_template_environment) -@mock.patch('yacfg.yacfg.get_main_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.filter_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.ensure_output_path', mock.Mock()) -@mock.patch('yacfg.yacfg.write_output', mock.Mock()) -@mock.patch('yacfg.yacfg.generate_outputs', mock.Mock()) +@mock.patch("yacfg.yacfg.add_template_metadata", mock.Mock()) +@mock.patch("yacfg.yacfg.add_render_config", mock.Mock()) +@mock.patch( + "yacfg.yacfg.get_template_environment", side_effect=fake_template_environment +) +@mock.patch("yacfg.yacfg.get_main_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.filter_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.ensure_output_path", mock.Mock()) +@mock.patch("yacfg.yacfg.write_output", mock.Mock()) +@mock.patch("yacfg.yacfg.generate_outputs", mock.Mock()) def test_true(*_): - template = 'template/1.0.0' - render_options = 'Render options' - expected_result = 'generated data' + template = "template/1.0.0" + render_options = "Render options" + expected_result = "generated data" config_data, _ = fake_load_tuned_profile_no_defaults() yacfg.yacfg.generate_outputs.return_value = expected_result result = generate_core( - config_data=config_data, - template=template, - render_options=render_options + config_data=config_data, template=template, render_options=render_options ) assert expected_result == result # noinspection PyUnresolvedReferences - yacfg.yacfg.add_render_config.assert_called_with(config_data, - render_options) + yacfg.yacfg.add_render_config.assert_called_with(config_data, render_options) # noinspection PyUnresolvedReferences yacfg.yacfg.get_template_environment.assert_called() # noinspection PyUnresolvedReferences @@ -68,16 +66,17 @@ def test_true(*_): yacfg.yacfg.generate_outputs.assert_called() -@mock.patch('yacfg.yacfg.get_template_environment', - side_effect=fake_template_environment) -@mock.patch('yacfg.yacfg.get_main_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.filter_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.ensure_output_path', mock.Mock()) -@mock.patch('yacfg.yacfg.write_output', mock.Mock()) -@mock.patch('yacfg.yacfg.generate_outputs', mock.Mock()) +@mock.patch( + "yacfg.yacfg.get_template_environment", side_effect=fake_template_environment +) +@mock.patch("yacfg.yacfg.get_main_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.filter_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.ensure_output_path", mock.Mock()) +@mock.patch("yacfg.yacfg.write_output", mock.Mock()) +@mock.patch("yacfg.yacfg.generate_outputs", mock.Mock()) def test_true_no_output_path_write_profile(*_): - template = 'template/1.0.0' - expected_result = 'generated data' + template = "template/1.0.0" + expected_result = "generated data" config_data, tuned_profile = fake_load_tuned_profile_no_defaults() yacfg.yacfg.generate_outputs.return_value = expected_result @@ -105,16 +104,17 @@ def test_true_no_output_path_write_profile(*_): yacfg.yacfg.generate_outputs.assert_called() -@mock.patch('yacfg.yacfg.get_template_environment', - side_effect=fake_template_environment) -@mock.patch('yacfg.yacfg.get_main_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.filter_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.ensure_output_path', mock.Mock()) -@mock.patch('yacfg.yacfg.write_output', mock.Mock()) -@mock.patch('yacfg.yacfg.generate_outputs', mock.Mock()) +@mock.patch( + "yacfg.yacfg.get_template_environment", side_effect=fake_template_environment +) +@mock.patch("yacfg.yacfg.get_main_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.filter_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.ensure_output_path", mock.Mock()) +@mock.patch("yacfg.yacfg.write_output", mock.Mock()) +@mock.patch("yacfg.yacfg.generate_outputs", mock.Mock()) def test_true_output_path_write_no_profile(*_): - template = 'template/1.0.0' - expected_result = 'generated data' + template = "template/1.0.0" + expected_result = "generated data" config_data, _ = fake_load_tuned_profile_no_defaults() yacfg.yacfg.generate_outputs.return_value = expected_result @@ -141,17 +141,18 @@ def test_true_output_path_write_no_profile(*_): yacfg.yacfg.generate_outputs.assert_called() -@mock.patch('yacfg.yacfg.get_template_environment', - side_effect=fake_template_environment) -@mock.patch('yacfg.yacfg.get_main_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.filter_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.ensure_output_path', mock.Mock()) -@mock.patch('yacfg.yacfg.write_output', mock.Mock()) -@mock.patch('yacfg.yacfg.generate_outputs', mock.Mock()) +@mock.patch( + "yacfg.yacfg.get_template_environment", side_effect=fake_template_environment +) +@mock.patch("yacfg.yacfg.get_main_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.filter_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.ensure_output_path", mock.Mock()) +@mock.patch("yacfg.yacfg.write_output", mock.Mock()) +@mock.patch("yacfg.yacfg.generate_outputs", mock.Mock()) def test_true_output_path_write_profile(*_): - template = 'template/1.0.0' - output_path = '/out/directory' - expected_result = 'generated data' + template = "template/1.0.0" + output_path = "/out/directory" + expected_result = "generated data" config_data, tuned_profile = fake_load_tuned_profile_no_defaults() yacfg.yacfg.generate_outputs.return_value = expected_result @@ -180,17 +181,18 @@ def test_true_output_path_write_profile(*_): yacfg.yacfg.generate_outputs.assert_called() -@mock.patch('yacfg.yacfg.get_template_environment', - side_effect=fake_template_environment) -@mock.patch('yacfg.yacfg.get_main_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.filter_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.ensure_output_path', mock.Mock()) -@mock.patch('yacfg.yacfg.write_output', mock.Mock()) -@mock.patch('yacfg.yacfg.generate_outputs', mock.Mock()) +@mock.patch( + "yacfg.yacfg.get_template_environment", side_effect=fake_template_environment +) +@mock.patch("yacfg.yacfg.get_main_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.filter_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.ensure_output_path", mock.Mock()) +@mock.patch("yacfg.yacfg.write_output", mock.Mock()) +@mock.patch("yacfg.yacfg.generate_outputs", mock.Mock()) def test_true_output_path(*_): - template = 'template/1.0.0' - output_path = '/out/directory' - expected_result = 'generated data' + template = "template/1.0.0" + output_path = "/out/directory" + expected_result = "generated data" config_data, tuned_profile = fake_load_tuned_profile_no_defaults() yacfg.yacfg.generate_outputs.return_value = expected_result @@ -218,16 +220,17 @@ def test_true_output_path(*_): yacfg.yacfg.generate_outputs.assert_called() -@mock.patch('yacfg.yacfg.get_template_environment', - side_effect=fake_template_environment) -@mock.patch('yacfg.yacfg.get_main_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.filter_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.ensure_output_path', mock.Mock()) -@mock.patch('yacfg.yacfg.write_output', mock.Mock()) -@mock.patch('yacfg.yacfg.generate_outputs', mock.Mock()) +@mock.patch( + "yacfg.yacfg.get_template_environment", side_effect=fake_template_environment +) +@mock.patch("yacfg.yacfg.get_main_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.filter_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.ensure_output_path", mock.Mock()) +@mock.patch("yacfg.yacfg.write_output", mock.Mock()) +@mock.patch("yacfg.yacfg.generate_outputs", mock.Mock()) def test_true_template(*_): - template = 'template/1.0.0' - expected_result = 'generated data' + template = "template/1.0.0" + expected_result = "generated data" config_data, _ = fake_load_tuned_profile_no_defaults() yacfg.yacfg.generate_outputs.return_value = expected_result @@ -253,15 +256,16 @@ def test_true_template(*_): yacfg.yacfg.generate_outputs.assert_called() -@mock.patch('yacfg.yacfg.get_template_environment', - side_effect=fake_template_environment) -@mock.patch('yacfg.yacfg.get_main_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.filter_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.ensure_output_path', mock.Mock()) -@mock.patch('yacfg.yacfg.write_output', mock.Mock()) -@mock.patch('yacfg.yacfg.generate_outputs', mock.Mock()) +@mock.patch( + "yacfg.yacfg.get_template_environment", side_effect=fake_template_environment +) +@mock.patch("yacfg.yacfg.get_main_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.filter_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.ensure_output_path", mock.Mock()) +@mock.patch("yacfg.yacfg.write_output", mock.Mock()) +@mock.patch("yacfg.yacfg.generate_outputs", mock.Mock()) def test_true_profile_template(*_): - expected_result = 'generated data' + expected_result = "generated data" config_data, _ = fake_load_tuned_profile_w_template() yacfg.yacfg.generate_outputs.return_value = expected_result @@ -284,12 +288,12 @@ def test_true_profile_template(*_): yacfg.yacfg.generate_outputs.assert_called() -@mock.patch('yacfg.yacfg.get_template_environment', mock.Mock()) -@mock.patch('yacfg.yacfg.get_main_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.filter_template_list', mock.Mock()) -@mock.patch('yacfg.yacfg.ensure_output_path', mock.Mock()) -@mock.patch('yacfg.yacfg.write_output', mock.Mock()) -@mock.patch('yacfg.yacfg.generate_outputs', mock.Mock()) +@mock.patch("yacfg.yacfg.get_template_environment", mock.Mock()) +@mock.patch("yacfg.yacfg.get_main_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.filter_template_list", mock.Mock()) +@mock.patch("yacfg.yacfg.ensure_output_path", mock.Mock()) +@mock.patch("yacfg.yacfg.write_output", mock.Mock()) +@mock.patch("yacfg.yacfg.generate_outputs", mock.Mock()) def test_no_template_exception(*_): config_data, _ = fake_load_tuned_profile_no_defaults() diff --git a/tests/test_yacfg/test_generate_outputs.py b/tests/test_yacfg/test_generate_outputs.py index 114902bc..71ae38aa 100644 --- a/tests/test_yacfg/test_generate_outputs.py +++ b/tests/test_yacfg/test_generate_outputs.py @@ -21,50 +21,43 @@ from yacfg.exceptions import GenerationError -@mock.patch('yacfg.yacfg.write_output', mock.Mock()) +@mock.patch("yacfg.yacfg.write_output", mock.Mock()) def test_one_true_no_output(*_): config_data = {} template_list = [ - 'broker.xml.jinja2', + "broker.xml.jinja2", ] - expected_result_data = { - 'broker.xml': 'Rendered data' - } + expected_result_data = {"broker.xml": "Rendered data"} env = mock.Mock() template = mock.Mock() env.get_template.return_value = template - template.render.return_value = 'Rendered data' + template.render.return_value = "Rendered data" # noinspection PyTypeChecker result = generate_outputs( - config_data=config_data, - template_list=template_list, - env=env, - output_path=None + config_data=config_data, template_list=template_list, env=env, output_path=None ) assert expected_result_data == result - env.get_template.assert_called_with('broker.xml.jinja2') + env.get_template.assert_called_with("broker.xml.jinja2") template.render.assert_called() # noinspection PyUnresolvedReferences yacfg.yacfg.write_output.assert_not_called() -@mock.patch('yacfg.yacfg.write_output', mock.Mock()) +@mock.patch("yacfg.yacfg.write_output", mock.Mock()) def test_one_true_output(*_): config_data = {} - output_file = 'broker.xml' - output_path = '/output/directory' - expected_output_data = 'Rendered data' + output_file = "broker.xml" + output_path = "/output/directory" + expected_output_data = "Rendered data" template_list = [ - '%s.jinja2' % output_file, + "%s.jinja2" % output_file, ] - expected_result_data = { - output_file: 'Rendered data' - } + expected_result_data = {output_file: "Rendered data"} env = mock.Mock() template = mock.Mock() @@ -76,25 +69,26 @@ def test_one_true_output(*_): config_data=config_data, template_list=template_list, env=env, - output_path=output_path + output_path=output_path, ) assert expected_result_data == result - env.get_template.assert_called_with('broker.xml.jinja2') + env.get_template.assert_called_with("broker.xml.jinja2") template.render.assert_called() # noinspection PyUnresolvedReferences - yacfg.yacfg.write_output.assert_called_with(output_file, output_path, - expected_output_data) + yacfg.yacfg.write_output.assert_called_with( + output_file, output_path, expected_output_data + ) -@mock.patch('yacfg.yacfg.write_output', mock.Mock()) +@mock.patch("yacfg.yacfg.write_output", mock.Mock()) def test_one_exception_render(*_): config_data = {} - output_file = 'broker.xml' - output_path = '/output/directory' + output_file = "broker.xml" + output_path = "/output/directory" template_list = [ - '%s.jinja2' % output_file, + "%s.jinja2" % output_file, ] env = mock.Mock() @@ -108,22 +102,22 @@ def test_one_exception_render(*_): config_data=config_data, template_list=template_list, env=env, - output_path=output_path + output_path=output_path, ) - env.get_template.assert_called_with('broker.xml.jinja2') + env.get_template.assert_called_with("broker.xml.jinja2") template.render.assert_called() # noinspection PyUnresolvedReferences yacfg.yacfg.write_output.assert_not_called() -@mock.patch('yacfg.yacfg.write_output', mock.Mock()) +@mock.patch("yacfg.yacfg.write_output", mock.Mock()) def test_one_exception_template(*_): config_data = {} - output_file = 'broker.xml' - output_path = '/output/directory' + output_file = "broker.xml" + output_path = "/output/directory" template_list = [ - '%s.jinja2' % output_file, + "%s.jinja2" % output_file, ] env = mock.Mock() @@ -135,9 +129,9 @@ def test_one_exception_template(*_): config_data=config_data, template_list=template_list, env=env, - output_path=output_path + output_path=output_path, ) - env.get_template.assert_called_with('broker.xml.jinja2') + env.get_template.assert_called_with("broker.xml.jinja2") # noinspection PyUnresolvedReferences yacfg.yacfg.write_output.assert_not_called() diff --git a/tests/test_yacfg_batch/fakes.py b/tests/test_yacfg_batch/fakes.py index 201d4f54..4d044819 100644 --- a/tests/test_yacfg_batch/fakes.py +++ b/tests/test_yacfg_batch/fakes.py @@ -18,43 +18,31 @@ def fake_iter_gen_profiles_one(filename): del filename yield { - '_default': { - 'tuning_files': ['a', 'b'] - }, - '_common': { - 'profile': 'Profile Name' - } + "_default": {"tuning_files": ["a", "b"]}, + "_common": {"profile": "Profile Name"}, } def fake_iter_gen_profiles_two(filename): del filename yield { - '_default': { - 'tuning_files': ['a', 'b'] - }, - '_common': { - 'profile': 'Profile Name' - } + "_default": {"tuning_files": ["a", "b"]}, + "_common": {"profile": "Profile Name"}, } yield { - '_default': { - 'tuning_files': ['c', 'd'] - }, - '_common': { - 'profile': 'Profile Name 2' - } + "_default": {"tuning_files": ["c", "d"]}, + "_common": {"profile": "Profile Name 2"}, } fake_default_one = GenerateData() -fake_default_one.tuning_files = ['a', 'b'] +fake_default_one.tuning_files = ["a", "b"] fake_common_one = GenerateData() -fake_common_one.profile_name = 'Profile Name' +fake_common_one.profile_name = "Profile Name" fake_default_two = GenerateData() -fake_default_two.tuning_files = ['c', 'd'] +fake_default_two.tuning_files = ["c", "d"] fake_common_two = GenerateData() -fake_common_two.profile_name = 'Profile Name 2' +fake_common_two.profile_name = "Profile Name 2" diff --git a/tests/test_yacfg_batch/test_GenerateData.py b/tests/test_yacfg_batch/test_GenerateData.py index 4717b329..4d139041 100644 --- a/tests/test_yacfg_batch/test_GenerateData.py +++ b/tests/test_yacfg_batch/test_GenerateData.py @@ -12,9 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from yacfg_batch.yacfg_batch import ( - GenerateData -) +from yacfg_batch.yacfg_batch import GenerateData def test_str_none(*_): @@ -22,15 +20,15 @@ def test_str_none(*_): result = str(generate_data) - expected = 'GenerateData(None, None, None, None)' + expected = "GenerateData(None, None, None, None)" assert expected == result def test_str_str(*_): generate_data = GenerateData() - generate_data.profile_name = 'a' - generate_data.template_name = 'b' + generate_data.profile_name = "a" + generate_data.template_name = "b" result = str(generate_data) @@ -48,79 +46,79 @@ def test_eq_empty(*_): def test_eq_data(*_): data1 = GenerateData() - data1.profile_name = 'Profile Name' - data1.template_name = 'Template Name' - data1.tuning_files = ['Tuning file'] - data1.tuning_data = {'a': 1} + data1.profile_name = "Profile Name" + data1.template_name = "Template Name" + data1.tuning_files = ["Tuning file"] + data1.tuning_data = {"a": 1} data2 = GenerateData() - data2.profile_name = 'Profile Name' - data2.template_name = 'Template Name' - data2.tuning_files = ['Tuning file'] - data2.tuning_data = {'a': 1} + data2.profile_name = "Profile Name" + data2.template_name = "Template Name" + data2.tuning_files = ["Tuning file"] + data2.tuning_data = {"a": 1} assert data1 == data2 def test_neq_profile_name(*_): data1 = GenerateData() - data1.profile_name = 'Profile Nam' - data1.template_name = 'Template Name' - data1.tuning_files = ['Tuning file'] - data1.tuning_data = {'a': 1} + data1.profile_name = "Profile Nam" + data1.template_name = "Template Name" + data1.tuning_files = ["Tuning file"] + data1.tuning_data = {"a": 1} data2 = GenerateData() - data2.profile_name = 'Profile Name' - data2.template_name = 'Template Name' - data2.tuning_files = ['Tuning file'] - data2.tuning_data = {'a': 1} + data2.profile_name = "Profile Name" + data2.template_name = "Template Name" + data2.tuning_files = ["Tuning file"] + data2.tuning_data = {"a": 1} assert data1 != data2 def test_neq_template_name(*_): data1 = GenerateData() - data1.profile_name = 'Profile Name' - data1.template_name = 'Template Nam' - data1.tuning_files = ['Tuning file'] - data1.tuning_data = {'a': 1} + data1.profile_name = "Profile Name" + data1.template_name = "Template Nam" + data1.tuning_files = ["Tuning file"] + data1.tuning_data = {"a": 1} data2 = GenerateData() - data2.profile_name = 'Profile Name' - data2.template_name = 'Template Name' - data2.tuning_files = ['Tuning file'] - data2.tuning_data = {'a': 1} + data2.profile_name = "Profile Name" + data2.template_name = "Template Name" + data2.tuning_files = ["Tuning file"] + data2.tuning_data = {"a": 1} assert data1 != data2 def test_neq_tuning_files(*_): data1 = GenerateData() - data1.profile_name = 'Profile Name' - data1.template_name = 'Template Name' - data1.tuning_files = ['Tuning fil'] - data1.tuning_data = {'a': 1} + data1.profile_name = "Profile Name" + data1.template_name = "Template Name" + data1.tuning_files = ["Tuning fil"] + data1.tuning_data = {"a": 1} data2 = GenerateData() - data2.profile_name = 'Profile Name' - data2.template_name = 'Template Name' - data2.tuning_files = ['Tuning file'] - data2.tuning_data = {'a': 1} + data2.profile_name = "Profile Name" + data2.template_name = "Template Name" + data2.tuning_files = ["Tuning file"] + data2.tuning_data = {"a": 1} assert data1 != data2 def test_neq_tuning_data(*_): data1 = GenerateData() - data1.profile_name = 'Profile Name' - data1.template_name = 'Template Name' - data1.tuning_files = ['Tuning file'] - data1.tuning_data = {'a': 0} + data1.profile_name = "Profile Name" + data1.template_name = "Template Name" + data1.tuning_files = ["Tuning file"] + data1.tuning_data = {"a": 0} data2 = GenerateData() - data2.profile_name = 'Profile Name' - data2.template_name = 'Template Name' - data2.tuning_files = ['Tuning file'] - data2.tuning_data = {'a': 1} + data2.profile_name = "Profile Name" + data2.template_name = "Template Name" + data2.tuning_files = ["Tuning file"] + data2.tuning_data = {"a": 1} assert data1 != data2 diff --git a/tests/test_yacfg_batch/test_extract_generate_data.py b/tests/test_yacfg_batch/test_extract_generate_data.py index 01fa1eff..7644d6ef 100644 --- a/tests/test_yacfg_batch/test_extract_generate_data.py +++ b/tests/test_yacfg_batch/test_extract_generate_data.py @@ -12,10 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from yacfg_batch.yacfg_batch import ( - extract_generate_data, - GenerateData -) +from yacfg_batch.yacfg_batch import extract_generate_data, GenerateData def test_empty(*_): @@ -29,53 +26,45 @@ def test_empty(*_): def test_default(*_): - profile_file_data = { - '_default': { - 'profile': 'Profile Name' - } - } + profile_file_data = {"_default": {"profile": "Profile Name"}} result = extract_generate_data(profile_file_data) expected = GenerateData() - expected.profile_name = 'Profile Name' + expected.profile_name = "Profile Name" assert expected == result def test_section(*_): - profile_file_data = { - '_section': { - 'profile': 'Profile Name' - } - } + profile_file_data = {"_section": {"profile": "Profile Name"}} - result = extract_generate_data(profile_file_data, '_section') + result = extract_generate_data(profile_file_data, "_section") expected = GenerateData() - expected.profile_name = 'Profile Name' + expected.profile_name = "Profile Name" assert expected == result def test_data(*_): profile_file_data = { - '_default': { - 'profile': 'Profile Name', - 'template': 'Template Name', - 'tuning_files': ['Tuning Files'], - 'tuning': { - 'a': 1, - } + "_default": { + "profile": "Profile Name", + "template": "Template Name", + "tuning_files": ["Tuning Files"], + "tuning": { + "a": 1, + }, } } result = extract_generate_data(profile_file_data) expected = GenerateData() - expected.profile_name = 'Profile Name' - expected.template_name = 'Template Name' - expected.tuning_files = ['Tuning Files'] - expected.tuning_data = {'a': 1} + expected.profile_name = "Profile Name" + expected.template_name = "Template Name" + expected.tuning_files = ["Tuning Files"] + expected.tuning_data = {"a": 1} assert expected == result diff --git a/tests/test_yacfg_batch/test_generate.py b/tests/test_yacfg_batch/test_generate.py index 4e2086ff..8c1a7658 100644 --- a/tests/test_yacfg_batch/test_generate.py +++ b/tests/test_yacfg_batch/test_generate.py @@ -26,66 +26,53 @@ ) -@mock.patch('yacfg_batch.yacfg_batch.generate_all_profiles', mock.Mock()) -@mock.patch('yacfg_batch.yacfg_batch.iter_gen_profiles', - fake_iter_gen_profiles_one) +@mock.patch("yacfg_batch.yacfg_batch.generate_all_profiles", mock.Mock()) +@mock.patch("yacfg_batch.yacfg_batch.iter_gen_profiles", fake_iter_gen_profiles_one) def test_one(*_): - input_files = ['a/b.yaml'] + input_files = ["a/b.yaml"] generate(input_files) # noinspection PyUnresolvedReferences yacfg_batch.yacfg_batch.generate_all_profiles.assert_called_with( - 'a', + "a", None, fake_default_one, fake_common_one, - next(fake_iter_gen_profiles_one(None)) + next(fake_iter_gen_profiles_one(None)), ) -@mock.patch('yacfg_batch.yacfg_batch.generate_all_profiles', mock.Mock()) -@mock.patch('yacfg_batch.yacfg_batch.iter_gen_profiles', - fake_iter_gen_profiles_two) +@mock.patch("yacfg_batch.yacfg_batch.generate_all_profiles", mock.Mock()) +@mock.patch("yacfg_batch.yacfg_batch.iter_gen_profiles", fake_iter_gen_profiles_two) def test_two(*_): - input_files = ['a/b.yaml'] + input_files = ["a/b.yaml"] generate(input_files) profile_data = list(fake_iter_gen_profiles_two(None)) calls = [ - mock.call('a', None, fake_default_one, - fake_common_one, profile_data[0]), - mock.call('a', None, fake_default_two, - fake_common_two, profile_data[1]), + mock.call("a", None, fake_default_one, fake_common_one, profile_data[0]), + mock.call("a", None, fake_default_two, fake_common_two, profile_data[1]), ] # noinspection PyUnresolvedReferences - yacfg_batch.yacfg_batch.generate_all_profiles.assert_has_calls( - calls - ) + yacfg_batch.yacfg_batch.generate_all_profiles.assert_has_calls(calls) -@mock.patch('yacfg_batch.yacfg_batch.generate_all_profiles', mock.Mock()) -@mock.patch('yacfg_batch.yacfg_batch.iter_gen_profiles', - fake_iter_gen_profiles_two) +@mock.patch("yacfg_batch.yacfg_batch.generate_all_profiles", mock.Mock()) +@mock.patch("yacfg_batch.yacfg_batch.iter_gen_profiles", fake_iter_gen_profiles_two) def test_two_files_two(*_): - input_files = ['a/b.yaml', 'c/d.yaml'] + input_files = ["a/b.yaml", "c/d.yaml"] generate(input_files) profile_data = list(fake_iter_gen_profiles_two(None)) calls = [ - mock.call('a', None, fake_default_one, - fake_common_one, profile_data[0]), - mock.call('a', None, fake_default_two, - fake_common_two, profile_data[1]), - mock.call('c', None, fake_default_one, - fake_common_one, profile_data[0]), - mock.call('c', None, fake_default_two, - fake_common_two, profile_data[1]), + mock.call("a", None, fake_default_one, fake_common_one, profile_data[0]), + mock.call("a", None, fake_default_two, fake_common_two, profile_data[1]), + mock.call("c", None, fake_default_one, fake_common_one, profile_data[0]), + mock.call("c", None, fake_default_two, fake_common_two, profile_data[1]), ] # noinspection PyUnresolvedReferences - yacfg_batch.yacfg_batch.generate_all_profiles.assert_has_calls( - calls - ) + yacfg_batch.yacfg_batch.generate_all_profiles.assert_has_calls(calls) diff --git a/tests/test_yacfg_batch/test_generate_all_profiles.py b/tests/test_yacfg_batch/test_generate_all_profiles.py index b2f5f920..f781aaf3 100644 --- a/tests/test_yacfg_batch/test_generate_all_profiles.py +++ b/tests/test_yacfg_batch/test_generate_all_profiles.py @@ -20,49 +20,37 @@ from yacfg_batch.exceptions import YacfgBatchException -@mock.patch('yacfg.yacfg.generate', mock.Mock()) +@mock.patch("yacfg.yacfg.generate", mock.Mock()) def test_no_profile_name(*_): - input_path = '' - output_path = '' + input_path = "" + output_path = "" default = GenerateData() common = GenerateData() - profile_file_data = { - 'service': {'pass': True} - } + profile_file_data = {"service": {"pass": True}} with pytest.raises(YacfgBatchException): generate_all_profiles( - input_path, - output_path, - default, - common, - profile_file_data + input_path, output_path, default, common, profile_file_data ) -@mock.patch('yacfg.yacfg.generate', mock.Mock()) +@mock.patch("yacfg.yacfg.generate", mock.Mock()) def test_basic(*_): - input_path = '' - output_path = '' + input_path = "" + output_path = "" default = GenerateData() common = GenerateData() profile_file_data = { - 'service': { - 'profile': 'test', + "service": { + "profile": "test", } } - generate_all_profiles( - input_path, - output_path, - default, - common, - profile_file_data - ) + generate_all_profiles(input_path, output_path, default, common, profile_file_data) # noinspection PyUnresolvedReferences yacfg.yacfg.generate.assert_called_with( - profile='test', + profile="test", template=None, output_path=None, tuning_files_list=None, @@ -70,48 +58,49 @@ def test_basic(*_): ) -@mock.patch('yacfg.yacfg.generate', mock.Mock()) +@mock.patch("yacfg.yacfg.generate", mock.Mock()) def test_advanced(*_): - input_path = '' - output_path = 'test' + input_path = "" + output_path = "test" default = GenerateData() - default.profile_name = 'test2' + default.profile_name = "test2" common = GenerateData() profile_file_data = { - '_default': { - 'profile': 'test2', + "_default": { + "profile": "test2", }, - 'service': { - 'profile': 'test', + "service": { + "profile": "test", }, - 'service2': { - 'tuning_files': ['a'] - }, - 'service3': { - 'template': 'My Template', - 'tuning': { - 'a': 1 - } - } + "service2": {"tuning_files": ["a"]}, + "service3": {"template": "My Template", "tuning": {"a": 1}}, } - generate_all_profiles( - input_path, - output_path, - default, - common, - profile_file_data - ) + generate_all_profiles(input_path, output_path, default, common, profile_file_data) import os calls = [ - mock.call(profile='test', template=None, output_path=os.path.join('test','service'), - tuning_files_list=None, tuning_data_list=None), - mock.call(profile='test2', template=None, output_path=os.path.join('test','service2'), - tuning_files_list=['a'], tuning_data_list=None), - mock.call(profile='test2', template='My Template', - output_path=os.path.join('test','service3'), tuning_files_list=None, - tuning_data_list=[{'a': 1}]), + mock.call( + profile="test", + template=None, + output_path=os.path.join("test", "service"), + tuning_files_list=None, + tuning_data_list=None, + ), + mock.call( + profile="test2", + template=None, + output_path=os.path.join("test", "service2"), + tuning_files_list=["a"], + tuning_data_list=None, + ), + mock.call( + profile="test2", + template="My Template", + output_path=os.path.join("test", "service3"), + tuning_files_list=None, + tuning_data_list=[{"a": 1}], + ), ] # noinspection PyUnresolvedReferences diff --git a/tests/test_yacfg_batch/test_iter_gen_profiles.py b/tests/test_yacfg_batch/test_iter_gen_profiles.py index 8b3c9e77..a0348707 100644 --- a/tests/test_yacfg_batch/test_iter_gen_profiles.py +++ b/tests/test_yacfg_batch/test_iter_gen_profiles.py @@ -20,11 +20,11 @@ from yacfg_batch.exceptions import YacfgBatchException -@mock.patch('yacfg_batch.yacfg_batch.open', mock.Mock()) -@mock.patch('yaml.load_all', mock.Mock()) +@mock.patch("yacfg_batch.yacfg_batch.open", mock.Mock()) +@mock.patch("yaml.load_all", mock.Mock()) def test_true(*_): - filename = 'test.yaml' - expected_result = [{'a': 1}, {'b': 1}] + filename = "test.yaml" + expected_result = [{"a": 1}, {"b": 1}] file_desc = mock.sentinel.file_desc # noinspection PyUnresolvedReferences yacfg_batch.yacfg_batch.open.return_value = file_desc @@ -40,13 +40,13 @@ def test_true(*_): yaml.load_all.assert_called_with(file_desc) -@mock.patch('yacfg_batch.yacfg_batch.open', - side_effect=IOError( - '[Errno 2] No such file or directory: \'test.yaml\'' - )) -@mock.patch('yaml.load_all', mock.Mock()) +@mock.patch( + "yacfg_batch.yacfg_batch.open", + side_effect=IOError("[Errno 2] No such file or directory: 'test.yaml'"), +) +@mock.patch("yaml.load_all", mock.Mock()) def test_io_error(*_): - filename = 'test.yaml' + filename = "test.yaml" with pytest.raises(YacfgBatchException): list(iter_gen_profiles(filename)) @@ -57,10 +57,10 @@ def test_io_error(*_): yaml.load_all.assert_not_called() -@mock.patch('yacfg_batch.yacfg_batch.open', mock.Mock()) -@mock.patch('yaml.load_all', side_effect=yaml.YAMLError('Cannot parse')) +@mock.patch("yacfg_batch.yacfg_batch.open", mock.Mock()) +@mock.patch("yaml.load_all", side_effect=yaml.YAMLError("Cannot parse")) def test_yaml_error(*_): - filename = 'test.yaml' + filename = "test.yaml" file_desc = mock.sentinel.file_desc # noinspection PyUnresolvedReferences yacfg_batch.yacfg_batch.open.return_value = file_desc diff --git a/tests/test_yacfg_batch/test_prioritize_generate_data.py b/tests/test_yacfg_batch/test_prioritize_generate_data.py index 4084aac3..bc8329cb 100644 --- a/tests/test_yacfg_batch/test_prioritize_generate_data.py +++ b/tests/test_yacfg_batch/test_prioritize_generate_data.py @@ -12,18 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -from yacfg_batch.yacfg_batch import ( - prioritize_generate_data, - GenerateData -) +from yacfg_batch.yacfg_batch import prioritize_generate_data, GenerateData def test_default(*_): default = GenerateData() - default.profile_name = 'Default Profile' - default.template_name = 'Default Template' - default.tuning_files = ['Default Tuning Files'] - default.tuning_data = {'Tuning Data': 'Default', 'Default': 'Tuning data'} + default.profile_name = "Default Profile" + default.template_name = "Default Template" + default.tuning_files = ["Default Tuning Files"] + default.tuning_data = {"Tuning Data": "Default", "Default": "Tuning data"} common = GenerateData() profile = GenerateData() @@ -36,16 +33,16 @@ def test_default(*_): def test_default_common(*_): default = GenerateData() - default.profile_name = 'Default Profile' - default.template_name = 'Default Template' - default.tuning_files = ['Default Tuning Files'] - default.tuning_data = {'Tuning Data': 'Default', 'Default': 'Tuning data'} + default.profile_name = "Default Profile" + default.template_name = "Default Template" + default.tuning_files = ["Default Tuning Files"] + default.tuning_data = {"Tuning Data": "Default", "Default": "Tuning data"} common = GenerateData() - common.profile_name = 'Common Profile' - common.template_name = 'Common Template' - common.tuning_files = ['Common Tuning Files'] - common.tuning_data = {'Tuning Data': 'Common', 'Common': 'Tuning data'} + common.profile_name = "Common Profile" + common.template_name = "Common Template" + common.tuning_files = ["Common Tuning Files"] + common.tuning_data = {"Tuning Data": "Common", "Common": "Tuning data"} profile = GenerateData() @@ -64,22 +61,22 @@ def test_default_common(*_): def test_default_common_profile(*_): default = GenerateData() - default.profile_name = 'Default Profile' - default.template_name = 'Default Template' - default.tuning_files = ['Default Tuning Files'] - default.tuning_data = {'Tuning Data': 'Default', 'Default': 'Tuning data'} + default.profile_name = "Default Profile" + default.template_name = "Default Template" + default.tuning_files = ["Default Tuning Files"] + default.tuning_data = {"Tuning Data": "Default", "Default": "Tuning data"} common = GenerateData() - common.profile_name = 'Common Profile' - common.template_name = 'Common Template' - common.tuning_files = ['Common Tuning Files'] - common.tuning_data = {'Tuning Data': 'Common', 'Common': 'Tuning data'} + common.profile_name = "Common Profile" + common.template_name = "Common Template" + common.tuning_files = ["Common Tuning Files"] + common.tuning_data = {"Tuning Data": "Common", "Common": "Tuning data"} profile = GenerateData() - profile.profile_name = 'Profile Profile' - profile.template_name = 'Profile Template' - profile.tuning_files = ['Profile Tuning Files'] - profile.tuning_data = {'Tuning Data': 'Profile', 'Profile': 'Tuning data'} + profile.profile_name = "Profile Profile" + profile.template_name = "Profile Template" + profile.tuning_files = ["Profile Tuning Files"] + profile.tuning_data = {"Tuning Data": "Profile", "Profile": "Tuning data"} expected = GenerateData() expected.profile_name = profile.profile_name @@ -100,10 +97,10 @@ def test_profile(*_): common = GenerateData() profile = GenerateData() - profile.profile_name = 'Profile Profile' - profile.template_name = 'Profile Template' - profile.tuning_files = ['Profile Tuning Files'] - profile.tuning_data = {'Tuning Data': 'Profile', 'Profile': 'Tuning data'} + profile.profile_name = "Profile Profile" + profile.template_name = "Profile Template" + profile.tuning_files = ["Profile Tuning Files"] + profile.tuning_data = {"Tuning Data": "Profile", "Profile": "Tuning data"} expected = profile @@ -116,10 +113,10 @@ def test_common(*_): default = GenerateData() common = GenerateData() - common.profile_name = 'Common Profile' - common.template_name = 'Common Template' - common.tuning_files = ['Common Tuning Files'] - common.tuning_data = {'Tuning Data': 'Common', 'Common': 'Tuning data'} + common.profile_name = "Common Profile" + common.template_name = "Common Template" + common.tuning_files = ["Common Tuning Files"] + common.tuning_data = {"Tuning Data": "Common", "Common": "Tuning data"} profile = GenerateData() From f9d23a79068d98ee6a93a7276d4199f798034854 Mon Sep 17 00:00:00 2001 From: Dominik Lenoch Date: Fri, 5 Nov 2021 16:45:07 +0100 Subject: [PATCH 5/8] FIX remove pytest addopts --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 94aa8604..b9c2b20a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -83,7 +83,6 @@ yacfg-batch = 'yacfg_batch.yacfg_batch_cli:main' [tool.pytest.ini_options] minversion = "6.0" -addopts = "-ra -vv --cov=yacfg --cov=yacfg_batch --cov-report=xml" testpaths = [ "tests" ] From e5ca4dac34bd9b624e7121ee2c948c988d2b95fe Mon Sep 17 00:00:00 2001 From: Dominik Lenoch Date: Fri, 5 Nov 2021 16:56:11 +0100 Subject: [PATCH 6/8] FIX Loader in iter_gen_profiles --- src/yacfg_batch/yacfg_batch.py | 2 +- tests/test_yacfg_batch/test_iter_gen_profiles.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/yacfg_batch/yacfg_batch.py b/src/yacfg_batch/yacfg_batch.py index 6b57b2da..6cc1a5c9 100644 --- a/src/yacfg_batch/yacfg_batch.py +++ b/src/yacfg_batch/yacfg_batch.py @@ -54,7 +54,7 @@ def iter_gen_profiles(filename): profile_data_list = None try: - profile_data_list = yaml.load_all(open(filename, "r")) + profile_data_list = yaml.load_all(open(filename, "r"), yaml.SafeLoader) except IOError as exc: raise YacfgBatchException( 'Unable to open gen profile "{}" {}'.format(filename, exc) diff --git a/tests/test_yacfg_batch/test_iter_gen_profiles.py b/tests/test_yacfg_batch/test_iter_gen_profiles.py index a0348707..41c48bda 100644 --- a/tests/test_yacfg_batch/test_iter_gen_profiles.py +++ b/tests/test_yacfg_batch/test_iter_gen_profiles.py @@ -37,7 +37,7 @@ def test_true(*_): # noinspection PyUnresolvedReferences yacfg_batch.yacfg_batch.open.assert_called() # noinspection PyUnresolvedReferences - yaml.load_all.assert_called_with(file_desc) + yaml.load_all.assert_called_with(file_desc, yaml.SafeLoader) @mock.patch( From 61d8cb1955e11f6d9f739da0343d8b3cb8744d99 Mon Sep 17 00:00:00 2001 From: Dominik Lenoch Date: Fri, 5 Nov 2021 17:26:05 +0100 Subject: [PATCH 7/8] UPD Optimize imports --- src/yacfg/cli_arguments.py | 8 ++++---- src/yacfg/config_data.py | 2 +- src/yacfg/yacfg.py | 1 - src/yacfg/yacfg_cli.py | 9 ++++----- src/yacfg_batch/cli_arguments.py | 2 +- src/yacfg_batch/yacfg_batch_cli.py | 4 ++-- tests/extras/test_broker_special_char.py | 1 + tests/files/test_ensure_output_path.py | 3 ++- tests/test_yacfg/cli_arguments/test_boolize.py | 1 + tests/test_yacfg/config_data/test_render_config.py | 1 + tests/test_yacfg/files/test_ensure_output_path.py | 3 ++- tests/test_yacfg/files/test_get_output_filename.py | 1 + tests/test_yacfg/output/test_new_profile.py | 4 ++-- tests/test_yacfg/output/test_new_profile_rendered.py | 2 +- tests/test_yacfg/output/test_write_output.py | 1 - tests/test_yacfg/test_generate.py | 2 +- tests/test_yacfg/test_generate_core.py | 2 +- tests/test_yacfg/test_generate_outputs.py | 2 +- tests/test_yacfg_batch/test_generate_all_profiles.py | 2 +- tests/test_yacfg_batch/test_iter_gen_profiles.py | 3 ++- 20 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/yacfg/cli_arguments.py b/src/yacfg/cli_arguments.py index fc9cb46c..636dcdd1 100644 --- a/src/yacfg/cli_arguments.py +++ b/src/yacfg/cli_arguments.py @@ -13,11 +13,11 @@ # limitations under the License. import argparse -import re import json +import re -from .meta import NAME, DESCRIPTION from . import __version__ +from .meta import NAME, DESCRIPTION parser = argparse.ArgumentParser( prog="{} {}".format(NAME, __version__), @@ -81,7 +81,7 @@ group_extra.add_argument( "--save-effective-profile", - help=("Write used profile data to output directory," " output has to be specified"), + help="Write used profile data to output directory," " output has to be specified", action="store_true", ) @@ -173,7 +173,7 @@ def boolize(data): - """Conver input values from string to bool if possible + """Convert input values from string to bool if possible :param data: input data from argparse :type data: str diff --git a/src/yacfg/config_data.py b/src/yacfg/config_data.py index 81b5269b..4416fad4 100644 --- a/src/yacfg/config_data.py +++ b/src/yacfg/config_data.py @@ -16,8 +16,8 @@ import time from collections import namedtuple -from .meta import NAME from . import __version__ +from .meta import NAME def add_template_metadata(config_data): diff --git a/src/yacfg/yacfg.py b/src/yacfg/yacfg.py index 823edcbb..b79e042f 100644 --- a/src/yacfg/yacfg.py +++ b/src/yacfg/yacfg.py @@ -14,7 +14,6 @@ from __future__ import print_function -import ast import copy import json import logging diff --git a/src/yacfg/yacfg_cli.py b/src/yacfg/yacfg_cli.py index 99003635..56ef33db 100644 --- a/src/yacfg/yacfg_cli.py +++ b/src/yacfg/yacfg_cli.py @@ -18,9 +18,10 @@ import os import sys -from .config_data import RenderOptions -from .yacfg import generate +from . import __version__ +from . import logger_settings from .cli_arguments import parser, boolize, parse_key_value_list +from .config_data import RenderOptions from .exceptions import TemplateError, ProfileError, GenerationError from .meta import NAME from .output import ( @@ -30,9 +31,7 @@ export_tuning_variables, ) from .query import list_templates, list_profiles - -from . import logger_settings -from . import __version__ +from .yacfg import generate logger_settings.config_console_logger() diff --git a/src/yacfg_batch/cli_arguments.py b/src/yacfg_batch/cli_arguments.py index 29491281..c47ae074 100644 --- a/src/yacfg_batch/cli_arguments.py +++ b/src/yacfg_batch/cli_arguments.py @@ -14,8 +14,8 @@ import argparse -from .meta import NAME, DESCRIPTION from . import __version__ +from .meta import NAME, DESCRIPTION parser = argparse.ArgumentParser( prog="{} {}".format(NAME, __version__), diff --git a/src/yacfg_batch/yacfg_batch_cli.py b/src/yacfg_batch/yacfg_batch_cli.py index ee34e608..171c8ab9 100644 --- a/src/yacfg_batch/yacfg_batch_cli.py +++ b/src/yacfg_batch/yacfg_batch_cli.py @@ -19,9 +19,9 @@ from yacfg import logger_settings from yacfg.meta import NAME -from .yacfg_batch import generate -from .cli_arguments import parser from . import __version__ +from .cli_arguments import parser +from .yacfg_batch import generate logger_settings.config_console_logger() diff --git a/tests/extras/test_broker_special_char.py b/tests/extras/test_broker_special_char.py index a2106f3c..71081227 100644 --- a/tests/extras/test_broker_special_char.py +++ b/tests/extras/test_broker_special_char.py @@ -14,6 +14,7 @@ import os import shutil + import pytest import yacfg diff --git a/tests/files/test_ensure_output_path.py b/tests/files/test_ensure_output_path.py index 22cc53f8..91564768 100644 --- a/tests/files/test_ensure_output_path.py +++ b/tests/files/test_ensure_output_path.py @@ -14,8 +14,9 @@ import os import os.path -import pytest + import mock +import pytest from yacfg.files import ensure_output_path diff --git a/tests/test_yacfg/cli_arguments/test_boolize.py b/tests/test_yacfg/cli_arguments/test_boolize.py index 96850687..a6ae8eb1 100644 --- a/tests/test_yacfg/cli_arguments/test_boolize.py +++ b/tests/test_yacfg/cli_arguments/test_boolize.py @@ -13,6 +13,7 @@ # limitations under the License. import pytest + import yacfg.cli_arguments dataset_boolize = ( diff --git a/tests/test_yacfg/config_data/test_render_config.py b/tests/test_yacfg/config_data/test_render_config.py index a3ed5878..afaf9639 100644 --- a/tests/test_yacfg/config_data/test_render_config.py +++ b/tests/test_yacfg/config_data/test_render_config.py @@ -13,6 +13,7 @@ # limitations under the License. import pytest + import yacfg.config_data dataset_render_config = ( diff --git a/tests/test_yacfg/files/test_ensure_output_path.py b/tests/test_yacfg/files/test_ensure_output_path.py index 22cc53f8..91564768 100644 --- a/tests/test_yacfg/files/test_ensure_output_path.py +++ b/tests/test_yacfg/files/test_ensure_output_path.py @@ -14,8 +14,9 @@ import os import os.path -import pytest + import mock +import pytest from yacfg.files import ensure_output_path diff --git a/tests/test_yacfg/files/test_get_output_filename.py b/tests/test_yacfg/files/test_get_output_filename.py index 9bbfddb8..f2e61c63 100644 --- a/tests/test_yacfg/files/test_get_output_filename.py +++ b/tests/test_yacfg/files/test_get_output_filename.py @@ -34,6 +34,7 @@ def test_base_name(): ) +# noinspection PyTypeChecker @pytest.mark.parametrize("value", dataset_incorrect_values) def test_int(value): with pytest.raises(TypeError): diff --git a/tests/test_yacfg/output/test_new_profile.py b/tests/test_yacfg/output/test_new_profile.py index ec3b8e02..c2b82b89 100644 --- a/tests/test_yacfg/output/test_new_profile.py +++ b/tests/test_yacfg/output/test_new_profile.py @@ -13,13 +13,13 @@ # limitations under the License. import os -import mock import shutil +import mock import pytest -from yacfg.output import new_profile import yacfg.output +from yacfg.output import new_profile from ..files.fakes import fake_select_profile_file, fake_profiles_path diff --git a/tests/test_yacfg/output/test_new_profile_rendered.py b/tests/test_yacfg/output/test_new_profile_rendered.py index 13853276..a32ed6a1 100644 --- a/tests/test_yacfg/output/test_new_profile_rendered.py +++ b/tests/test_yacfg/output/test_new_profile_rendered.py @@ -18,8 +18,8 @@ import pytest import yacfg.output -from yacfg.output import new_profile_rendered from yacfg.meta import NAME +from yacfg.output import new_profile_rendered from ..profiles.fakes import ( fake_load_tuned_profile_with_defaults, fake_load_tuned_profile_no_defaults, diff --git a/tests/test_yacfg/output/test_write_output.py b/tests/test_yacfg/output/test_write_output.py index b0d21bb0..503d5f98 100644 --- a/tests/test_yacfg/output/test_write_output.py +++ b/tests/test_yacfg/output/test_write_output.py @@ -18,7 +18,6 @@ import pytest import yacfg.output - from yacfg.output import write_output diff --git a/tests/test_yacfg/test_generate.py b/tests/test_yacfg/test_generate.py index 70242f37..23035834 100644 --- a/tests/test_yacfg/test_generate.py +++ b/tests/test_yacfg/test_generate.py @@ -16,8 +16,8 @@ import pytest import yacfg.yacfg -from yacfg.yacfg import generate from yacfg.exceptions import ProfileError, TemplateError +from yacfg.yacfg import generate from .profiles.fakes import ( fake_load_tuned_profile_no_defaults, fake_load_tuned_profile_w_template, diff --git a/tests/test_yacfg/test_generate_core.py b/tests/test_yacfg/test_generate_core.py index ed288b82..886efcf0 100644 --- a/tests/test_yacfg/test_generate_core.py +++ b/tests/test_yacfg/test_generate_core.py @@ -16,8 +16,8 @@ import pytest import yacfg.yacfg -from yacfg.yacfg import generate_core from yacfg.exceptions import TemplateError +from yacfg.yacfg import generate_core from .profiles.fakes import ( fake_load_tuned_profile_no_defaults, fake_load_tuned_profile_w_template, diff --git a/tests/test_yacfg/test_generate_outputs.py b/tests/test_yacfg/test_generate_outputs.py index 71ae38aa..078ba8e4 100644 --- a/tests/test_yacfg/test_generate_outputs.py +++ b/tests/test_yacfg/test_generate_outputs.py @@ -17,8 +17,8 @@ import pytest import yacfg.yacfg -from yacfg.yacfg import generate_outputs from yacfg.exceptions import GenerationError +from yacfg.yacfg import generate_outputs @mock.patch("yacfg.yacfg.write_output", mock.Mock()) diff --git a/tests/test_yacfg_batch/test_generate_all_profiles.py b/tests/test_yacfg_batch/test_generate_all_profiles.py index f781aaf3..a8aa81a2 100644 --- a/tests/test_yacfg_batch/test_generate_all_profiles.py +++ b/tests/test_yacfg_batch/test_generate_all_profiles.py @@ -16,8 +16,8 @@ import pytest import yacfg -from yacfg_batch.yacfg_batch import generate_all_profiles, GenerateData from yacfg_batch.exceptions import YacfgBatchException +from yacfg_batch.yacfg_batch import generate_all_profiles, GenerateData @mock.patch("yacfg.yacfg.generate", mock.Mock()) diff --git a/tests/test_yacfg_batch/test_iter_gen_profiles.py b/tests/test_yacfg_batch/test_iter_gen_profiles.py index 41c48bda..1ca809a4 100644 --- a/tests/test_yacfg_batch/test_iter_gen_profiles.py +++ b/tests/test_yacfg_batch/test_iter_gen_profiles.py @@ -15,9 +15,10 @@ import mock import pytest import yaml + import yacfg_batch -from yacfg_batch.yacfg_batch import iter_gen_profiles from yacfg_batch.exceptions import YacfgBatchException +from yacfg_batch.yacfg_batch import iter_gen_profiles @mock.patch("yacfg_batch.yacfg_batch.open", mock.Mock()) From fed66a1d751c3e4cd7895c25908551730c800bdb Mon Sep 17 00:00:00 2001 From: Dominik Lenoch Date: Fri, 5 Nov 2021 19:11:56 +0100 Subject: [PATCH 8/8] UPD: tox pytest coverage + Black formatter --- tox.ini | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 47d13474..f3529c4b 100644 --- a/tox.ini +++ b/tox.ini @@ -5,7 +5,7 @@ [tox] skipsdist = true -envlist = py{38,39}-pytest, py39-{yaml,flake8,mypy,coverage-report,docs} +envlist = py{38,39}-pytest, py39-{yaml,flake8,black,mypy,coverage-report,docs} toxworkdir = /tmp/.tox.yacfg/ [flake8] @@ -15,6 +15,7 @@ max-complexity = 10 [gh-actions] python = + 3.7: py38-pytest 3.8: py38-pytest 3.9: py39-pytest, py39-flake8, py39-yaml, py39-mypy, py39-docs @@ -24,7 +25,7 @@ basepython = python3.9 [testenv:pytest] description = Run tests and measure coverage commands = - poetry run pytest --basetemp="{envtmpdir}" {posargs} + poetry run pytest -ra -vv --cov=yacfg --cov=yacfg_batch --cov-report=xml --basetemp="{envtmpdir}" {posargs} mkdir -p {toxinidir}/.coverage-reports mv {envtmpdir}/.coverage {toxinidir}/.coverage-reports/.coverage.{env:COVERAGE_PREFIX:}{envname} @@ -77,6 +78,11 @@ basepython = {[testenv:base]basepython} extras = docs commands = poetry run jupyter-book build ./docs +[testenv:black] +description = Black formatter +basepython = {[testenv:base]basepython} +commands = poetry run black --check ./ + [testenv:coverage-report] description = Report coverage over all test runs basepython = {[testenv:base]basepython}