mirror of
https://github.com/inventree/InvenTree.git
synced 2026-07-07 07:31:24 +00:00
Add --keep option to setup-test task (#12308)
Allow keeping existing data
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user