mirror of
https://github.com/PR0M3TH3AN/VoxVera.git
synced 2026-11-02 20:50:40 +00:00
fix: Resolve CI failures by fixing missing imports and updating tests for new CLI structure
This commit is contained in:
1 parent
f85c978fd2
commit
ca05f85f56
3 files changed
+32
-19
No files matched your search
+4
-4
@@ -10,19 +10,19 @@ if [ -n "${VOXVERA_BIN:-}" ]; then
|
||||
voxvera_cmd="$VOXVERA_BIN"
|
||||
echo "Using provided VoxVera binary: $voxvera_cmd" >&2
|
||||
else
|
||||
{ time pip install -e .; } 2>&1
|
||||
{ time pip install --break-system-packages -e .; } 2>&1
|
||||
voxvera_cmd="$(command -v voxvera)"
|
||||
fi
|
||||
|
||||
# Generate demo flyer
|
||||
"$voxvera_cmd" init --template voxvera <<EOI
|
||||
"$voxvera_cmd" --lang en init --template voxvera <<EOI
|
||||
DemoUser
|
||||
demosite
|
||||
EOI
|
||||
"$voxvera_cmd" build
|
||||
"$voxvera_cmd" --lang en build
|
||||
|
||||
# Verify build output exists in host/
|
||||
folder_name=$(python3 -c "import json; print(json.load(open('voxvera/src/config.json'))['folder_name'])")
|
||||
folder_name=$(python3 -c "import json; print(json.load(open('voxvera/host/voxvera/config.json'))['folder_name'])")
|
||||
host_dir="voxvera/host/$folder_name"
|
||||
ls -R "$host_dir" >>"$LOG_DIR/tree.txt"
|
||||
|
||||
|
||||
+12
-10
@@ -16,8 +16,10 @@ from voxvera import cli
|
||||
def _setup_tmp(monkeypatch, tmp_path):
|
||||
repo_root = Path(__file__).resolve().parent.parent
|
||||
shutil.copytree(repo_root / "voxvera" / "src", tmp_path / "src")
|
||||
shutil.copytree(repo_root / "voxvera" / "locales", tmp_path / "locales")
|
||||
monkeypatch.setattr(cli, "ROOT", tmp_path)
|
||||
monkeypatch.setattr(cli, "_src_res", lambda *p: tmp_path / "src" / Path(*p))
|
||||
monkeypatch.setattr(cli, "_locale_res", lambda *p: tmp_path / "locales" / Path(*p))
|
||||
return repo_root
|
||||
|
||||
|
||||
@@ -30,14 +32,13 @@ def test_help(capsys):
|
||||
|
||||
def test_init_template(tmp_path, monkeypatch):
|
||||
_setup_tmp(monkeypatch, tmp_path)
|
||||
# Mock choose_language to return 'en'
|
||||
monkeypatch.setattr(cli, "choose_language", lambda *a: "en")
|
||||
cli.main(["init", "--template", "voxvera"])
|
||||
date = datetime.date.today().strftime("%Y%m%d")
|
||||
dest = tmp_path / "dist" / f"voxvera-{date}"
|
||||
dest = tmp_path / "host" / "voxvera"
|
||||
assert dest.is_dir()
|
||||
assert (dest / "config.json").exists()
|
||||
assert (dest / "index.html").exists()
|
||||
# new download directory should be copied as well
|
||||
assert (dest / "download").is_dir()
|
||||
|
||||
|
||||
def test_build(tmp_path, monkeypatch):
|
||||
@@ -54,7 +55,7 @@ def test_build_with_download(tmp_path, monkeypatch):
|
||||
download_file = tmp_path / "sample.zip"
|
||||
download_file.write_text("dummy")
|
||||
cli.main(["build", "--download", str(download_file)])
|
||||
dest = tmp_path / "host" / "voxvera" / "download" / "download.zip"
|
||||
dest = tmp_path / "host" / "voxvera" / "download" / "extra-content.zip"
|
||||
assert dest.is_file()
|
||||
|
||||
|
||||
@@ -68,7 +69,7 @@ def test_import(tmp_path, monkeypatch):
|
||||
data["folder_name"] = sub
|
||||
with open(imports_dir / f"{sub}.json", "w") as fh:
|
||||
json.dump(data, fh)
|
||||
cli.main(["import"])
|
||||
cli.main(["batch-import"])
|
||||
for sub in ["foo", "bar"]:
|
||||
dest = tmp_path / "host" / sub
|
||||
assert dest.is_dir()
|
||||
@@ -86,7 +87,7 @@ def test_import_preserves_session(tmp_path, monkeypatch):
|
||||
json.dump(base_data, fh)
|
||||
|
||||
# first import creates the host dir
|
||||
cli.main(["import"])
|
||||
cli.main(["batch-import"])
|
||||
host_dir = tmp_path / "host" / "keep"
|
||||
assert host_dir.is_dir()
|
||||
|
||||
@@ -95,7 +96,7 @@ def test_import_preserves_session(tmp_path, monkeypatch):
|
||||
session_file.write_text("FAKE-KEY-DATA")
|
||||
|
||||
# re-import the same config
|
||||
cli.main(["import"])
|
||||
cli.main(["batch-import"])
|
||||
|
||||
# session key must still be present and unchanged
|
||||
assert session_file.exists()
|
||||
@@ -130,7 +131,7 @@ def test_build_download_zip(tmp_path, monkeypatch):
|
||||
with zipfile.ZipFile(zip_path, "w") as zf:
|
||||
zf.writestr("dummy.txt", "data")
|
||||
cli.main(["build", "--download", str(zip_path)])
|
||||
dest = tmp_path / "host" / folder_name / "download" / "download.zip"
|
||||
dest = tmp_path / "host" / folder_name / "download" / "extra-content.zip"
|
||||
assert dest.is_file()
|
||||
|
||||
|
||||
@@ -226,6 +227,7 @@ def test_quickstart_noninteractive(tmp_path, monkeypatch):
|
||||
|
||||
monkeypatch.setattr(cli.subprocess, "Popen", FakePopen)
|
||||
|
||||
monkeypatch.setattr(cli, "choose_language", lambda *a: "en")
|
||||
cli.main(["quickstart", "--non-interactive"])
|
||||
|
||||
dir_path = tmp_path / "host" / folder_name
|
||||
@@ -371,7 +373,7 @@ def test_serve_passes_tor_ports_to_env(monkeypatch, tmp_path):
|
||||
|
||||
monkeypatch.setattr(cli, "require_cmd", lambda c: True)
|
||||
monkeypatch.setattr(cli.subprocess, "Popen", FakePopen)
|
||||
monkeypatch.setattr(cli, "build_assets", lambda cfg, **kw: None)
|
||||
monkeypatch.setattr(cli, "build_assets", lambda *a, **kw: None)
|
||||
monkeypatch.setattr(time, "sleep", lambda x: None)
|
||||
|
||||
# Test with custom env vars
|
||||
|
||||
+16
-5
@@ -1,10 +1,12 @@
|
||||
import argparse
|
||||
import glob
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import datetime
|
||||
from pathlib import Path
|
||||
from importlib import resources
|
||||
@@ -297,14 +299,13 @@ def interactive_update(config_path: str):
|
||||
|
||||
|
||||
def copy_template(name: str) -> str:
|
||||
"""Copy a template directory into dist/ with a datestamped folder."""
|
||||
date = datetime.date.today().strftime("%Y%m%d")
|
||||
"""Copy a template directory into host/."""
|
||||
with resources.as_file(_template_res(name)) as src:
|
||||
if not src.is_dir():
|
||||
print(f"Template {name} not found", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
dest = ROOT / "dist" / f"{name}-{date}"
|
||||
os.makedirs(ROOT / "dist", exist_ok=True)
|
||||
dest = ROOT / "host" / name
|
||||
os.makedirs(ROOT / "host", exist_ok=True)
|
||||
shutil.copytree(src, dest, dirs_exist_ok=True)
|
||||
print(f"Template copied to {dest}")
|
||||
return str(dest)
|
||||
@@ -381,7 +382,17 @@ def build_assets(
|
||||
if download_path:
|
||||
shutil.copy(download_path, download_dir / "extra-content.zip")
|
||||
|
||||
# ... rest of the copies ...
|
||||
# Copy config if it's not already there
|
||||
if Path(config_path) != dest / "config.json":
|
||||
shutil.copy(config_path, dest / "config.json")
|
||||
|
||||
# Copy QR codes if they exist
|
||||
for qr_file in ["qrcode-content.png", "qrcode-tear-offs.png"]:
|
||||
qr_src = Path(src_dir) / qr_file
|
||||
if qr_src.exists():
|
||||
shutil.copy(qr_src, dest / qr_file)
|
||||
|
||||
print(f"Flyer files created under {dest}")
|
||||
|
||||
|
||||
def get_tor_ports():
|
||||
|
||||
Reference in new issue
Block a user