mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2026-04-06 07:47:53 +10:00
wip
This commit is contained in:
@@ -11,27 +11,27 @@ import subprocess
|
||||
def test_config_displays_all_config(tmp_path, process):
|
||||
"""Test that config without args displays all configuration."""
|
||||
os.chdir(tmp_path)
|
||||
result = subprocess.run(['archivebox', 'config'], capture_output=True, text=True)
|
||||
result = subprocess.run(["archivebox", "config"], capture_output=True, text=True)
|
||||
|
||||
assert result.returncode == 0
|
||||
output = result.stdout
|
||||
# Should show config sections
|
||||
assert len(output) > 100
|
||||
# Should show at least some standard config keys
|
||||
assert 'TIMEOUT' in output or 'OUTPUT_PERMISSIONS' in output
|
||||
assert "TIMEOUT" in output or "OUTPUT_PERMISSIONS" in output
|
||||
|
||||
|
||||
def test_config_get_specific_key(tmp_path, process):
|
||||
"""Test that config --get KEY retrieves specific value."""
|
||||
os.chdir(tmp_path)
|
||||
result = subprocess.run(
|
||||
['archivebox', 'config', '--get', 'TIMEOUT'],
|
||||
["archivebox", "config", "--get", "TIMEOUT"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
|
||||
assert result.returncode == 0
|
||||
assert 'TIMEOUT' in result.stdout
|
||||
assert "TIMEOUT" in result.stdout
|
||||
|
||||
|
||||
def test_config_set_writes_to_file(tmp_path, process):
|
||||
@@ -39,7 +39,7 @@ def test_config_set_writes_to_file(tmp_path, process):
|
||||
os.chdir(tmp_path)
|
||||
|
||||
result = subprocess.run(
|
||||
['archivebox', 'config', '--set', 'TIMEOUT=120'],
|
||||
["archivebox", "config", "--set", "TIMEOUT=120"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
@@ -47,11 +47,11 @@ def test_config_set_writes_to_file(tmp_path, process):
|
||||
assert result.returncode == 0
|
||||
|
||||
# Verify config file was updated
|
||||
config_file = tmp_path / 'ArchiveBox.conf'
|
||||
config_file = tmp_path / "ArchiveBox.conf"
|
||||
assert config_file.exists()
|
||||
|
||||
content = config_file.read_text()
|
||||
assert 'TIMEOUT' in content or '120' in content
|
||||
assert "TIMEOUT" in content or "120" in content
|
||||
|
||||
|
||||
def test_config_set_and_get_roundtrip(tmp_path, process):
|
||||
@@ -60,19 +60,19 @@ def test_config_set_and_get_roundtrip(tmp_path, process):
|
||||
|
||||
# Set a unique value
|
||||
subprocess.run(
|
||||
['archivebox', 'config', '--set', 'TIMEOUT=987'],
|
||||
["archivebox", "config", "--set", "TIMEOUT=987"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
|
||||
# Get the value back
|
||||
result = subprocess.run(
|
||||
['archivebox', 'config', '--get', 'TIMEOUT'],
|
||||
["archivebox", "config", "--get", "TIMEOUT"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
|
||||
assert '987' in result.stdout
|
||||
assert "987" in result.stdout
|
||||
|
||||
|
||||
def test_config_set_multiple_values(tmp_path, process):
|
||||
@@ -80,7 +80,7 @@ def test_config_set_multiple_values(tmp_path, process):
|
||||
os.chdir(tmp_path)
|
||||
|
||||
result = subprocess.run(
|
||||
['archivebox', 'config', '--set', 'TIMEOUT=111', 'YTDLP_TIMEOUT=222'],
|
||||
["archivebox", "config", "--set", "TIMEOUT=111", "YTDLP_TIMEOUT=222"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
@@ -88,10 +88,10 @@ def test_config_set_multiple_values(tmp_path, process):
|
||||
assert result.returncode == 0
|
||||
|
||||
# Verify both were written
|
||||
config_file = tmp_path / 'ArchiveBox.conf'
|
||||
config_file = tmp_path / "ArchiveBox.conf"
|
||||
content = config_file.read_text()
|
||||
assert '111' in content
|
||||
assert '222' in content
|
||||
assert "111" in content
|
||||
assert "222" in content
|
||||
|
||||
|
||||
def test_config_set_invalid_key_fails(tmp_path, process):
|
||||
@@ -99,7 +99,7 @@ def test_config_set_invalid_key_fails(tmp_path, process):
|
||||
os.chdir(tmp_path)
|
||||
|
||||
result = subprocess.run(
|
||||
['archivebox', 'config', '--set', 'TOTALLY_INVALID_KEY_XYZ=value'],
|
||||
["archivebox", "config", "--set", "TOTALLY_INVALID_KEY_XYZ=value"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
@@ -112,7 +112,7 @@ def test_config_set_requires_equals_sign(tmp_path, process):
|
||||
os.chdir(tmp_path)
|
||||
|
||||
result = subprocess.run(
|
||||
['archivebox', 'config', '--set', 'TIMEOUT'],
|
||||
["archivebox", "config", "--set", "TIMEOUT"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
@@ -125,13 +125,13 @@ def test_config_search_finds_keys(tmp_path, process):
|
||||
os.chdir(tmp_path)
|
||||
|
||||
result = subprocess.run(
|
||||
['archivebox', 'config', '--search', 'TIMEOUT'],
|
||||
["archivebox", "config", "--search", "TIMEOUT"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
|
||||
# Should find timeout-related config
|
||||
assert 'TIMEOUT' in result.stdout
|
||||
assert "TIMEOUT" in result.stdout
|
||||
|
||||
|
||||
def test_config_preserves_existing_values(tmp_path, process):
|
||||
@@ -140,21 +140,21 @@ def test_config_preserves_existing_values(tmp_path, process):
|
||||
|
||||
# Set first value
|
||||
subprocess.run(
|
||||
['archivebox', 'config', '--set', 'TIMEOUT=100'],
|
||||
["archivebox", "config", "--set", "TIMEOUT=100"],
|
||||
capture_output=True,
|
||||
)
|
||||
|
||||
# Set second value
|
||||
subprocess.run(
|
||||
['archivebox', 'config', '--set', 'YTDLP_TIMEOUT=200'],
|
||||
["archivebox", "config", "--set", "YTDLP_TIMEOUT=200"],
|
||||
capture_output=True,
|
||||
)
|
||||
|
||||
# Verify both are in config file
|
||||
config_file = tmp_path / 'ArchiveBox.conf'
|
||||
config_file = tmp_path / "ArchiveBox.conf"
|
||||
content = config_file.read_text()
|
||||
assert 'TIMEOUT' in content
|
||||
assert 'YTDLP_TIMEOUT' in content
|
||||
assert "TIMEOUT" in content
|
||||
assert "YTDLP_TIMEOUT" in content
|
||||
|
||||
|
||||
def test_config_file_is_valid_toml(tmp_path, process):
|
||||
@@ -162,15 +162,15 @@ def test_config_file_is_valid_toml(tmp_path, process):
|
||||
os.chdir(tmp_path)
|
||||
|
||||
subprocess.run(
|
||||
['archivebox', 'config', '--set', 'TIMEOUT=150'],
|
||||
["archivebox", "config", "--set", "TIMEOUT=150"],
|
||||
capture_output=True,
|
||||
)
|
||||
|
||||
config_file = tmp_path / 'ArchiveBox.conf'
|
||||
config_file = tmp_path / "ArchiveBox.conf"
|
||||
content = config_file.read_text()
|
||||
|
||||
# Basic TOML validation - should have sections and key=value pairs
|
||||
assert '[' in content or '=' in content
|
||||
assert "[" in content or "=" in content
|
||||
|
||||
|
||||
def test_config_updates_existing_value(tmp_path, process):
|
||||
@@ -179,22 +179,22 @@ def test_config_updates_existing_value(tmp_path, process):
|
||||
|
||||
# Set initial value
|
||||
subprocess.run(
|
||||
['archivebox', 'config', '--set', 'TIMEOUT=100'],
|
||||
["archivebox", "config", "--set", "TIMEOUT=100"],
|
||||
capture_output=True,
|
||||
)
|
||||
|
||||
# Update to new value
|
||||
subprocess.run(
|
||||
['archivebox', 'config', '--set', 'TIMEOUT=200'],
|
||||
["archivebox", "config", "--set", "TIMEOUT=200"],
|
||||
capture_output=True,
|
||||
)
|
||||
|
||||
# Get current value
|
||||
result = subprocess.run(
|
||||
['archivebox', 'config', '--get', 'TIMEOUT'],
|
||||
["archivebox", "config", "--get", "TIMEOUT"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
|
||||
# Should show updated value
|
||||
assert '200' in result.stdout
|
||||
assert "200" in result.stdout
|
||||
|
||||
Reference in New Issue
Block a user