Fix mypy errors in the tests
The config values are now a TypedDict, so check inputs for None before sorting, use literal keys and use ConfigArgs as the fake _read_config() return type.
This commit is contained in:
+1
-1
@@ -91,7 +91,7 @@ def config_calls(monkeypatch: pytest.MonkeyPatch) -> list[tuple[str, Optional[st
|
||||
calls: list[tuple[str, Optional[str]]] = []
|
||||
read_config = sb._read_config
|
||||
|
||||
def record(config_file: str, user: Optional[str] = None) -> dict[str, Any]:
|
||||
def record(config_file: str, user: Optional[str] = None) -> sb.ConfigArgs:
|
||||
calls.append((config_file, user))
|
||||
|
||||
return read_config('/nonexistent/simple_backup.conf', user)
|
||||
|
||||
@@ -85,6 +85,7 @@ keep=3
|
||||
|
||||
config_args = sb._read_config(config_file, USER)
|
||||
|
||||
assert config_args['inputs'] is not None
|
||||
assert sorted(config_args['inputs']) == [f'{tmp_path}/one', f'{tmp_path}/two']
|
||||
# Expanded later, as it may be a path on the server
|
||||
assert config_args['output'] == '~/backups'
|
||||
@@ -176,9 +177,9 @@ numeric_ids=
|
||||
|
||||
config_args = sb._read_config(config_file, USER)
|
||||
|
||||
for key in ['ssh_host', 'ssh_user', 'ssh_keyfile']:
|
||||
assert config_args[key] is None
|
||||
|
||||
assert config_args['ssh_host'] is None
|
||||
assert config_args['ssh_user'] is None
|
||||
assert config_args['ssh_keyfile'] is None
|
||||
assert config_args['remote_sudo'] is False
|
||||
assert config_args['numeric_ids'] is False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user