"""Tests for defaults module."""

from pathlib import Path


class TestDefaultsDir:
    def test_defaults_dir_exists(self):
        from local_deep_research.defaults import DEFAULTS_DIR

        assert isinstance(DEFAULTS_DIR, Path)
        assert DEFAULTS_DIR.exists()


class TestDefaultFiles:
    def test_default_files_dict(self):
        from local_deep_research.defaults import DEFAULT_FILES

        assert isinstance(DEFAULT_FILES, dict)
        assert len(DEFAULT_FILES) > 0

    def test_main_toml_in_defaults(self):
        from local_deep_research.defaults import DEFAULT_FILES

        assert "main.toml" in DEFAULT_FILES

    def test_search_engines_toml_in_defaults(self):
        from local_deep_research.defaults import DEFAULT_FILES

        assert "search_engines.toml" in DEFAULT_FILES


class TestGetDefaultFilePath:
    def test_returns_path_for_known_file(self):
        from local_deep_research.defaults import get_default_file_path

        path = get_default_file_path("main.toml")
        assert path is not None
        assert isinstance(path, Path)

    def test_returns_none_for_unknown_file(self):
        from local_deep_research.defaults import get_default_file_path

        path = get_default_file_path("nonexistent.toml")
        assert path is None


class TestListDefaultFiles:
    def test_returns_list(self):
        from local_deep_research.defaults import list_default_files

        files = list_default_files()
        assert isinstance(files, list)
        assert len(files) > 0

    def test_contains_expected_files(self):
        from local_deep_research.defaults import list_default_files

        files = list_default_files()
        assert "main.toml" in files


class TestEnsureDefaultsExist:
    def test_returns_boolean(self):
        from local_deep_research.defaults import ensure_defaults_exist

        result = ensure_defaults_exist()
        assert isinstance(result, bool)

    def test_returns_true_when_all_exist(self):
        from local_deep_research.defaults import ensure_defaults_exist

        # In a properly installed package, all defaults should exist
        result = ensure_defaults_exist()
        # Don't assert True because some files may be missing in test env
        assert result is True or result is False
