From e52725fb4fbd87f53f26856f0face08b05f13e59 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 23 May 2026 23:51:39 +0000 Subject: [PATCH 1/2] Add handling for "testing" support in config --- plugin_creator/cli.py | 4 ++++ plugin_creator/template/cookiecutter.json | 1 + .../{{ cookiecutter.package_name }}/tests/__init__.py | 0 .../{{ cookiecutter.package_name }}/tests/test.py | 11 +++++++++++ 4 files changed, 16 insertions(+) create mode 100644 plugin_creator/template/{{ cookiecutter.plugin_name }}/{{ cookiecutter.package_name }}/tests/__init__.py create mode 100644 plugin_creator/template/{{ cookiecutter.plugin_name }}/{{ cookiecutter.package_name }}/tests/test.py diff --git a/plugin_creator/cli.py b/plugin_creator/cli.py index 37a364f..ec2bf01 100644 --- a/plugin_creator/cli.py +++ b/plugin_creator/cli.py @@ -131,6 +131,10 @@ def gather_info(context: dict) -> dict: context["ci_support"] = devops.get_devops_mode() if git_support else "None" + context["testing"] = questionary.confirm( + "Include testing support?", default=True, + ).ask() + return context diff --git a/plugin_creator/template/cookiecutter.json b/plugin_creator/template/cookiecutter.json index 3a12c81..cdb2811 100644 --- a/plugin_creator/template/cookiecutter.json +++ b/plugin_creator/template/cookiecutter.json @@ -30,6 +30,7 @@ "plugin_creator_url": "https://github.com/inventree/plugin_creator", "git_support": true, "ci_support": "github", + "testing": true, "frontend": { "enabled": true, "translation": true, diff --git a/plugin_creator/template/{{ cookiecutter.plugin_name }}/{{ cookiecutter.package_name }}/tests/__init__.py b/plugin_creator/template/{{ cookiecutter.plugin_name }}/{{ cookiecutter.package_name }}/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/plugin_creator/template/{{ cookiecutter.plugin_name }}/{{ cookiecutter.package_name }}/tests/test.py b/plugin_creator/template/{{ cookiecutter.plugin_name }}/{{ cookiecutter.package_name }}/tests/test.py new file mode 100644 index 0000000..d34696f --- /dev/null +++ b/plugin_creator/template/{{ cookiecutter.plugin_name }}/{{ cookiecutter.package_name }}/tests/test.py @@ -0,0 +1,11 @@ +"""Run unit tests for the {{ cookiecutter.plugin_name }} plugin.""" + +from django.test import TestCase + + +class PluginTest(TestCase): + """Tests for the {{ cookiecutter.plugin_name }} plugin.""" + + def test_plugin(self): + """Test that the plugin can be loaded.""" + ... From 3a555347fc258f3e874b2da6a4427c2bcaa444bd Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 23 May 2026 23:53:57 +0000 Subject: [PATCH 2/2] Remove tests dir if not configured --- plugin_creator/cli.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugin_creator/cli.py b/plugin_creator/cli.py index ec2bf01..3567331 100644 --- a/plugin_creator/cli.py +++ b/plugin_creator/cli.py @@ -9,7 +9,7 @@ from cookiecutter.main import cookiecutter from . import PLUGIN_CREATOR_VERSION, config, devops, frontend, mixins, validators -from .helpers import info, success +from .helpers import info, success, remove_dir def default_values() -> dict: @@ -156,6 +156,10 @@ def cleanup(plugin_dir: str, context: dict) -> None: if context["git_support"]: devops.git_init(plugin_dir) + if not context["testing"]: + src_dir = os.path.join(plugin_dir, context["package_name"]) + remove_dir(src_dir, "tests") + def main(): """Run plugin scaffolding."""