mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-27 17:35:07 +01:00
71 lines
2.4 KiB
Python
71 lines
2.4 KiB
Python
|
# Standard Modules
|
||
|
from pathlib import Path
|
||
|
|
||
|
# Internal Packages
|
||
|
from utils.cli import cli
|
||
|
|
||
|
|
||
|
# Test
|
||
|
# ----------------------------------------------------------------------------------------------------
|
||
|
def test_cli_minimal_default():
|
||
|
# Act
|
||
|
actual_args = cli(['--config-file=tests/data/config.yml'])
|
||
|
|
||
|
# Assert
|
||
|
assert actual_args.config_file == Path('tests/data/config.yml')
|
||
|
assert actual_args.regenerate == False
|
||
|
assert actual_args.verbose == 0
|
||
|
|
||
|
# ----------------------------------------------------------------------------------------------------
|
||
|
def test_cli_flags():
|
||
|
# Act
|
||
|
actual_args = cli(['--config-file=tests/data/config.yml',
|
||
|
'--regenerate',
|
||
|
'-vvv'])
|
||
|
|
||
|
# Assert
|
||
|
assert actual_args.config_file == Path('tests/data/config.yml')
|
||
|
assert actual_args.regenerate == True
|
||
|
assert actual_args.verbose == 3
|
||
|
|
||
|
|
||
|
# ----------------------------------------------------------------------------------------------------
|
||
|
def test_cli_config_from_file():
|
||
|
# Act
|
||
|
actual_args = cli(['--config-file=tests/data/config.yml',
|
||
|
'--regenerate',
|
||
|
'-vvv'])
|
||
|
|
||
|
# Assert
|
||
|
assert actual_args.config_file == Path('tests/data/config.yml')
|
||
|
assert actual_args.regenerate == True
|
||
|
assert actual_args.config is not None
|
||
|
assert actual_args.config['content-type']['org']['input-files'] == ['~/first_from_config.org', '~/second_from_config.org']
|
||
|
assert actual_args.verbose == 3
|
||
|
|
||
|
|
||
|
# ----------------------------------------------------------------------------------------------------
|
||
|
def test_cli_config_from_cmd_args():
|
||
|
""
|
||
|
# Act
|
||
|
actual_args = cli(['--org-files=first.org'])
|
||
|
|
||
|
# Assert
|
||
|
assert actual_args.org_files == ['first.org']
|
||
|
assert actual_args.config_file is None
|
||
|
assert actual_args.config is not None
|
||
|
assert actual_args.config['content-type']['org']['input-files'] == ['first.org']
|
||
|
|
||
|
|
||
|
# ----------------------------------------------------------------------------------------------------
|
||
|
def test_cli_config_from_cmd_args_override_config_file():
|
||
|
# Act
|
||
|
actual_args = cli(['--config-file=tests/data/config.yml',
|
||
|
'--org-files=first.org'])
|
||
|
|
||
|
# Assert
|
||
|
assert actual_args.org_files == ['first.org']
|
||
|
assert actual_args.config_file == Path('tests/data/config.yml')
|
||
|
assert actual_args.config is not None
|
||
|
assert actual_args.config['content-type']['org']['input-files'] == ['first.org']
|