"""Coverage tests for security/__init__.py targeting ~11 missing statements.

Uncovered functions/branches:
- PathValidator ImportError fallback (lines 34-36)
- FileUploadValidator ImportError fallback (lines 44-45)
- rate_limiter ImportError fallback + no-op decorator (lines 53-59)
"""

MODULE = "local_deep_research.security"


class TestSecurityImports:
    """Tests for conditional imports in security __init__."""

    def test_all_exports_present(self):
        """All items in __all__ are importable."""
        import local_deep_research.security as sec

        for name in sec.__all__:
            assert hasattr(sec, name), f"{name} not exported"

    def test_path_validator_available(self):
        """PathValidator is available when werkzeug is installed."""
        import local_deep_research.security as sec

        # In our test environment, werkzeug should be available
        assert sec._has_path_validator is True
        assert sec.PathValidator is not None

    def test_file_upload_validator_available(self):
        """FileUploadValidator available when pdfplumber is installed."""
        import local_deep_research.security as sec

        # Check the flag - may or may not be available
        if sec._has_file_upload_validator:
            assert sec.FileUploadValidator is not None

    def test_safe_get_exported(self):
        """safe_get is properly exported."""
        from local_deep_research.security import safe_get

        assert callable(safe_get)

    def test_module_whitelist_exported(self):
        """Module whitelist utilities are exported."""
        from local_deep_research.security import (
            ALLOWED_MODULES,
            ModuleNotAllowedError,
        )

        assert isinstance(ALLOWED_MODULES, (dict, set, frozenset))
        assert issubclass(ModuleNotAllowedError, Exception)
