wip
This commit is contained in:
@@ -91,21 +91,42 @@ def blender_container(docker_client, blender_image, tmp_path):
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def addon_package(tmp_path):
|
||||
def addon_package(tmp_path, request):
|
||||
"""
|
||||
Package the addon as a zip file for installation in Blender.
|
||||
|
||||
Detects version type from test file name and patches VERSION_TYPE accordingly.
|
||||
|
||||
Returns path to the packaged addon zip.
|
||||
"""
|
||||
src_dir = Path(__file__).parent.parent.parent / "src"
|
||||
addon_zip = tmp_path / "text_texture_generator.zip"
|
||||
|
||||
# Create zip with addon contents
|
||||
# Determine version type from test module name
|
||||
test_file = request.node.fspath.basename
|
||||
version_type = "free" if "free_version" in test_file else "full"
|
||||
|
||||
# Copy src to temp and patch constants.py
|
||||
temp_src = tmp_path / "src_temp"
|
||||
shutil.copytree(src_dir, temp_src)
|
||||
|
||||
constants_file = temp_src / "utils" / "constants.py"
|
||||
content = constants_file.read_text()
|
||||
content = content.replace('VERSION_TYPE = "free"', f'VERSION_TYPE = "{version_type}"')
|
||||
constants_file.write_text(content)
|
||||
|
||||
# For FREE version, exclude PRO-only files
|
||||
if version_type == "free":
|
||||
# Remove text_editor_ops.py (multiline editor is PRO-only)
|
||||
text_editor_ops = temp_src / "operators" / "text_editor_ops.py"
|
||||
if text_editor_ops.exists():
|
||||
text_editor_ops.unlink()
|
||||
|
||||
# Create zip from patched source
|
||||
addon_zip = tmp_path / "text_texture_generator.zip"
|
||||
with zipfile.ZipFile(addon_zip, 'w', zipfile.ZIP_DEFLATED) as zf:
|
||||
for file_path in src_dir.rglob("*"):
|
||||
for file_path in temp_src.rglob("*"):
|
||||
if file_path.is_file():
|
||||
# Add file with relative path from src/
|
||||
arc_name = f"text_texture_generator/{file_path.relative_to(src_dir)}"
|
||||
arc_name = f"text_texture_generator/{file_path.relative_to(temp_src)}"
|
||||
zf.write(file_path, arc_name)
|
||||
|
||||
return addon_zip
|
||||
Reference in New Issue
Block a user