From f2d7a5624827d8caf8df7a6224e80148a68a32a0 Mon Sep 17 00:00:00 2001 From: Eric Matthes Date: Mon, 26 May 2025 12:38:26 -0400 Subject: [PATCH 01/18] Only clone depth=1 for dsd in e2e test. --- tests/e2e_tests/test_basic_plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e_tests/test_basic_plugin.py b/tests/e2e_tests/test_basic_plugin.py index 519bd7d..8dafdc3 100644 --- a/tests/e2e_tests/test_basic_plugin.py +++ b/tests/e2e_tests/test_basic_plugin.py @@ -67,7 +67,7 @@ def test_new_plugin_e2e(tmp_path_factory): # Clone django-simple-deploy in temp env. path_dsd = tmp_path / "django-simple-deploy" - cmd = f"git clone https://github.com/django-simple-deploy/django-simple-deploy.git {path_dsd.as_posix()}" + cmd = f"git clone https://github.com/django-simple-deploy/django-simple-deploy.git {path_dsd.as_posix()} --depth 1" cmd_parts = shlex.split(cmd) subprocess.run(cmd_parts) From 556a8ed5773813722294d5fff5b93e0dc11a99f2 Mon Sep 17 00:00:00 2001 From: Eric Matthes Date: Mon, 26 May 2025 12:58:11 -0400 Subject: [PATCH 02/18] In e2e test, only run the plugin's integration tests, not all core dsd tests. --- tests/e2e_tests/test_basic_plugin.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/tests/e2e_tests/test_basic_plugin.py b/tests/e2e_tests/test_basic_plugin.py index 8dafdc3..75bc1bc 100644 --- a/tests/e2e_tests/test_basic_plugin.py +++ b/tests/e2e_tests/test_basic_plugin.py @@ -4,7 +4,7 @@ - Generates a new plugin. - Sets up a development environment for django-simple-deploy core. - Installs the new plugin to the development environment. -- Runs the initial set of tests against the plugin. +- Runs the plugin's integration tests. Notes: - This makes an editable install of both django-simple-deploy and the new plugin. @@ -23,6 +23,7 @@ import pytest from utils.plugin_config import PluginConfig +from utils.generator_utils import get_platform_name_lower import generate_plugin as gp @@ -109,22 +110,25 @@ def test_new_plugin_e2e(tmp_path_factory): subprocess.run(cmd_parts) if run_core_plugin_tests: - # Run core tests **with** the new plugin installed. + # Run plugin's integration tests. tests_dir = path_dsd / "tests" - cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest" + platform_name_lower = get_platform_name_lower(plugin_config.platform_name) + test_filename = f"test_{platform_name_lower}_config.py" + cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest -k {test_filename}" output = subprocess.run(cmd, capture_output=True,shell=True) stdout = output.stdout.decode() assert "test session starts" in stdout assert "[100%]" in stdout - # Check number of core tests that passed and skipped. + # Check number of plugin's tests that passed and skipped. + # No assertions about number skipped, but helpful to know at times. m = re.findall(re_passed_skipped, stdout) if m: passed = int(m[0][0]) skipped = int(m[0][1]) - assert passed >= 65 - assert skipped >= 6 + assert passed >= 18 + # Remove plugin, and test another one. # This is much faster than having a completely separate test. We lose some test @@ -156,19 +160,21 @@ def test_new_plugin_e2e(tmp_path_factory): subprocess.run(cmd_parts) if run_core_plugin_tests: - # Run core tests **with** the new plugin installed. + # Run plugin's integration tests. tests_dir = path_dsd / "tests" - cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest" + platform_name_lower = get_platform_name_lower(plugin_config.platform_name) + test_filename = f"test_{platform_name_lower}_config.py" + cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest -k {test_filename}" output = subprocess.run(cmd, capture_output=True,shell=True) stdout = output.stdout.decode() assert "test session starts" in stdout assert "[100%]" in stdout - # Check number of core tests that passed and skipped. + # Check number of plugin's tests that passed and skipped. + # No assertions about number skipped, but helpful to know at times. m = re.findall(re_passed_skipped, stdout) if m: passed = int(m[0][0]) skipped = int(m[0][1]) - assert passed >= 65 - assert skipped >= 6 \ No newline at end of file + assert passed >= 18 From ddb45ff915537573822b848993eed4870451e71a Mon Sep 17 00:00:00 2001 From: Eric Matthes Date: Mon, 26 May 2025 19:13:23 -0400 Subject: [PATCH 03/18] CLI option to run full set of dsd core tests for each new plugin in e2e tests. --- tests/e2e_tests/conftest.py | 23 +++++++++++++++++++++++ tests/e2e_tests/test_basic_plugin.py | 9 +++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 tests/e2e_tests/conftest.py diff --git a/tests/e2e_tests/conftest.py b/tests/e2e_tests/conftest.py new file mode 100644 index 0000000..aa70ef9 --- /dev/null +++ b/tests/e2e_tests/conftest.py @@ -0,0 +1,23 @@ +"""Configuration for e2e test runs.""" + +from dataclasses import dataclass + +import pytest + + +def pytest_addoption(parser): + parser.addoption( + "--include-core-tests", + action="store_true", + help="Run the full set of core django-simple-deploy tests for each new plugin.", + ) + +@dataclass +class CLIOptions: + include_core_tests: bool=False + +@pytest.fixture(scope="session") +def cli_options(request): + return CLIOptions( + include_core_tests=request.config.getoption("--include-core-tests"), + ) \ No newline at end of file diff --git a/tests/e2e_tests/test_basic_plugin.py b/tests/e2e_tests/test_basic_plugin.py index 75bc1bc..cb0d5e8 100644 --- a/tests/e2e_tests/test_basic_plugin.py +++ b/tests/e2e_tests/test_basic_plugin.py @@ -42,7 +42,7 @@ def uv_available(): ### --- Test function --- @pytest.mark.skipif(not uv_available(), reason="uv must be installed in order to run e2e tests.") -def test_new_plugin_e2e(tmp_path_factory): +def test_new_plugin_e2e(tmp_path_factory, cli_options): # Flag to temporarily disable running dsd and plugin tests. This is helpful when # examining this environment. Otherwise pytest runs so many tests, this one can't # easily be found. @@ -114,7 +114,12 @@ def test_new_plugin_e2e(tmp_path_factory): tests_dir = path_dsd / "tests" platform_name_lower = get_platform_name_lower(plugin_config.platform_name) test_filename = f"test_{platform_name_lower}_config.py" - cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest -k {test_filename}" + if cli_options.include_core_tests: + # Run full set of core django-simple-deploy tests, and plugin integration tests. + cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest" + else: + # Only run the new plugin's integration tests. + cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest -k {test_filename}" output = subprocess.run(cmd, capture_output=True,shell=True) stdout = output.stdout.decode() From f6a95db5ed1da88ef23d4f0c8bddb3b4dcfdffe6 Mon Sep 17 00:00:00 2001 From: Eric Matthes Date: Mon, 26 May 2025 19:15:41 -0400 Subject: [PATCH 04/18] Flag --include-core-tests applies to both new plugins. --- tests/e2e_tests/test_basic_plugin.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/e2e_tests/test_basic_plugin.py b/tests/e2e_tests/test_basic_plugin.py index cb0d5e8..6d7237b 100644 --- a/tests/e2e_tests/test_basic_plugin.py +++ b/tests/e2e_tests/test_basic_plugin.py @@ -169,7 +169,13 @@ def test_new_plugin_e2e(tmp_path_factory, cli_options): tests_dir = path_dsd / "tests" platform_name_lower = get_platform_name_lower(plugin_config.platform_name) test_filename = f"test_{platform_name_lower}_config.py" - cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest -k {test_filename}" + # cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest -k {test_filename}" + if cli_options.include_core_tests: + # Run full set of core django-simple-deploy tests, and plugin integration tests. + cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest" + else: + # Only run the new plugin's integration tests. + cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest -k {test_filename}" output = subprocess.run(cmd, capture_output=True,shell=True) stdout = output.stdout.decode() From 3d6d776e0fe3bd2930b241558bbad2fa3948eb2a Mon Sep 17 00:00:00 2001 From: Eric Matthes Date: Mon, 26 May 2025 19:25:11 -0400 Subject: [PATCH 05/18] Conditional check on number of passed tests. --- tests/e2e_tests/test_basic_plugin.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/e2e_tests/test_basic_plugin.py b/tests/e2e_tests/test_basic_plugin.py index 6d7237b..0523761 100644 --- a/tests/e2e_tests/test_basic_plugin.py +++ b/tests/e2e_tests/test_basic_plugin.py @@ -45,7 +45,8 @@ def uv_available(): def test_new_plugin_e2e(tmp_path_factory, cli_options): # Flag to temporarily disable running dsd and plugin tests. This is helpful when # examining this environment. Otherwise pytest runs so many tests, this one can't - # easily be found. + # easily be found. This is not a CLI arg, because it only needs to be modified when you're + # working on this test, not when you're just running it. run_core_plugin_tests = True # Build a new plugin in temp dir. @@ -114,12 +115,14 @@ def test_new_plugin_e2e(tmp_path_factory, cli_options): tests_dir = path_dsd / "tests" platform_name_lower = get_platform_name_lower(plugin_config.platform_name) test_filename = f"test_{platform_name_lower}_config.py" + if cli_options.include_core_tests: # Run full set of core django-simple-deploy tests, and plugin integration tests. cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest" else: # Only run the new plugin's integration tests. cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest -k {test_filename}" + output = subprocess.run(cmd, capture_output=True,shell=True) stdout = output.stdout.decode() @@ -132,7 +135,11 @@ def test_new_plugin_e2e(tmp_path_factory, cli_options): if m: passed = int(m[0][0]) skipped = int(m[0][1]) - assert passed >= 18 + + if cli_options.include_core_tests: + assert passed >= 65 + else: + assert passed >= 18 # Remove plugin, and test another one. @@ -169,13 +176,14 @@ def test_new_plugin_e2e(tmp_path_factory, cli_options): tests_dir = path_dsd / "tests" platform_name_lower = get_platform_name_lower(plugin_config.platform_name) test_filename = f"test_{platform_name_lower}_config.py" - # cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest -k {test_filename}" + if cli_options.include_core_tests: # Run full set of core django-simple-deploy tests, and plugin integration tests. cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest" else: # Only run the new plugin's integration tests. cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest -k {test_filename}" + output = subprocess.run(cmd, capture_output=True,shell=True) stdout = output.stdout.decode() @@ -188,4 +196,8 @@ def test_new_plugin_e2e(tmp_path_factory, cli_options): if m: passed = int(m[0][0]) skipped = int(m[0][1]) - assert passed >= 18 + + if cli_options.include_core_tests: + assert passed >= 65 + else: + assert passed >= 18 From e04998b67818e370fefc98d503d98f3836dd8971 Mon Sep 17 00:00:00 2001 From: Eric Matthes Date: Mon, 26 May 2025 19:25:59 -0400 Subject: [PATCH 06/18] Include core tests in CI testing, when e2e tests are enabled. --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 8c86f71..862a2e9 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -59,4 +59,4 @@ jobs: # Run e2e tests. # DEV: Enable this after remmoving requirement to test with Poetry and Pipenv. - # pytest tests/e2e_tests -s + # pytest tests/e2e_tests -s --include-core-tests From f8c0e336f6bac3b3fdca2d30d08419165eeb6ea0 Mon Sep 17 00:00:00 2001 From: Eric Matthes Date: Mon, 26 May 2025 19:30:55 -0400 Subject: [PATCH 07/18] Document new testing flag. --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 457dabd..54a562d 100644 --- a/README.md +++ b/README.md @@ -79,4 +79,10 @@ $ pytest tests/e2e_tests -s The `-s` flag is not required, but since the tests takes a fairly long time it's helpful to see the output as it's running. You can get a good sense of which steps are working by watching the output as the test runs. +This will only run the integration tests for each new plugin in the e2e test. It will not run all of django-simple-deploy's tests for each new plugin. If you want to run the full set of tests, include an additional flag: + +```sh +$ pytest tests/e2e_tests -s --include-core-tests +``` + Currently, CI tests only run unit and integration tests. There's an open task in django-simple-deploy to remove the dependence on poetry and pipenv for running tests. When that is implemented, e2e tests can run much more easily in CI. From 7ba8d2ce90eb221373c42e172f910033a4f31c53 Mon Sep 17 00:00:00 2001 From: Eric Matthes Date: Mon, 26 May 2025 19:43:01 -0400 Subject: [PATCH 08/18] Utility function for getting cmd to run core and plugin tests. --- tests/e2e_tests/conftest.py | 2 +- tests/e2e_tests/test_basic_plugin.py | 38 +++++++++++++++------------- tests/e2e_tests/utils/e2e_utils.py | 15 +++++++++++ 3 files changed, 37 insertions(+), 18 deletions(-) create mode 100644 tests/e2e_tests/utils/e2e_utils.py diff --git a/tests/e2e_tests/conftest.py b/tests/e2e_tests/conftest.py index aa70ef9..35423e4 100644 --- a/tests/e2e_tests/conftest.py +++ b/tests/e2e_tests/conftest.py @@ -20,4 +20,4 @@ class CLIOptions: def cli_options(request): return CLIOptions( include_core_tests=request.config.getoption("--include-core-tests"), - ) \ No newline at end of file + ) diff --git a/tests/e2e_tests/test_basic_plugin.py b/tests/e2e_tests/test_basic_plugin.py index 0523761..71ec28d 100644 --- a/tests/e2e_tests/test_basic_plugin.py +++ b/tests/e2e_tests/test_basic_plugin.py @@ -24,6 +24,7 @@ from utils.plugin_config import PluginConfig from utils.generator_utils import get_platform_name_lower +from tests.e2e_tests.utils import e2e_utils import generate_plugin as gp @@ -114,15 +115,16 @@ def test_new_plugin_e2e(tmp_path_factory, cli_options): # Run plugin's integration tests. tests_dir = path_dsd / "tests" platform_name_lower = get_platform_name_lower(plugin_config.platform_name) - test_filename = f"test_{platform_name_lower}_config.py" - - if cli_options.include_core_tests: - # Run full set of core django-simple-deploy tests, and plugin integration tests. - cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest" - else: - # Only run the new plugin's integration tests. - cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest -k {test_filename}" - + # test_filename = f"test_{platform_name_lower}_config.py" + + cmd = e2e_utils.get_core_plugin_test_cmd(path_dsd, cli_options, platform_name_lower) + # if cli_options.include_core_tests: + # # Run full set of core django-simple-deploy tests, and plugin integration tests. + # cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest" + # else: + # # Only run the new plugin's integration tests. + # cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest -k {test_filename}" + output = subprocess.run(cmd, capture_output=True,shell=True) stdout = output.stdout.decode() @@ -175,14 +177,16 @@ def test_new_plugin_e2e(tmp_path_factory, cli_options): # Run plugin's integration tests. tests_dir = path_dsd / "tests" platform_name_lower = get_platform_name_lower(plugin_config.platform_name) - test_filename = f"test_{platform_name_lower}_config.py" - - if cli_options.include_core_tests: - # Run full set of core django-simple-deploy tests, and plugin integration tests. - cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest" - else: - # Only run the new plugin's integration tests. - cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest -k {test_filename}" + # test_filename = f"test_{platform_name_lower}_config.py" + + # if cli_options.include_core_tests: + # # Run full set of core django-simple-deploy tests, and plugin integration tests. + # cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest" + # else: + # # Only run the new plugin's integration tests. + # cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest -k {test_filename}" + + cmd = e2e_utils.get_core_plugin_test_cmd(path_dsd, cli_options, platform_name_lower) output = subprocess.run(cmd, capture_output=True,shell=True) stdout = output.stdout.decode() diff --git a/tests/e2e_tests/utils/e2e_utils.py b/tests/e2e_tests/utils/e2e_utils.py new file mode 100644 index 0000000..97329eb --- /dev/null +++ b/tests/e2e_tests/utils/e2e_utils.py @@ -0,0 +1,15 @@ +"""Utility functions for e2e tests.""" + + + +def get_core_plugin_test_cmd(path_dsd, cli_options, platform_name_lower): + """Get the command for running django-simple-deploy tests after a new plugin has been installed.""" + test_filename = f"test_{platform_name_lower}_config.py" + if cli_options.include_core_tests: + # Run full set of core django-simple-deploy tests, and plugin integration tests. + cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest" + else: + # Only run the new plugin's integration tests. + cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest -k {test_filename}" + + return cmd \ No newline at end of file From 509d2ea6b254148d0c4425a7c44a79be45b01593 Mon Sep 17 00:00:00 2001 From: Eric Matthes Date: Mon, 26 May 2025 19:45:28 -0400 Subject: [PATCH 09/18] Remove unused code. --- tests/e2e_tests/test_basic_plugin.py | 17 ----------------- tests/e2e_tests/utils/e2e_utils.py | 1 + 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/tests/e2e_tests/test_basic_plugin.py b/tests/e2e_tests/test_basic_plugin.py index 71ec28d..f15ab22 100644 --- a/tests/e2e_tests/test_basic_plugin.py +++ b/tests/e2e_tests/test_basic_plugin.py @@ -115,15 +115,7 @@ def test_new_plugin_e2e(tmp_path_factory, cli_options): # Run plugin's integration tests. tests_dir = path_dsd / "tests" platform_name_lower = get_platform_name_lower(plugin_config.platform_name) - # test_filename = f"test_{platform_name_lower}_config.py" - cmd = e2e_utils.get_core_plugin_test_cmd(path_dsd, cli_options, platform_name_lower) - # if cli_options.include_core_tests: - # # Run full set of core django-simple-deploy tests, and plugin integration tests. - # cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest" - # else: - # # Only run the new plugin's integration tests. - # cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest -k {test_filename}" output = subprocess.run(cmd, capture_output=True,shell=True) stdout = output.stdout.decode() @@ -177,15 +169,6 @@ def test_new_plugin_e2e(tmp_path_factory, cli_options): # Run plugin's integration tests. tests_dir = path_dsd / "tests" platform_name_lower = get_platform_name_lower(plugin_config.platform_name) - # test_filename = f"test_{platform_name_lower}_config.py" - - # if cli_options.include_core_tests: - # # Run full set of core django-simple-deploy tests, and plugin integration tests. - # cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest" - # else: - # # Only run the new plugin's integration tests. - # cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest -k {test_filename}" - cmd = e2e_utils.get_core_plugin_test_cmd(path_dsd, cli_options, platform_name_lower) output = subprocess.run(cmd, capture_output=True,shell=True) diff --git a/tests/e2e_tests/utils/e2e_utils.py b/tests/e2e_tests/utils/e2e_utils.py index 97329eb..f1260dc 100644 --- a/tests/e2e_tests/utils/e2e_utils.py +++ b/tests/e2e_tests/utils/e2e_utils.py @@ -5,6 +5,7 @@ def get_core_plugin_test_cmd(path_dsd, cli_options, platform_name_lower): """Get the command for running django-simple-deploy tests after a new plugin has been installed.""" test_filename = f"test_{platform_name_lower}_config.py" + if cli_options.include_core_tests: # Run full set of core django-simple-deploy tests, and plugin integration tests. cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest" From b8216ce90dab3a5fbccdeea1bf9ad21c9b525516 Mon Sep 17 00:00:00 2001 From: Eric Matthes Date: Mon, 26 May 2025 21:49:10 -0400 Subject: [PATCH 10/18] Move uv_available() to utils. --- tests/e2e_tests/test_basic_plugin.py | 16 +--------------- tests/e2e_tests/utils/e2e_utils.py | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/e2e_tests/test_basic_plugin.py b/tests/e2e_tests/test_basic_plugin.py index f15ab22..5d00cf9 100644 --- a/tests/e2e_tests/test_basic_plugin.py +++ b/tests/e2e_tests/test_basic_plugin.py @@ -28,21 +28,7 @@ import generate_plugin as gp -def uv_available(): - """Ensure uv is available before running test.""" - cmd = "uv self version -q" - cmd_parts = shlex.split(cmd) - try: - subprocess.run(cmd_parts) - return True - except FileNotFoundError: - # This is the exception raised on macOS when the command uv is unavailable. - return False - - -### --- Test function --- - -@pytest.mark.skipif(not uv_available(), reason="uv must be installed in order to run e2e tests.") +@pytest.mark.skipif(not e2e_utils.uv_available(), reason="uv must be installed in order to run e2e tests.") def test_new_plugin_e2e(tmp_path_factory, cli_options): # Flag to temporarily disable running dsd and plugin tests. This is helpful when # examining this environment. Otherwise pytest runs so many tests, this one can't diff --git a/tests/e2e_tests/utils/e2e_utils.py b/tests/e2e_tests/utils/e2e_utils.py index f1260dc..28cb456 100644 --- a/tests/e2e_tests/utils/e2e_utils.py +++ b/tests/e2e_tests/utils/e2e_utils.py @@ -1,11 +1,25 @@ """Utility functions for e2e tests.""" +import shlex +import subprocess + + +def uv_available(): + """Ensure uv is available before running test.""" + cmd = "uv self version -q" + cmd_parts = shlex.split(cmd) + try: + subprocess.run(cmd_parts) + return True + except FileNotFoundError: + # This is the exception raised on macOS when the command uv is unavailable. + return False def get_core_plugin_test_cmd(path_dsd, cli_options, platform_name_lower): """Get the command for running django-simple-deploy tests after a new plugin has been installed.""" test_filename = f"test_{platform_name_lower}_config.py" - + if cli_options.include_core_tests: # Run full set of core django-simple-deploy tests, and plugin integration tests. cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest" From 0bbb3e92579a001817cd64beab0e1bfb879c8c66 Mon Sep 17 00:00:00 2001 From: Eric Matthes Date: Mon, 26 May 2025 21:55:00 -0400 Subject: [PATCH 11/18] Util function for checking output of core tests. --- tests/e2e_tests/test_basic_plugin.py | 41 ++++++++++++++-------------- tests/e2e_tests/utils/e2e_utils.py | 18 +++++++++++- 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/tests/e2e_tests/test_basic_plugin.py b/tests/e2e_tests/test_basic_plugin.py index 5d00cf9..28af91e 100644 --- a/tests/e2e_tests/test_basic_plugin.py +++ b/tests/e2e_tests/test_basic_plugin.py @@ -108,18 +108,18 @@ def test_new_plugin_e2e(tmp_path_factory, cli_options): assert "test session starts" in stdout assert "[100%]" in stdout - + e2e_utils.check_core_plugin_tests(stdout, cli_options) # Check number of plugin's tests that passed and skipped. # No assertions about number skipped, but helpful to know at times. - m = re.findall(re_passed_skipped, stdout) - if m: - passed = int(m[0][0]) - skipped = int(m[0][1]) + # m = re.findall(re_passed_skipped, stdout) + # if m: + # passed = int(m[0][0]) + # skipped = int(m[0][1]) - if cli_options.include_core_tests: - assert passed >= 65 - else: - assert passed >= 18 + # if cli_options.include_core_tests: + # assert passed >= 65 + # else: + # assert passed >= 18 # Remove plugin, and test another one. @@ -163,14 +163,15 @@ def test_new_plugin_e2e(tmp_path_factory, cli_options): assert "test session starts" in stdout assert "[100%]" in stdout - # Check number of plugin's tests that passed and skipped. - # No assertions about number skipped, but helpful to know at times. - m = re.findall(re_passed_skipped, stdout) - if m: - passed = int(m[0][0]) - skipped = int(m[0][1]) - - if cli_options.include_core_tests: - assert passed >= 65 - else: - assert passed >= 18 + e2e_utils.check_core_plugin_tests(stdout, cli_options) + # # Check number of plugin's tests that passed and skipped. + # # No assertions about number skipped, but helpful to know at times. + # m = re.findall(re_passed_skipped, stdout) + # if m: + # passed = int(m[0][0]) + # skipped = int(m[0][1]) + + # if cli_options.include_core_tests: + # assert passed >= 65 + # else: + # assert passed >= 18 diff --git a/tests/e2e_tests/utils/e2e_utils.py b/tests/e2e_tests/utils/e2e_utils.py index 28cb456..62fae44 100644 --- a/tests/e2e_tests/utils/e2e_utils.py +++ b/tests/e2e_tests/utils/e2e_utils.py @@ -2,6 +2,7 @@ import shlex import subprocess +import re def uv_available(): @@ -27,4 +28,19 @@ def get_core_plugin_test_cmd(path_dsd, cli_options, platform_name_lower): # Only run the new plugin's integration tests. cmd = f"cd {path_dsd.as_posix()} && source .venv/bin/activate && pytest -k {test_filename}" - return cmd \ No newline at end of file + return cmd + + +def check_core_plugin_tests(stdout, cli_options): + """Check number of plugin's tests that passed and skipped.""" + # No assertions about number skipped, but helpful to know at times. + re_passed_skipped = r"""(\d*) passed, (\d*) skipped""" + m = re.findall(re_passed_skipped, stdout) + if m: + passed = int(m[0][0]) + skipped = int(m[0][1]) + + if cli_options.include_core_tests: + assert passed >= 65 + else: + assert passed >= 18 \ No newline at end of file From fb37c320adcc89c12b87e2f11f9cc546fc79778d Mon Sep 17 00:00:00 2001 From: Eric Matthes Date: Mon, 26 May 2025 21:59:13 -0400 Subject: [PATCH 12/18] Util function for checking output of core-only tests. --- tests/e2e_tests/test_basic_plugin.py | 41 ++++++---------------------- tests/e2e_tests/utils/e2e_utils.py | 9 ++++++ 2 files changed, 17 insertions(+), 33 deletions(-) diff --git a/tests/e2e_tests/test_basic_plugin.py b/tests/e2e_tests/test_basic_plugin.py index 28af91e..3614ba5 100644 --- a/tests/e2e_tests/test_basic_plugin.py +++ b/tests/e2e_tests/test_basic_plugin.py @@ -82,15 +82,15 @@ def test_new_plugin_e2e(tmp_path_factory, cli_options): assert "test session starts" in stdout assert "[100%]" in stdout - + e2e_utils.check_core_only_tests(stdout) # Check number of core tests that passed and skipped. - re_passed_skipped = r"""(\d*) passed, (\d*) skipped""" - m = re.findall(re_passed_skipped, stdout) - if m: - passed = int(m[0][0]) - skipped = int(m[0][1]) - assert passed >= 31 - assert skipped >= 22 + # re_passed_skipped = r"""(\d*) passed, (\d*) skipped""" + # m = re.findall(re_passed_skipped, stdout) + # if m: + # passed = int(m[0][0]) + # skipped = int(m[0][1]) + # assert passed >= 31 + # assert skipped >= 22 # Install plugin editable to django-simple-deploy env. cmd = f'uv pip install --python {path_to_python} -e "{path_new_plugin.as_posix()}[dev]"' @@ -106,20 +106,8 @@ def test_new_plugin_e2e(tmp_path_factory, cli_options): output = subprocess.run(cmd, capture_output=True,shell=True) stdout = output.stdout.decode() - assert "test session starts" in stdout assert "[100%]" in stdout e2e_utils.check_core_plugin_tests(stdout, cli_options) - # Check number of plugin's tests that passed and skipped. - # No assertions about number skipped, but helpful to know at times. - # m = re.findall(re_passed_skipped, stdout) - # if m: - # passed = int(m[0][0]) - # skipped = int(m[0][1]) - - # if cli_options.include_core_tests: - # assert passed >= 65 - # else: - # assert passed >= 18 # Remove plugin, and test another one. @@ -160,18 +148,5 @@ def test_new_plugin_e2e(tmp_path_factory, cli_options): output = subprocess.run(cmd, capture_output=True,shell=True) stdout = output.stdout.decode() - assert "test session starts" in stdout assert "[100%]" in stdout - e2e_utils.check_core_plugin_tests(stdout, cli_options) - # # Check number of plugin's tests that passed and skipped. - # # No assertions about number skipped, but helpful to know at times. - # m = re.findall(re_passed_skipped, stdout) - # if m: - # passed = int(m[0][0]) - # skipped = int(m[0][1]) - - # if cli_options.include_core_tests: - # assert passed >= 65 - # else: - # assert passed >= 18 diff --git a/tests/e2e_tests/utils/e2e_utils.py b/tests/e2e_tests/utils/e2e_utils.py index 62fae44..5c8a5ea 100644 --- a/tests/e2e_tests/utils/e2e_utils.py +++ b/tests/e2e_tests/utils/e2e_utils.py @@ -30,6 +30,15 @@ def get_core_plugin_test_cmd(path_dsd, cli_options, platform_name_lower): return cmd +def check_core_only_tests(stdout): + """Check output of running core tests with no plugin installed.""" + # No assertions about number skipped, but helpful to know at times. + re_passed_skipped = r"""(\d*) passed, (\d*) skipped""" + m = re.findall(re_passed_skipped, stdout) + if m: + passed = int(m[0][0]) + skipped = int(m[0][1]) + assert passed >= 31 def check_core_plugin_tests(stdout, cli_options): """Check number of plugin's tests that passed and skipped.""" From c6263ec8ef745845d51035a207d4b98b06651780 Mon Sep 17 00:00:00 2001 From: Eric Matthes Date: Mon, 26 May 2025 21:59:37 -0400 Subject: [PATCH 13/18] Remove unused code. --- tests/e2e_tests/test_basic_plugin.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/tests/e2e_tests/test_basic_plugin.py b/tests/e2e_tests/test_basic_plugin.py index 3614ba5..35f9fab 100644 --- a/tests/e2e_tests/test_basic_plugin.py +++ b/tests/e2e_tests/test_basic_plugin.py @@ -80,17 +80,8 @@ def test_new_plugin_e2e(tmp_path_factory, cli_options): output = subprocess.run(cmd_parts, capture_output=True) stdout = output.stdout.decode() - assert "test session starts" in stdout assert "[100%]" in stdout e2e_utils.check_core_only_tests(stdout) - # Check number of core tests that passed and skipped. - # re_passed_skipped = r"""(\d*) passed, (\d*) skipped""" - # m = re.findall(re_passed_skipped, stdout) - # if m: - # passed = int(m[0][0]) - # skipped = int(m[0][1]) - # assert passed >= 31 - # assert skipped >= 22 # Install plugin editable to django-simple-deploy env. cmd = f'uv pip install --python {path_to_python} -e "{path_new_plugin.as_posix()}[dev]"' From 1e8d2521740216c22c60d82e7d500783cf4d2787 Mon Sep 17 00:00:00 2001 From: Eric Matthes Date: Mon, 26 May 2025 22:05:54 -0400 Subject: [PATCH 14/18] One util function for checking core and plugin test results. --- tests/e2e_tests/test_basic_plugin.py | 3 ++- tests/e2e_tests/utils/e2e_utils.py | 31 ++++++++++++++++------------ 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/tests/e2e_tests/test_basic_plugin.py b/tests/e2e_tests/test_basic_plugin.py index 35f9fab..4deba63 100644 --- a/tests/e2e_tests/test_basic_plugin.py +++ b/tests/e2e_tests/test_basic_plugin.py @@ -81,7 +81,8 @@ def test_new_plugin_e2e(tmp_path_factory, cli_options): stdout = output.stdout.decode() assert "[100%]" in stdout - e2e_utils.check_core_only_tests(stdout) + # e2e_utils.check_core_only_tests(stdout) + e2e_utils.check_core_plugin_tests(stdout, cli_options, core_only=True) # Install plugin editable to django-simple-deploy env. cmd = f'uv pip install --python {path_to_python} -e "{path_new_plugin.as_posix()}[dev]"' diff --git a/tests/e2e_tests/utils/e2e_utils.py b/tests/e2e_tests/utils/e2e_utils.py index 5c8a5ea..86789e0 100644 --- a/tests/e2e_tests/utils/e2e_utils.py +++ b/tests/e2e_tests/utils/e2e_utils.py @@ -30,26 +30,31 @@ def get_core_plugin_test_cmd(path_dsd, cli_options, platform_name_lower): return cmd -def check_core_only_tests(stdout): - """Check output of running core tests with no plugin installed.""" +# def check_core_only_tests(stdout): +# """Check output of running core tests with no plugin installed.""" +# # No assertions about number skipped, but helpful to know at times. +# re_passed_skipped = r"""(\d*) passed, (\d*) skipped""" +# m = re.findall(re_passed_skipped, stdout) +# if m: +# passed = int(m[0][0]) +# skipped = int(m[0][1]) +# assert passed >= 31 + +def check_core_plugin_tests(stdout, cli_options, core_only=False): + """Check number of core and plugin tests that passed and skipped.""" # No assertions about number skipped, but helpful to know at times. re_passed_skipped = r"""(\d*) passed, (\d*) skipped""" m = re.findall(re_passed_skipped, stdout) if m: passed = int(m[0][0]) skipped = int(m[0][1]) - assert passed >= 31 -def check_core_plugin_tests(stdout, cli_options): - """Check number of plugin's tests that passed and skipped.""" - # No assertions about number skipped, but helpful to know at times. - re_passed_skipped = r"""(\d*) passed, (\d*) skipped""" - m = re.findall(re_passed_skipped, stdout) - if m: - passed = int(m[0][0]) - skipped = int(m[0][1]) - - if cli_options.include_core_tests: + if core_only: + # Core tests, no plugin installed. + assert passed >= 31 + elif cli_options.include_core_tests: + # Core tests, and plugin's integrationtests. assert passed >= 65 else: + # Plugin's integration tests, no core tests. assert passed >= 18 \ No newline at end of file From 790075a6a35e292a8402998038f87c135e4b4002 Mon Sep 17 00:00:00 2001 From: Eric Matthes Date: Mon, 26 May 2025 22:06:50 -0400 Subject: [PATCH 15/18] Remove unused code. --- tests/e2e_tests/utils/e2e_utils.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/tests/e2e_tests/utils/e2e_utils.py b/tests/e2e_tests/utils/e2e_utils.py index 86789e0..f1978fa 100644 --- a/tests/e2e_tests/utils/e2e_utils.py +++ b/tests/e2e_tests/utils/e2e_utils.py @@ -30,15 +30,6 @@ def get_core_plugin_test_cmd(path_dsd, cli_options, platform_name_lower): return cmd -# def check_core_only_tests(stdout): -# """Check output of running core tests with no plugin installed.""" -# # No assertions about number skipped, but helpful to know at times. -# re_passed_skipped = r"""(\d*) passed, (\d*) skipped""" -# m = re.findall(re_passed_skipped, stdout) -# if m: -# passed = int(m[0][0]) -# skipped = int(m[0][1]) -# assert passed >= 31 def check_core_plugin_tests(stdout, cli_options, core_only=False): """Check number of core and plugin tests that passed and skipped.""" @@ -57,4 +48,4 @@ def check_core_plugin_tests(stdout, cli_options, core_only=False): assert passed >= 65 else: # Plugin's integration tests, no core tests. - assert passed >= 18 \ No newline at end of file + assert passed >= 18 From 1aca3cfcfc3e45acd3622b6b82496ebe1d951a0d Mon Sep 17 00:00:00 2001 From: Eric Matthes Date: Mon, 26 May 2025 22:12:30 -0400 Subject: [PATCH 16/18] Util function for running core tests. --- tests/e2e_tests/test_basic_plugin.py | 19 ++++++++++--------- tests/e2e_tests/utils/e2e_utils.py | 12 ++++++++++++ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/tests/e2e_tests/test_basic_plugin.py b/tests/e2e_tests/test_basic_plugin.py index 4deba63..328ee16 100644 --- a/tests/e2e_tests/test_basic_plugin.py +++ b/tests/e2e_tests/test_basic_plugin.py @@ -74,15 +74,16 @@ def test_new_plugin_e2e(tmp_path_factory, cli_options): if run_core_plugin_tests: # Run core tests without a plugin installed. - tests_dir = path_dsd / "tests" - cmd = f"{path_to_python} -m pytest {tests_dir.as_posix()}" - cmd_parts = shlex.split(cmd) - output = subprocess.run(cmd_parts, capture_output=True) - stdout = output.stdout.decode() - - assert "[100%]" in stdout - # e2e_utils.check_core_only_tests(stdout) - e2e_utils.check_core_plugin_tests(stdout, cli_options, core_only=True) + e2e_utils.run_core_tests(path_dsd, path_to_python, cli_options) + # tests_dir = path_dsd / "tests" + # cmd = f"{path_to_python} -m pytest {tests_dir.as_posix()}" + # cmd_parts = shlex.split(cmd) + # output = subprocess.run(cmd_parts, capture_output=True) + # stdout = output.stdout.decode() + + # assert "[100%]" in stdout + # # e2e_utils.check_core_only_tests(stdout) + # e2e_utils.check_core_plugin_tests(stdout, cli_options, core_only=True) # Install plugin editable to django-simple-deploy env. cmd = f'uv pip install --python {path_to_python} -e "{path_new_plugin.as_posix()}[dev]"' diff --git a/tests/e2e_tests/utils/e2e_utils.py b/tests/e2e_tests/utils/e2e_utils.py index f1978fa..7eeb9e7 100644 --- a/tests/e2e_tests/utils/e2e_utils.py +++ b/tests/e2e_tests/utils/e2e_utils.py @@ -17,6 +17,18 @@ def uv_available(): return False +def run_core_tests(path_dsd, path_to_python, cli_options): + """Run django-simple-deploy's test suite with no plugin installed.""" + tests_dir = path_dsd / "tests" + cmd = f"{path_to_python} -m pytest {tests_dir.as_posix()}" + cmd_parts = shlex.split(cmd) + output = subprocess.run(cmd_parts, capture_output=True) + stdout = output.stdout.decode() + + assert "[100%]" in stdout + check_core_plugin_tests(stdout, cli_options, core_only=True) + + def get_core_plugin_test_cmd(path_dsd, cli_options, platform_name_lower): """Get the command for running django-simple-deploy tests after a new plugin has been installed.""" test_filename = f"test_{platform_name_lower}_config.py" From 822cc414d69e443645baaf6ebb8bb1b036f8e07a Mon Sep 17 00:00:00 2001 From: Eric Matthes Date: Mon, 26 May 2025 22:19:19 -0400 Subject: [PATCH 17/18] Remove unused code. --- tests/e2e_tests/test_basic_plugin.py | 31 ++-------------------------- tests/e2e_tests/utils/e2e_utils.py | 14 +++++++++++++ 2 files changed, 16 insertions(+), 29 deletions(-) diff --git a/tests/e2e_tests/test_basic_plugin.py b/tests/e2e_tests/test_basic_plugin.py index 328ee16..89d9dca 100644 --- a/tests/e2e_tests/test_basic_plugin.py +++ b/tests/e2e_tests/test_basic_plugin.py @@ -75,15 +75,6 @@ def test_new_plugin_e2e(tmp_path_factory, cli_options): if run_core_plugin_tests: # Run core tests without a plugin installed. e2e_utils.run_core_tests(path_dsd, path_to_python, cli_options) - # tests_dir = path_dsd / "tests" - # cmd = f"{path_to_python} -m pytest {tests_dir.as_posix()}" - # cmd_parts = shlex.split(cmd) - # output = subprocess.run(cmd_parts, capture_output=True) - # stdout = output.stdout.decode() - - # assert "[100%]" in stdout - # # e2e_utils.check_core_only_tests(stdout) - # e2e_utils.check_core_plugin_tests(stdout, cli_options, core_only=True) # Install plugin editable to django-simple-deploy env. cmd = f'uv pip install --python {path_to_python} -e "{path_new_plugin.as_posix()}[dev]"' @@ -91,16 +82,7 @@ def test_new_plugin_e2e(tmp_path_factory, cli_options): subprocess.run(cmd_parts) if run_core_plugin_tests: - # Run plugin's integration tests. - tests_dir = path_dsd / "tests" - platform_name_lower = get_platform_name_lower(plugin_config.platform_name) - cmd = e2e_utils.get_core_plugin_test_cmd(path_dsd, cli_options, platform_name_lower) - - output = subprocess.run(cmd, capture_output=True,shell=True) - stdout = output.stdout.decode() - - assert "[100%]" in stdout - e2e_utils.check_core_plugin_tests(stdout, cli_options) + e2e_utils.run_core_plugin_tests(path_dsd, plugin_config, cli_options) # Remove plugin, and test another one. @@ -133,13 +115,4 @@ def test_new_plugin_e2e(tmp_path_factory, cli_options): subprocess.run(cmd_parts) if run_core_plugin_tests: - # Run plugin's integration tests. - tests_dir = path_dsd / "tests" - platform_name_lower = get_platform_name_lower(plugin_config.platform_name) - cmd = e2e_utils.get_core_plugin_test_cmd(path_dsd, cli_options, platform_name_lower) - - output = subprocess.run(cmd, capture_output=True,shell=True) - stdout = output.stdout.decode() - - assert "[100%]" in stdout - e2e_utils.check_core_plugin_tests(stdout, cli_options) + e2e_utils.run_core_plugin_tests(path_dsd, plugin_config, cli_options) diff --git a/tests/e2e_tests/utils/e2e_utils.py b/tests/e2e_tests/utils/e2e_utils.py index 7eeb9e7..e997a93 100644 --- a/tests/e2e_tests/utils/e2e_utils.py +++ b/tests/e2e_tests/utils/e2e_utils.py @@ -4,6 +4,8 @@ import subprocess import re +from utils.generator_utils import get_platform_name_lower + def uv_available(): """Ensure uv is available before running test.""" @@ -28,6 +30,18 @@ def run_core_tests(path_dsd, path_to_python, cli_options): assert "[100%]" in stdout check_core_plugin_tests(stdout, cli_options, core_only=True) +def run_core_plugin_tests(path_dsd, plugin_config, cli_options): + """Run django-simple-deploy's test suite with a plugin installed.""" + tests_dir = path_dsd / "tests" + platform_name_lower = get_platform_name_lower(plugin_config.platform_name) + cmd = get_core_plugin_test_cmd(path_dsd, cli_options, platform_name_lower) + + output = subprocess.run(cmd, capture_output=True,shell=True) + stdout = output.stdout.decode() + + assert "[100%]" in stdout + check_core_plugin_tests(stdout, cli_options) + def get_core_plugin_test_cmd(path_dsd, cli_options, platform_name_lower): """Get the command for running django-simple-deploy tests after a new plugin has been installed.""" From 167c21d3f08a207bec6fc63c9617f25c585ecc4f Mon Sep 17 00:00:00 2001 From: Eric Matthes Date: Tue, 27 May 2025 07:08:44 -0400 Subject: [PATCH 18/18] Remove unneeded imports. --- tests/e2e_tests/test_basic_plugin.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/e2e_tests/test_basic_plugin.py b/tests/e2e_tests/test_basic_plugin.py index 89d9dca..a147b4f 100644 --- a/tests/e2e_tests/test_basic_plugin.py +++ b/tests/e2e_tests/test_basic_plugin.py @@ -18,12 +18,10 @@ from pathlib import Path import subprocess import shlex -import re import pytest from utils.plugin_config import PluginConfig -from utils.generator_utils import get_platform_name_lower from tests.e2e_tests.utils import e2e_utils import generate_plugin as gp