from edpconfigprovider._utils import get_dict_value


class TestGetDictValue:
    def test_simple_single_key(self):
        assert get_dict_value({"a": 1}, ["a"]) == 1

    def test_nested_path(self):
        assert get_dict_value({"a": {"b": 2}}, ["a", "b"]) == 2

    def test_missing_key_returns_default(self):
        assert get_dict_value({"a": 1}, ["x"]) is None

    def test_missing_key_returns_custom_default(self):
        assert get_dict_value({"a": 1}, ["x"], default_value="fallback") == "fallback"

    def test_none_value_returns_default(self):
        assert get_dict_value({"a": None}, ["a"]) is None

    def test_none_value_returns_custom_default(self):
        assert get_dict_value({"a": None}, ["a"], default_value="fallback") == "fallback"

    def test_partial_path_missing(self):
        assert get_dict_value({"a": {"b": 1}}, ["a", "z"]) is None

    def test_empty_path(self):
        assert get_dict_value({"a": 1}, []) is None

    def test_empty_dict(self):
        assert get_dict_value({}, ["a"]) is None

    def test_deeply_nested(self):
        data = {"a": {"b": {"c": {"d": 42}}}}
        assert get_dict_value(data, ["a", "b", "c", "d"]) == 42
