Remove pre-package-restructure cruft and dead features
Delete the top-level implementation superseded by the gallery/ package conversion (generate_gallery.py, orchestration/, root templates/ and assets/, python/ scripts), stray scratch files, and docs describing a container/GitLab-CI coverage workflow that no longer exists. Also drop two half-wired, never-invoked features: the backup_folder config/TUI option (create_backup() was never called from the pipeline) and the unfinished export-to-LaTeX JS/CSS. Update README's install instructions to the current Gitea remote.
This commit is contained in:
@@ -1,137 +0,0 @@
|
||||
import datetime
|
||||
import zipfile
|
||||
from unittest.mock import patch
|
||||
|
||||
from gallery.utils.backup import create_backup
|
||||
|
||||
|
||||
def test_backup_creates_zip(tmp_path):
|
||||
web_folder = tmp_path / "plots"
|
||||
web_folder.mkdir()
|
||||
(web_folder / "file1.txt").write_text("abc")
|
||||
(web_folder / "file2.txt").write_text("def")
|
||||
backup_folder = tmp_path / "backups"
|
||||
backup_folder.mkdir()
|
||||
|
||||
assert create_backup(web_folder, backup_folder) is True
|
||||
|
||||
today = datetime.date.today().strftime("%Y%m%d")
|
||||
backup_path = backup_folder / f"backup-{today}.zip"
|
||||
|
||||
assert backup_path.exists()
|
||||
with zipfile.ZipFile(backup_path, "r") as z:
|
||||
names = z.namelist()
|
||||
assert any("file1.txt" in n for n in names)
|
||||
assert any("file2.txt" in n for n in names)
|
||||
|
||||
|
||||
def test_backup_with_subdirectories(tmp_path):
|
||||
web_folder = tmp_path / "plots"
|
||||
web_folder.mkdir()
|
||||
(web_folder / "file1.txt").write_text("content1")
|
||||
|
||||
subdir = web_folder / "subdir"
|
||||
subdir.mkdir()
|
||||
(subdir / "file2.txt").write_text("content2")
|
||||
|
||||
nested_subdir = subdir / "nested"
|
||||
nested_subdir.mkdir()
|
||||
(nested_subdir / "file3.txt").write_text("content3")
|
||||
|
||||
backup_folder = tmp_path / "backups"
|
||||
backup_folder.mkdir()
|
||||
|
||||
assert create_backup(web_folder, backup_folder) is True
|
||||
|
||||
today = datetime.date.today().strftime("%Y%m%d")
|
||||
backup_path = backup_folder / f"backup-{today}.zip"
|
||||
|
||||
assert backup_path.exists()
|
||||
with zipfile.ZipFile(backup_path, "r") as z:
|
||||
names = z.namelist()
|
||||
assert any("file1.txt" in n for n in names)
|
||||
assert any("file2.txt" in n for n in names)
|
||||
assert any("file3.txt" in n for n in names)
|
||||
|
||||
|
||||
def test_backup_existing_file_is_not_overwritten(tmp_path):
|
||||
web_folder = tmp_path / "plots"
|
||||
web_folder.mkdir()
|
||||
(web_folder / "file1.txt").write_text("abc")
|
||||
|
||||
backup_folder = tmp_path / "backups"
|
||||
backup_folder.mkdir()
|
||||
|
||||
today = datetime.date.today().strftime("%Y%m%d")
|
||||
backup_path = backup_folder / f"backup-{today}.zip"
|
||||
backup_path.write_text("existing backup")
|
||||
|
||||
assert create_backup(web_folder, backup_folder) is True
|
||||
assert backup_path.read_text() == "existing backup"
|
||||
|
||||
|
||||
def test_backup_empty_folder(tmp_path):
|
||||
web_folder = tmp_path / "plots"
|
||||
web_folder.mkdir()
|
||||
|
||||
backup_folder = tmp_path / "backups"
|
||||
backup_folder.mkdir()
|
||||
|
||||
assert create_backup(web_folder, backup_folder) is True
|
||||
|
||||
today = datetime.date.today().strftime("%Y%m%d")
|
||||
backup_path = backup_folder / f"backup-{today}.zip"
|
||||
|
||||
assert backup_path.exists()
|
||||
with zipfile.ZipFile(backup_path, "r") as z:
|
||||
assert len(z.namelist()) == 0
|
||||
|
||||
|
||||
def test_backup_nonexistent_web_folder(tmp_path):
|
||||
web_folder = tmp_path / "nonexistent_plots"
|
||||
backup_folder = tmp_path / "backups"
|
||||
backup_folder.mkdir()
|
||||
|
||||
assert create_backup(web_folder, backup_folder) is True
|
||||
|
||||
today = datetime.date.today().strftime("%Y%m%d")
|
||||
backup_path = backup_folder / f"backup-{today}.zip"
|
||||
|
||||
assert backup_path.exists()
|
||||
with zipfile.ZipFile(backup_path, "r") as z:
|
||||
assert len(z.namelist()) == 0
|
||||
|
||||
|
||||
@patch("datetime.date")
|
||||
def test_backup_with_custom_date(mock_date, tmp_path):
|
||||
mock_date.today.return_value.strftime.return_value = "20230908"
|
||||
|
||||
web_folder = tmp_path / "plots"
|
||||
web_folder.mkdir()
|
||||
(web_folder / "file1.txt").write_text("test")
|
||||
|
||||
backup_folder = tmp_path / "backups"
|
||||
backup_folder.mkdir()
|
||||
|
||||
assert create_backup(web_folder, backup_folder) is True
|
||||
|
||||
backup_path = backup_folder / "backup-20230908.zip"
|
||||
assert backup_path.exists()
|
||||
|
||||
|
||||
def test_backup_folder_creation(tmp_path):
|
||||
web_folder = tmp_path / "plots"
|
||||
web_folder.mkdir()
|
||||
(web_folder / "file1.txt").write_text("test")
|
||||
|
||||
# Don't create backup folder - let create_backup() create it
|
||||
backup_folder = tmp_path / "new_backups"
|
||||
|
||||
assert create_backup(web_folder, backup_folder) is True
|
||||
|
||||
assert backup_folder.exists()
|
||||
assert backup_folder.is_dir()
|
||||
|
||||
today = datetime.date.today().strftime("%Y%m%d")
|
||||
backup_path = backup_folder / f"backup-{today}.zip"
|
||||
assert backup_path.exists()
|
||||
@@ -28,7 +28,6 @@ def test_gallery_config_defaults():
|
||||
assert cfg.plot_root == GalleryDefaults.plot_root
|
||||
assert cfg.cache_enabled == GalleryDefaults.cache_enabled
|
||||
assert cfg.inherit_from_parent == GalleryDefaults.inherit_from_parent
|
||||
assert cfg.backup_folder == ""
|
||||
|
||||
|
||||
def test_gallery_config_sources_from_dicts():
|
||||
@@ -47,7 +46,7 @@ def test_gallery_config_sources_invalid_type():
|
||||
def test_gallery_config_from_yaml(tmp_path):
|
||||
yaml_content = {
|
||||
"paths": {"web_folder": "/test/web"},
|
||||
"gallery": {"plot_root": "test_plots", "png_dpi": 200, "backup_folder": "test_backups"},
|
||||
"gallery": {"plot_root": "test_plots", "png_dpi": 200},
|
||||
"metadata": {"cache_enabled": False, "inherit_from_parent": False},
|
||||
"sources": [
|
||||
{"name": "source1", "path": "/path1"},
|
||||
@@ -64,7 +63,6 @@ def test_gallery_config_from_yaml(tmp_path):
|
||||
assert cfg.web_folder == Path("/test/web")
|
||||
assert cfg.plot_root == "test_plots"
|
||||
assert cfg.png_dpi == 200
|
||||
assert cfg.backup_folder == "test_backups"
|
||||
assert cfg.cache_enabled is False
|
||||
assert cfg.inherit_from_parent is False
|
||||
assert len(cfg.sources) == 2
|
||||
@@ -106,7 +104,6 @@ def test_gallery_config_to_yaml_round_trip(tmp_path):
|
||||
sources=[{"name": "test", "path": "/test"}],
|
||||
plot_root="plots",
|
||||
png_dpi=300,
|
||||
backup_folder="backups",
|
||||
)
|
||||
|
||||
yaml_file = tmp_path / "output_config.yaml"
|
||||
@@ -118,7 +115,6 @@ def test_gallery_config_to_yaml_round_trip(tmp_path):
|
||||
assert reloaded.web_folder == cfg.web_folder
|
||||
assert reloaded.plot_root == cfg.plot_root
|
||||
assert reloaded.png_dpi == cfg.png_dpi
|
||||
assert reloaded.backup_folder == cfg.backup_folder
|
||||
assert reloaded.sources[0].name == "test"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user