mirror of
https://github.com/inventree/InvenTree.git
synced 2026-08-30 16:58:06 +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(
|
@task(
|
||||||
help={
|
help={
|
||||||
'dev': 'Set up development environment at the end',
|
'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',
|
'validate_files': 'Validate media files are correctly copied',
|
||||||
'use_ssh': 'Use SSH protocol for cloning the demo dataset (requires SSH key)',
|
'use_ssh': 'Use SSH protocol for cloning the demo dataset (requires SSH key)',
|
||||||
'branch': 'Specify branch of demo-dataset to clone (default = main)',
|
'branch': 'Specify branch of demo-dataset to clone (default = main)',
|
||||||
@@ -1848,12 +1849,13 @@ def test(
|
|||||||
)
|
)
|
||||||
def setup_test(
|
def setup_test(
|
||||||
c,
|
c,
|
||||||
ignore_update=False,
|
ignore_update: bool = False,
|
||||||
dev=False,
|
dev: bool = False,
|
||||||
validate_files=False,
|
keep: bool = False,
|
||||||
use_ssh=False,
|
validate_files: bool = False,
|
||||||
verbose=False,
|
use_ssh: bool = False,
|
||||||
path='inventree-demo-dataset',
|
verbose: bool = False,
|
||||||
|
path: str = 'inventree-demo-dataset',
|
||||||
branch='main',
|
branch='main',
|
||||||
):
|
):
|
||||||
"""Setup a testing environment."""
|
"""Setup a testing environment."""
|
||||||
@@ -1866,19 +1868,20 @@ def setup_test(
|
|||||||
|
|
||||||
template_dir = local_dir().joinpath(path)
|
template_dir = local_dir().joinpath(path)
|
||||||
|
|
||||||
# Remove old data directory
|
if not keep:
|
||||||
if template_dir.exists():
|
# Remove old data directory
|
||||||
run(c, f'rm {template_dir} -r')
|
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:
|
if use_ssh:
|
||||||
# Use SSH protocol for cloning the demo dataset
|
# Use SSH protocol for cloning the demo dataset
|
||||||
URL = 'git@github.com:inventree/demo-dataset.git'
|
URL = 'git@github.com:inventree/demo-dataset.git'
|
||||||
|
|
||||||
# Get test data
|
# Get test data
|
||||||
info('Cloning demo dataset ...')
|
info('Cloning demo dataset ...')
|
||||||
run(c, f'git clone {URL} {template_dir} -b {branch} -v --depth=1')
|
run(c, f'git clone {URL} {template_dir} -b {branch} -v --depth=1')
|
||||||
|
|
||||||
# Make sure migrations are done - might have just deleted sqlite database
|
# Make sure migrations are done - might have just deleted sqlite database
|
||||||
if not ignore_update:
|
if not ignore_update:
|
||||||
|
|||||||
Reference in New Issue
Block a user