From e17de3eec108a65e0f4875fe74dc0c67a1c8de04 Mon Sep 17 00:00:00 2001 From: Fasih Ahmad Fakhri Date: Tue, 20 Oct 2020 00:11:18 +0530 Subject: [PATCH 01/15] Create python-publish.yml --- .github/workflows/python-publish.yml | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/python-publish.yml diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml new file mode 100644 index 0000000..4e1ef42 --- /dev/null +++ b/.github/workflows/python-publish.yml @@ -0,0 +1,31 @@ +# This workflows will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +name: Upload Python Package + +on: + release: + types: [created] + +jobs: + deploy: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python setup.py sdist bdist_wheel + twine upload dist/* From 44b0e3ce1a5ec9244b63cb58ca4749ff1efdcad6 Mon Sep 17 00:00:00 2001 From: Fasih Ahmad Fakhri Date: Tue, 20 Oct 2020 00:12:16 +0530 Subject: [PATCH 02/15] Create python-package.yml --- .github/workflows/python-package.yml | 39 ++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/python-package.yml diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml new file mode 100644 index 0000000..6dd4fa6 --- /dev/null +++ b/.github/workflows/python-package.yml @@ -0,0 +1,39 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Python package + +on: + push: + branches: [ develop ] + pull_request: + branches: [ develop ] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.6, 3.7, 3.8] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest From ec882d3450cc5595b5f56a6fa80e74fdab999ec2 Mon Sep 17 00:00:00 2001 From: Fasih Ahmad Fakhri Date: Tue, 20 Oct 2020 01:17:46 +0530 Subject: [PATCH 03/15] Added tests --- src/django_settings_local/__init__.py | 2 +- tests/settings_local_with_patch_globals/settings_local.py | 5 +++++ .../test_settings_local_with_patch_globals.py | 4 ++++ .../settings_local.py | 4 ++++ .../test_settings_local_with_patch_globals_not_function.py | 4 ++++ tests/settings_local_without_patch_globals/settings_local.py | 1 + .../test_settings_local_without_patch_globals.py | 4 ++++ tests/test_settings.py | 4 ++++ 8 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 tests/settings_local_with_patch_globals/settings_local.py create mode 100644 tests/settings_local_with_patch_globals/test_settings_local_with_patch_globals.py create mode 100644 tests/settings_local_with_patch_globals_not_function/settings_local.py create mode 100644 tests/settings_local_with_patch_globals_not_function/test_settings_local_with_patch_globals_not_function.py create mode 100644 tests/settings_local_without_patch_globals/settings_local.py create mode 100644 tests/settings_local_without_patch_globals/test_settings_local_without_patch_globals.py create mode 100644 tests/test_settings.py diff --git a/src/django_settings_local/__init__.py b/src/django_settings_local/__init__.py index d8958d4..fd030db 100644 --- a/src/django_settings_local/__init__.py +++ b/src/django_settings_local/__init__.py @@ -23,7 +23,7 @@ def import_local(g): settings_local.patch_globals(g) except ImportError: msg = "Use `settings_local.py` in the project app to override global settings" - except AttributeError: + except (AttributeError, TypeError): msg = "For global settings mutation, see format of settings_local.py `dsl -f`" finally: if not DSL_CACHE: diff --git a/tests/settings_local_with_patch_globals/settings_local.py b/tests/settings_local_with_patch_globals/settings_local.py new file mode 100644 index 0000000..606889c --- /dev/null +++ b/tests/settings_local_with_patch_globals/settings_local.py @@ -0,0 +1,5 @@ +DEBUG = True +ALLOWED_HOSTS = ['*'] + +def patch_globals(g): + pass diff --git a/tests/settings_local_with_patch_globals/test_settings_local_with_patch_globals.py b/tests/settings_local_with_patch_globals/test_settings_local_with_patch_globals.py new file mode 100644 index 0000000..ef4d1de --- /dev/null +++ b/tests/settings_local_with_patch_globals/test_settings_local_with_patch_globals.py @@ -0,0 +1,4 @@ +from src.django_settings_local import import_local + +def test_import_local(): + import_local(globals()) diff --git a/tests/settings_local_with_patch_globals_not_function/settings_local.py b/tests/settings_local_with_patch_globals_not_function/settings_local.py new file mode 100644 index 0000000..0c1bc54 --- /dev/null +++ b/tests/settings_local_with_patch_globals_not_function/settings_local.py @@ -0,0 +1,4 @@ +DEBUG = True +ALLOWED_HOSTS = ['*'] + +patch_globals = "Not a function" diff --git a/tests/settings_local_with_patch_globals_not_function/test_settings_local_with_patch_globals_not_function.py b/tests/settings_local_with_patch_globals_not_function/test_settings_local_with_patch_globals_not_function.py new file mode 100644 index 0000000..ef4d1de --- /dev/null +++ b/tests/settings_local_with_patch_globals_not_function/test_settings_local_with_patch_globals_not_function.py @@ -0,0 +1,4 @@ +from src.django_settings_local import import_local + +def test_import_local(): + import_local(globals()) diff --git a/tests/settings_local_without_patch_globals/settings_local.py b/tests/settings_local_without_patch_globals/settings_local.py new file mode 100644 index 0000000..51c64dd --- /dev/null +++ b/tests/settings_local_without_patch_globals/settings_local.py @@ -0,0 +1 @@ +DEBUG = True diff --git a/tests/settings_local_without_patch_globals/test_settings_local_without_patch_globals.py b/tests/settings_local_without_patch_globals/test_settings_local_without_patch_globals.py new file mode 100644 index 0000000..ef4d1de --- /dev/null +++ b/tests/settings_local_without_patch_globals/test_settings_local_without_patch_globals.py @@ -0,0 +1,4 @@ +from src.django_settings_local import import_local + +def test_import_local(): + import_local(globals()) diff --git a/tests/test_settings.py b/tests/test_settings.py new file mode 100644 index 0000000..ef4d1de --- /dev/null +++ b/tests/test_settings.py @@ -0,0 +1,4 @@ +from src.django_settings_local import import_local + +def test_import_local(): + import_local(globals()) From dd9fa07fe7295086fbe54013b9208537339511d9 Mon Sep 17 00:00:00 2001 From: Fasih Ahmad Fakhri Date: Tue, 20 Oct 2020 01:26:05 +0530 Subject: [PATCH 04/15] Added __init__.py in src --- src/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/__init__.py diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..e69de29 From 65cf50aaf55db13961716575b285b6b0491ea7f1 Mon Sep 17 00:00:00 2001 From: Fasih Ahmad Fakhri Date: Tue, 20 Oct 2020 01:29:48 +0530 Subject: [PATCH 05/15] Moved __init__.py to tests --- {src => tests}/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {src => tests}/__init__.py (100%) diff --git a/src/__init__.py b/tests/__init__.py similarity index 100% rename from src/__init__.py rename to tests/__init__.py From a30c62406bbb329ed2a977b057ac9b2c3d6026e0 Mon Sep 17 00:00:00 2001 From: Fasih Ahmad Fakhri Date: Tue, 20 Oct 2020 02:30:32 +0530 Subject: [PATCH 06/15] Added codecov --- .github/workflows/python-package.yml | 7 +++++-- README.rst | 2 ++ setup.cfg | 4 ++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 6dd4fa6..4b3852b 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -1,7 +1,7 @@ # This workflow will install Python dependencies, run tests and lint with a variety of Python versions # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions -name: Python package +name: Test Python Package on: push: @@ -26,7 +26,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install flake8 pytest + pip install flake8 pytest pytest-cov codecov if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Lint with flake8 run: | @@ -37,3 +37,6 @@ jobs: - name: Test with pytest run: | pytest + - name: Coverage by codecov + run: | + codecov diff --git a/README.rst b/README.rst index fe68be1..a578546 100644 --- a/README.rst +++ b/README.rst @@ -8,6 +8,8 @@ django-settings-local - Manage Django Local Settings .. image:: https://badge.fury.io/py/django-settings-local.svg :target: http://badge.fury.io/py/django-settings-local +.. |Python package| image:: https://github.com/fasih/django-settings-local/workflows/Python%20package/badge.svg + ***** Usage ***** diff --git a/setup.cfg b/setup.cfg index a6fb745..0b74b6a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -29,3 +29,7 @@ where=src [options.entry_points] console_scripts = dsl = django_settings_local.__main__:main + +[tool:pytest] +addopts = --tb=short --strict -ra --cov-report=xml --cov=src/ +testpaths = tests From 5be4368f485f7ee3153a330eacb66f19e07301b7 Mon Sep 17 00:00:00 2001 From: Fasih Ahmad Fakhri Date: Tue, 20 Oct 2020 02:46:37 +0530 Subject: [PATCH 07/15] Added codecov.yml --- README.rst | 2 +- codecov.yml | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 codecov.yml diff --git a/README.rst b/README.rst index a578546..9ed0814 100644 --- a/README.rst +++ b/README.rst @@ -8,7 +8,7 @@ django-settings-local - Manage Django Local Settings .. image:: https://badge.fury.io/py/django-settings-local.svg :target: http://badge.fury.io/py/django-settings-local -.. |Python package| image:: https://github.com/fasih/django-settings-local/workflows/Python%20package/badge.svg +.. |Python package| image:: https://github.com/fasih/django-settings-local/workflows/Test%20Python%20Package/badge.svg ***** Usage diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..43b171d --- /dev/null +++ b/codecov.yml @@ -0,0 +1,11 @@ +codecov: + archive: + uploads: no + +coverage: + precision: 0 + range: 80...100 + +comment: + layout: "header, diff, changes" + From e198d4d0c695742540ee10faa379fb0692e08b76 Mon Sep 17 00:00:00 2001 From: Fasih Ahmad Fakhri Date: Tue, 20 Oct 2020 02:55:31 +0530 Subject: [PATCH 08/15] Added Badges --- README.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 9ed0814..8c28b1d 100644 --- a/README.rst +++ b/README.rst @@ -7,9 +7,11 @@ django-settings-local - Manage Django Local Settings .. image:: https://badge.fury.io/py/django-settings-local.svg :target: http://badge.fury.io/py/django-settings-local - -.. |Python package| image:: https://github.com/fasih/django-settings-local/workflows/Test%20Python%20Package/badge.svg - +.. image:: https://github.com/fasih/django-settings-local/workflows/Test%20Python%20Package/badge.svg + :target: https://github.com/fasih/django-settings-local/actions?query=workflow%3A%22Test+Python+Package%22 +.. image:: https://codecov.io/gh/fasih/django-settings-local/branch/develop/graph/badge.svg?token=YDO44RQBSS + :target: https://codecov.io/gh/fasih/django-settings-local + ***** Usage ***** From cb43d8771c88e6bd52c2953b4015ea7b5e5450b3 Mon Sep 17 00:00:00 2001 From: Fasih Ahmad Fakhri Date: Tue, 20 Oct 2020 03:50:36 +0530 Subject: [PATCH 09/15] More Generic in terms of directory structure --- src/django_settings_local/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/django_settings_local/__init__.py b/src/django_settings_local/__init__.py index fd030db..f3d6efc 100644 --- a/src/django_settings_local/__init__.py +++ b/src/django_settings_local/__init__.py @@ -12,7 +12,9 @@ def pritty_print(msg): print('\n','#'*len(msg),'\n',msg,'\n','#'*len(msg)) def import_local(g): - PROJECT_APP = Path(g['__file__']).resolve(strict=True).parent.name + CWD = Path(os.getcwd()) + PWD = Path(g['__file__']).resolve(strict=True).parent + PROJECT_APP = ".".join(PWD.relative_to(CWD).parts) try: msg = "Django local settings applied" settings_local = importlib.import_module(".settings_local", PROJECT_APP) From 9e6cb20280abdef02967661e60b00ed95825b070 Mon Sep 17 00:00:00 2001 From: Fasih Ahmad Fakhri Date: Tue, 20 Oct 2020 04:36:34 +0530 Subject: [PATCH 10/15] Added test case for console script --- tests/project_app/settings.py | 1 + tests/test_project.py | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 tests/project_app/settings.py create mode 100644 tests/test_project.py diff --git a/tests/project_app/settings.py b/tests/project_app/settings.py new file mode 100644 index 0000000..c7d5d42 --- /dev/null +++ b/tests/project_app/settings.py @@ -0,0 +1 @@ +DEBUG = False diff --git a/tests/test_project.py b/tests/test_project.py new file mode 100644 index 0000000..b0f47ea --- /dev/null +++ b/tests/test_project.py @@ -0,0 +1,9 @@ +import os + +def test_main_console_script(): + cmd0 = ['cd', 'src', '&&', 'python3', '-m', 'django_settings_local', '-p', '../tests/project_app/'] + os.system(" ".join(cmd0)) + os.system(" ".join(cmd0)) + + cmd1 = cmd0[:-2] + ["-f"] + os.system(" ".join(cmd1)) From fed1e7e173d58054cf51917158923d77be5d8619 Mon Sep 17 00:00:00 2001 From: Fasih Ahmad Fakhri Date: Tue, 20 Oct 2020 04:40:56 +0530 Subject: [PATCH 11/15] Python in cmd --- tests/test_project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_project.py b/tests/test_project.py index b0f47ea..18c03cb 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -1,7 +1,7 @@ import os def test_main_console_script(): - cmd0 = ['cd', 'src', '&&', 'python3', '-m', 'django_settings_local', '-p', '../tests/project_app/'] + cmd0 = ['cd', 'src', '&&', 'python', '-m', 'django_settings_local', '-p', '../tests/project_app/'] os.system(" ".join(cmd0)) os.system(" ".join(cmd0)) From d4de0f847ddea8b4a09806ae97f3b30be2f7100e Mon Sep 17 00:00:00 2001 From: Fasih Ahmad Fakhri Date: Tue, 20 Oct 2020 05:25:33 +0530 Subject: [PATCH 12/15] Updated --- .gitignore | 1 + src/django_settings_local/__main__.py | 44 +++------------------------ src/django_settings_local/dsl.py | 44 +++++++++++++++++++++++++++ tests/test_project.py | 11 +++---- 4 files changed, 54 insertions(+), 46 deletions(-) create mode 100644 src/django_settings_local/dsl.py diff --git a/.gitignore b/.gitignore index b6e4761..e444f26 100644 --- a/.gitignore +++ b/.gitignore @@ -50,6 +50,7 @@ coverage.xml *.py,cover .hypothesis/ .pytest_cache/ +tests/ # Translations *.mo diff --git a/src/django_settings_local/__main__.py b/src/django_settings_local/__main__.py index 3a715ed..7dcc04a 100644 --- a/src/django_settings_local/__main__.py +++ b/src/django_settings_local/__main__.py @@ -1,45 +1,9 @@ -import argparse, os, shutil - -from pathlib import Path -from .cute_python import snek - -FILE_NAME = 'settings_local.py' - +"""Entry-point for the :program:`dsl` command.""" +import sys def main(): - print(snek) - - parser = argparse.ArgumentParser(description='Create Django Local Settings') - parser.add_argument('-p', metavar='PATH', help='Django Project Application Path') - parser.add_argument('-f', action='store_true', help='Show Django Local Settings Format') - args = parser.parse_args() - - WORKING_DIR = Path(args.p or os.getcwd()) - PACKAGE_DIR = Path(__file__).resolve(strict=True).parent - - GIT_IGNORE = WORKING_DIR.parent/'.gitignore' - DJANGO_SETTINGS = WORKING_DIR/'settings.py' - - if args.f: - with open(PACKAGE_DIR/FILE_NAME, 'r') as fb: - print(fb.read()) - elif os.path.isfile(WORKING_DIR/FILE_NAME): - print(f"{FILE_NAME} is already there at {WORKING_DIR}") - else: - shutil.copyfile(PACKAGE_DIR/FILE_NAME, WORKING_DIR/FILE_NAME) - if os.path.isfile(GIT_IGNORE): - fp = open(GIT_IGNORE, 'a') - else: - fp = open(GIT_IGNORE, 'w') - fp.write('\n# Added by `dsl` (Django Setting Local) \nsettings_local*\n') - fp.close() - - fp = open(DJANGO_SETTINGS, 'a') - fp.write("\n\n\n\n") - fp.write("\n##################### END OF SETTINGS ################################") - fp.write("\nfrom django_settings_local import import_local;import_local(globals())") - fp.write("\n##################### END OF SETTINGS ################################") - fp.close() + from dsl import main as _main + sys.exit(_main()) if __name__ == '__main__': main() diff --git a/src/django_settings_local/dsl.py b/src/django_settings_local/dsl.py new file mode 100644 index 0000000..8f3c044 --- /dev/null +++ b/src/django_settings_local/dsl.py @@ -0,0 +1,44 @@ +import argparse, os, shutil + +from pathlib import Path +from .cute_python import snek + + +FILE_NAME = 'settings_local.py' + + +def main(): + print(snek) + + parser = argparse.ArgumentParser(description='Create Django Local Settings') + parser.add_argument('-p', metavar='PATH', help='Django Project Application Path') + parser.add_argument('-f', action='store_true', help='Show Django Local Settings Format') + args = parser.parse_args() + + WORKING_DIR = Path(args.p or os.getcwd()) + PACKAGE_DIR = Path(__file__).resolve(strict=True).parent + + GIT_IGNORE = WORKING_DIR.parent/'.gitignore' + DJANGO_SETTINGS = WORKING_DIR/'settings.py' + + if args.f: + with open(PACKAGE_DIR/FILE_NAME, 'r') as fb: + print(fb.read()) + elif os.path.isfile(WORKING_DIR/FILE_NAME): + print(f"{FILE_NAME} is already there at {WORKING_DIR}") + else: + shutil.copyfile(PACKAGE_DIR/FILE_NAME, WORKING_DIR/FILE_NAME) + if os.path.isfile(GIT_IGNORE): + fp = open(GIT_IGNORE, 'a') + else: + fp = open(GIT_IGNORE, 'w') + fp.write('\n# Added by `dsl` (Django Setting Local) \nsettings_local*\n') + fp.close() + + fp = open(DJANGO_SETTINGS, 'a') + fp.write("\n\n\n\n") + fp.write("\n##################### END OF SETTINGS ################################") + fp.write("\nfrom django_settings_local import import_local;import_local(globals())") + fp.write("\n##################### END OF SETTINGS ################################") + fp.close() + diff --git a/tests/test_project.py b/tests/test_project.py index 18c03cb..6be199e 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -1,9 +1,8 @@ import os +from src.django_settings_local.dsl import main -def test_main_console_script(): - cmd0 = ['cd', 'src', '&&', 'python', '-m', 'django_settings_local', '-p', '../tests/project_app/'] - os.system(" ".join(cmd0)) - os.system(" ".join(cmd0)) - cmd1 = cmd0[:-2] + ["-f"] - os.system(" ".join(cmd1)) +def test_main_console_script(): + os.chdir("tests/project_app") + main();main() + os.chdir("../../") From 9848d271897904ecb365cb4a80283371798b70b4 Mon Sep 17 00:00:00 2001 From: Fasih Ahmad Fakhri Date: Tue, 20 Oct 2020 06:26:11 +0530 Subject: [PATCH 13/15] Minor Changes --- src/django_settings_local/__main__.py | 2 +- tests/project_app/settings.py | 1 - tests/test_project.py | 8 ------ tests/test_project/settings.py | 37 +++++++++++++++++++++++++++ tests/test_settings.py | 4 --- 5 files changed, 38 insertions(+), 14 deletions(-) delete mode 100644 tests/project_app/settings.py delete mode 100644 tests/test_project.py create mode 100644 tests/test_project/settings.py delete mode 100644 tests/test_settings.py diff --git a/src/django_settings_local/__main__.py b/src/django_settings_local/__main__.py index 7dcc04a..5c2e627 100644 --- a/src/django_settings_local/__main__.py +++ b/src/django_settings_local/__main__.py @@ -2,7 +2,7 @@ import sys def main(): - from dsl import main as _main + from .dsl import main as _main sys.exit(_main()) if __name__ == '__main__': diff --git a/tests/project_app/settings.py b/tests/project_app/settings.py deleted file mode 100644 index c7d5d42..0000000 --- a/tests/project_app/settings.py +++ /dev/null @@ -1 +0,0 @@ -DEBUG = False diff --git a/tests/test_project.py b/tests/test_project.py deleted file mode 100644 index 6be199e..0000000 --- a/tests/test_project.py +++ /dev/null @@ -1,8 +0,0 @@ -import os -from src.django_settings_local.dsl import main - - -def test_main_console_script(): - os.chdir("tests/project_app") - main();main() - os.chdir("../../") diff --git a/tests/test_project/settings.py b/tests/test_project/settings.py new file mode 100644 index 0000000..a844db0 --- /dev/null +++ b/tests/test_project/settings.py @@ -0,0 +1,37 @@ +DEBUG = False + + + + + +##################### END OF SETTINGS ################################ +from django_settings_local import import_local;import_local(globals()) +##################### END OF SETTINGS ################################ + + + + +##################### END OF SETTINGS ################################ +from django_settings_local import import_local;import_local(globals()) +##################### END OF SETTINGS ################################ + + + + +##################### END OF SETTINGS ################################ +from django_settings_local import import_local;import_local(globals()) +##################### END OF SETTINGS ################################ + + + + +##################### END OF SETTINGS ################################ +from django_settings_local import import_local;import_local(globals()) +##################### END OF SETTINGS ################################ + + + + +##################### END OF SETTINGS ################################ +from django_settings_local import import_local;import_local(globals()) +##################### END OF SETTINGS ################################ \ No newline at end of file diff --git a/tests/test_settings.py b/tests/test_settings.py deleted file mode 100644 index ef4d1de..0000000 --- a/tests/test_settings.py +++ /dev/null @@ -1,4 +0,0 @@ -from src.django_settings_local import import_local - -def test_import_local(): - import_local(globals()) From 754ce9b0bd34d1311519e40522bc2c6720643490 Mon Sep 17 00:00:00 2001 From: Fasih Ahmad Fakhri Date: Tue, 20 Oct 2020 06:36:47 +0530 Subject: [PATCH 14/15] Major movement --- .gitignore | 5 ++- tests/django_project_app/settings.py | 1 + .../settings_local.py | 0 .../test_invalid_patch_globals.py} | 0 .../settings_local.py | 0 .../test_no_patch_globals.py} | 0 tests/test_project/settings.py | 37 ------------------- tests/test_settings_local.py | 27 ++++++++++++++ .../settings_local.py | 0 .../test_valid_patch_globals.py} | 0 10 files changed, 32 insertions(+), 38 deletions(-) create mode 100644 tests/django_project_app/settings.py rename tests/{settings_local_with_patch_globals_not_function => invalid_patch_globals}/settings_local.py (100%) rename tests/{settings_local_with_patch_globals/test_settings_local_with_patch_globals.py => invalid_patch_globals/test_invalid_patch_globals.py} (100%) rename tests/{settings_local_without_patch_globals => no_patch_globals}/settings_local.py (100%) rename tests/{settings_local_with_patch_globals_not_function/test_settings_local_with_patch_globals_not_function.py => no_patch_globals/test_no_patch_globals.py} (100%) delete mode 100644 tests/test_project/settings.py create mode 100644 tests/test_settings_local.py rename tests/{settings_local_with_patch_globals => valid_patch_globals}/settings_local.py (100%) rename tests/{settings_local_without_patch_globals/test_settings_local_without_patch_globals.py => valid_patch_globals/test_valid_patch_globals.py} (100%) diff --git a/.gitignore b/.gitignore index e444f26..4ed0a6c 100644 --- a/.gitignore +++ b/.gitignore @@ -50,7 +50,7 @@ coverage.xml *.py,cover .hypothesis/ .pytest_cache/ -tests/ + # Translations *.mo @@ -128,3 +128,6 @@ dmypy.json # Pyre type checker .pyre/ + +# dsl +tests/.gitignore diff --git a/tests/django_project_app/settings.py b/tests/django_project_app/settings.py new file mode 100644 index 0000000..c7d5d42 --- /dev/null +++ b/tests/django_project_app/settings.py @@ -0,0 +1 @@ +DEBUG = False diff --git a/tests/settings_local_with_patch_globals_not_function/settings_local.py b/tests/invalid_patch_globals/settings_local.py similarity index 100% rename from tests/settings_local_with_patch_globals_not_function/settings_local.py rename to tests/invalid_patch_globals/settings_local.py diff --git a/tests/settings_local_with_patch_globals/test_settings_local_with_patch_globals.py b/tests/invalid_patch_globals/test_invalid_patch_globals.py similarity index 100% rename from tests/settings_local_with_patch_globals/test_settings_local_with_patch_globals.py rename to tests/invalid_patch_globals/test_invalid_patch_globals.py diff --git a/tests/settings_local_without_patch_globals/settings_local.py b/tests/no_patch_globals/settings_local.py similarity index 100% rename from tests/settings_local_without_patch_globals/settings_local.py rename to tests/no_patch_globals/settings_local.py diff --git a/tests/settings_local_with_patch_globals_not_function/test_settings_local_with_patch_globals_not_function.py b/tests/no_patch_globals/test_no_patch_globals.py similarity index 100% rename from tests/settings_local_with_patch_globals_not_function/test_settings_local_with_patch_globals_not_function.py rename to tests/no_patch_globals/test_no_patch_globals.py diff --git a/tests/test_project/settings.py b/tests/test_project/settings.py deleted file mode 100644 index a844db0..0000000 --- a/tests/test_project/settings.py +++ /dev/null @@ -1,37 +0,0 @@ -DEBUG = False - - - - - -##################### END OF SETTINGS ################################ -from django_settings_local import import_local;import_local(globals()) -##################### END OF SETTINGS ################################ - - - - -##################### END OF SETTINGS ################################ -from django_settings_local import import_local;import_local(globals()) -##################### END OF SETTINGS ################################ - - - - -##################### END OF SETTINGS ################################ -from django_settings_local import import_local;import_local(globals()) -##################### END OF SETTINGS ################################ - - - - -##################### END OF SETTINGS ################################ -from django_settings_local import import_local;import_local(globals()) -##################### END OF SETTINGS ################################ - - - - -##################### END OF SETTINGS ################################ -from django_settings_local import import_local;import_local(globals()) -##################### END OF SETTINGS ################################ \ No newline at end of file diff --git a/tests/test_settings_local.py b/tests/test_settings_local.py new file mode 100644 index 0000000..fe2d811 --- /dev/null +++ b/tests/test_settings_local.py @@ -0,0 +1,27 @@ +import importlib, os +from src.django_settings_local import dsl, import_local, settings_local + +def test_import_local(): + import_local(globals()) + +def test_valid_patch_globals(): + settings_local.patch_globals(globals()) + +def test_invalid_patch_globals(): + try: + settings_local.patch_globals(1,2) + except TypeError: + pass + +def test_main_module(): + main_module = importlib.import_module("src.django_settings_local.__main__") + try: + os.chdir("tests/django_project_app") + main_module.main() + except SystemExit: + os.chdir("../../") + +def test_main_script(): + os.chdir("tests/django_project_app") + dsl.main(); dsl.main() + os.chdir("../../") diff --git a/tests/settings_local_with_patch_globals/settings_local.py b/tests/valid_patch_globals/settings_local.py similarity index 100% rename from tests/settings_local_with_patch_globals/settings_local.py rename to tests/valid_patch_globals/settings_local.py diff --git a/tests/settings_local_without_patch_globals/test_settings_local_without_patch_globals.py b/tests/valid_patch_globals/test_valid_patch_globals.py similarity index 100% rename from tests/settings_local_without_patch_globals/test_settings_local_without_patch_globals.py rename to tests/valid_patch_globals/test_valid_patch_globals.py From 4c8a8afbf6aa5923ac303951b46a404cca8766b8 Mon Sep 17 00:00:00 2001 From: Fasih Ahmad Fakhri Date: Tue, 20 Oct 2020 07:17:48 +0530 Subject: [PATCH 15/15] Release Bumped --- src/django_settings_local/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/django_settings_local/__init__.py b/src/django_settings_local/__init__.py index f3d6efc..7461b68 100644 --- a/src/django_settings_local/__init__.py +++ b/src/django_settings_local/__init__.py @@ -4,7 +4,7 @@ from pathlib import Path from .cute_python import snek -__version__ = '0.1.8' +__version__ = '0.1.9' DSL_CACHE = os.environ.get("DSL_CACHE")