From f787b81d7fe19345ab7cd04fce157239485afea0 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 7 Jul 2026 00:06:03 +1000 Subject: [PATCH] Add --keep option to setup-test task (#12308) Allow keeping existing data --- tasks.py | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/tasks.py b/tasks.py index b59a43d738..388c43c192 100644 --- a/tasks.py +++ b/tasks.py @@ -1840,6 +1840,7 @@ def test( @task( help={ 'dev': 'Set up development environment at the end', + 'keep': 'Keep existing demo dataset (do not re-clone)', 'validate_files': 'Validate media files are correctly copied', 'use_ssh': 'Use SSH protocol for cloning the demo dataset (requires SSH key)', 'branch': 'Specify branch of demo-dataset to clone (default = main)', @@ -1848,12 +1849,13 @@ def test( ) def setup_test( c, - ignore_update=False, - dev=False, - validate_files=False, - use_ssh=False, - verbose=False, - path='inventree-demo-dataset', + ignore_update: bool = False, + dev: bool = False, + keep: bool = False, + validate_files: bool = False, + use_ssh: bool = False, + verbose: bool = False, + path: str = 'inventree-demo-dataset', branch='main', ): """Setup a testing environment.""" @@ -1866,19 +1868,20 @@ def setup_test( template_dir = local_dir().joinpath(path) - # Remove old data directory - if template_dir.exists(): - run(c, f'rm {template_dir} -r') + if not keep: + # Remove old data directory + if template_dir.exists(): + run(c, f'rm {template_dir} -r') - URL = 'https://github.com/inventree/demo-dataset' + URL = 'https://github.com/inventree/demo-dataset' - if use_ssh: - # Use SSH protocol for cloning the demo dataset - URL = 'git@github.com:inventree/demo-dataset.git' + if use_ssh: + # Use SSH protocol for cloning the demo dataset + URL = 'git@github.com:inventree/demo-dataset.git' - # Get test data - info('Cloning demo dataset ...') - run(c, f'git clone {URL} {template_dir} -b {branch} -v --depth=1') + # Get test data + info('Cloning demo dataset ...') + run(c, f'git clone {URL} {template_dir} -b {branch} -v --depth=1') # Make sure migrations are done - might have just deleted sqlite database if not ignore_update: