"""
EditingMode 剪辑模式枚举单元测试
"""

from packages.domain.editing_mode import EditingMode


class TestEditingMode:
    """EditingMode 枚举测试"""

    def test_all_modes_exist(self):
        assert EditingMode.ONE_TAKE == "one_take"
        assert EditingMode.PIP == "pip"
        assert EditingMode.VOICE_OVER == "voice_over"
        assert EditingMode.VOICE_PIP == "voice_pip"

    def test_total_count(self):
        assert len(EditingMode) == 4

    def test_is_string_type(self):
        for mode in EditingMode:
            assert isinstance(mode.value, str)
            assert isinstance(mode, str)

    def test_mode_descriptions(self):
        """验证模式值有意义"""
        assert "one" in EditingMode.ONE_TAKE
        assert "pip" in EditingMode.PIP
        assert "voice" in EditingMode.VOICE_OVER
        assert "voice" in EditingMode.VOICE_PIP

    def test_usage_in_comparison(self):
        mode = EditingMode.ONE_TAKE
        assert mode == "one_take"
        assert mode != "pip"

    def test_iterable(self):
        modes = list(EditingMode)
        assert len(modes) == 4
        assert EditingMode.ONE_TAKE in modes


class TestEditingModeExtended:
    """EditingMode 深度补充测试"""

    def test_from_string_value(self):
        """可以从字符串值构造枚举"""
        assert EditingMode("one_take") == EditingMode.ONE_TAKE
        assert EditingMode("pip") == EditingMode.PIP
        assert EditingMode("voice_over") == EditingMode.VOICE_OVER
        assert EditingMode("voice_pip") == EditingMode.VOICE_PIP

    def test_invalid_string_raises(self):
        import pytest

        with pytest.raises(ValueError):
            EditingMode("invalid_mode")

    def test_string_concatenation(self):
        """StrEnum 支持字符串拼接"""
        result = "mode_" + EditingMode.ONE_TAKE
        assert result == "mode_one_take"

    def test_dict_key_usage(self):
        """可以作为字典 key 使用"""
        mapping = {
            EditingMode.ONE_TAKE: "顺序拼接",
            EditingMode.PIP: "画中画",
        }
        assert mapping[EditingMode.ONE_TAKE] == "顺序拼接"
        assert mapping[EditingMode.PIP] == "画中画"
        assert len(mapping) == 2

    def test_value_lowercase(self):
        """所有枚举值都是小写字母+下划线"""
        for mode in EditingMode:
            assert mode.value == mode.value.lower()
            assert " " not in mode.value

    def test_unique_values(self):
        """所有枚举值唯一"""
        values = [m.value for m in EditingMode]
        assert len(values) == len(set(values))

    def test_membership_test(self):
        assert EditingMode.ONE_TAKE in EditingMode
        assert "one_take" in [m.value for m in EditingMode]

    def test_comparison_with_string(self):
        """和字符串直接比较"""
        mode = EditingMode.VOICE_OVER
        assert mode == "voice_over"
        assert mode != "pip"
        assert "voice_over" == mode
