# Path: i3configger/context.py
# def process(item: Iterable[Union[dict, partials.Partial]]) -> dict:
# def merge_all(item: Iterable[Union[dict, partials.Partial]]) -> dict:
# def merge(dst: dict, src: dict) -> dict:
# def prune(dst: dict, src: dict) -> dict:
# def resolve_variables(ctx: dict) -> dict:
# def _resolve_variable(key, ctx, path):
# def remove_variable_markers(ctx: dict) -> dict:
# def substitute(content: str, ctx: dict):
# 
# Path: i3configger/exc.py
# class I3configgerException(Exception):
# class BuildError(I3configgerException):
# class ConfigError(I3configgerException):
# class MessageError(I3configgerException):
# class PartialsError(I3configgerException):
# class ParseError(I3configgerException):
# class ContextError(I3configgerException):
# class UserError(I3configgerException):


import pytest as pytest
from i3configger import context, exc


verySimple = {"$k1": "v1", "$k2": "v2"}
simple = {"$k1": "v1", "$k2": "v1"}
undef = {"$k1": "v1", "$k2": "$undef"}
oneIndirection = {"$k1": "$k2", "$k2": "v1"}
twoIndirections = {"$k1": "$k2", "$k2": "$k3", "$k3": "v1"}
unresolvedIndirection = {"$k1": "$k2", "$k2": "$k3", "$k3": "$k4"}


@pytest.mark.parametrize(
    "ctx, exp",
    (
        (verySimple, verySimple),
        (simple, {"$k1": "v1", "$k2": "v1"}),
        (undef, exc.ContextError),
        (oneIndirection, {"$k1": "v1", "$k2": "v1"}),
        (twoIndirections, {"$k1": "v1", "$k2": "v1", "$k3": "v1"}),
        (unresolvedIndirection, exc.ContextError),
    ),
)
def test_context(ctx, exp):
    if isinstance(exp, dict):
        ctx = context.resolve_variables(ctx)
        assert ctx == exp
    else:
        with pytest.raises(exc.ContextError):

# Path: i3configger/context.py
# def process(item: Iterable[Union[dict, partials.Partial]]) -> dict:
# def merge_all(item: Iterable[Union[dict, partials.Partial]]) -> dict:
# def merge(dst: dict, src: dict) -> dict:
# def prune(dst: dict, src: dict) -> dict:
# def resolve_variables(ctx: dict) -> dict:
# def _resolve_variable(key, ctx, path):
# def remove_variable_markers(ctx: dict) -> dict:
# def substitute(content: str, ctx: dict):
# 
# Path: i3configger/exc.py
# class I3configgerException(Exception):
# class BuildError(I3configgerException):
# class ConfigError(I3configgerException):
# class MessageError(I3configgerException):
# class PartialsError(I3configgerException):
# class ParseError(I3configgerException):
# class ContextError(I3configgerException):
# class UserError(I3configgerException):


# Path: tests/test_context.py
import pytest as pytest
from i3configger import context, exc



verySimple = {"$k1": "v1", "$k2": "v2"}
simple = {"$k1": "v1", "$k2": "v1"}
undef = {"$k1": "v1", "$k2": "$undef"}
oneIndirection = {"$k1": "$k2", "$k2": "v1"}
twoIndirections = {"$k1": "$k2", "$k2": "$k3", "$k3": "v1"}
unresolvedIndirection = {"$k1": "$k2", "$k2": "$k3", "$k3": "$k4"}


@pytest.mark.parametrize(
    "ctx, exp",
    (
        (verySimple, verySimple),
        (simple, {"$k1": "v1", "$k2": "v1"}),
        (undef, exc.ContextError),
        (oneIndirection, {"$k1": "v1", "$k2": "v1"}),
        (twoIndirections, {"$k1": "v1", "$k2": "v1", "$k3": "v1"}),
        (unresolvedIndirection, exc.ContextError),
    ),
)
def test_context(ctx, exp):
    if isinstance(exp, dict):
        ctx = context.resolve_variables(ctx)
        assert ctx == exp
    else:
        with pytest.raises(exc.ContextError):

            context.resolve_variables(ctx)