"""Tests for packaging configuration — addon package data path resolution."""

from pathlib import Path

import pytest


def test_addon_package_importable():
    """godotiq.addon is importable as a Python package."""
    import godotiq.addon
    assert godotiq.addon is not None


def test_addon_directory_is_real_path():
    """The addon __init__.py resolves to a real filesystem directory."""
    import godotiq.addon
    addon_dir = Path(godotiq.addon.__file__).parent
    assert addon_dir.is_dir()


def _addon_dir() -> Path:
    import godotiq.addon
    return Path(godotiq.addon.__file__).parent


def test_addon_contains_plugin_cfg():
    """Addon directory contains plugin.cfg (requires force-include via wheel install)."""
    plugin_cfg = _addon_dir() / "plugin.cfg"
    if not plugin_cfg.exists():
        pytest.skip("plugin.cfg not present — verified during wheel build (section-05)")
    assert plugin_cfg.exists()


def test_addon_contains_gd_files():
    """Addon directory contains at least 5 .gd files (requires force-include via wheel install)."""
    gd_files = list(_addon_dir().glob("*.gd"))
    if len(gd_files) < 5:
        pytest.skip(".gd files not present — verified during wheel build (section-05)")
    assert len(gd_files) >= 5, f"Expected >= 5 .gd files, found {len(gd_files)}: {gd_files}"
