mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-23 15:38:55 +01:00
1374065092
- Add custom validator to throw if neither input_filter or input_<files|directories> are specified - Set field expecting paths to type Path - Now that default_config isn't used in code. We can update fields in rawconfig to specify whether they're required or not. This lets pydantic validate config file and throw appropriate error
44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
# Standard Modules
|
|
from pathlib import Path
|
|
|
|
# Internal Packages
|
|
from src.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 == [Path('~/first_from_config.org'), Path('~/second_from_config.org')]
|
|
assert actual_args.verbose == 3
|