mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-27 17:35:07 +01:00
Update CLI tests since config_file arg has become optional (again)
This commit is contained in:
parent
a748acfeeb
commit
fc48ee62ad
1 changed files with 14 additions and 5 deletions
|
@ -13,28 +13,37 @@ from src.utils.cli import cli
|
|||
# ----------------------------------------------------------------------------------------------------
|
||||
def test_cli_minimal_default():
|
||||
# Act
|
||||
actual_args = cli(['tests/data/config.yml'])
|
||||
actual_args = cli([])
|
||||
|
||||
# Assert
|
||||
assert actual_args.config_file == Path('tests/data/config.yml')
|
||||
assert actual_args.config_file == Path('~/.khoj/khoj.yml')
|
||||
assert actual_args.regenerate == False
|
||||
assert actual_args.no_gui == False
|
||||
assert actual_args.verbose == 0
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------
|
||||
def test_cli_invalid_config_file_path():
|
||||
# Arrange
|
||||
non_existent_config_file = f"non-existent-khoj-{random()}.yml"
|
||||
|
||||
# Act
|
||||
with pytest.raises(ValueError):
|
||||
cli([f"non-existent-khoj-{random()}.yml"])
|
||||
actual_args = cli([f'-c={non_existent_config_file}'])
|
||||
|
||||
# Assert
|
||||
assert actual_args.config_file == Path(non_existent_config_file)
|
||||
assert actual_args.config == None
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------
|
||||
def test_cli_config_from_file():
|
||||
# Act
|
||||
actual_args = cli(['tests/data/config.yml',
|
||||
actual_args = cli(['-c=tests/data/config.yml',
|
||||
'--regenerate',
|
||||
'--no-gui',
|
||||
'-vvv'])
|
||||
|
||||
# Assert
|
||||
assert actual_args.config_file == Path('tests/data/config.yml')
|
||||
assert actual_args.no_gui == True
|
||||
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')]
|
||||
|
|
Loading…
Reference in a new issue