# 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: i3configger/partials.py
# SPECIAL_SELECTORS = {"hostname": socket.gethostname()}
# EXCLUDE_MARKER = "."
# class Partial:
#     def __init__(self, path: Path):
#     def __repr__(self):
#     def __lt__(self, other):
#     def get_pruned_content(self) -> str:
#     def contain_something(lines):
#     def context(self):
# def find(
#     prts: List[Partial], key: str, value: str = None
# ) -> Union[Partial, List[Partial]]:
# def select(partials, selection, excludes=None) -> List[Partial]:
#     def _select():
# def create(partialsPath) -> List[Partial]:


from pathlib import Path
from i3configger import exc, partials
import pytest



SCHEMES = Path(__file__).parents[1] / "examples" / "4-schemes" / "config.d"


def test_create():
    prts = partials.create(SCHEMES)
    assert len(prts) == 3


@pytest.mark.parametrize(
    "key, value, exp",
    (
        ("", "", exc.ConfigError),
        ("some-key", "", exc.ConfigError),
        ("", "", exc.ConfigError),
        (None, None, exc.ConfigError),
        ("non-existing-key", "some-value", exc.ConfigError),
        ("non-existing-key", "none-existing-value", exc.ConfigError),
        ("some-category", "none-existing-value", exc.ConfigError),
        ("some-key", "value1", True),
        ("some-key", "value2", True),
    ),
)
def test_select(key, value, exp):
    prts = partials.create(SCHEMES)
    selector = {key: value}
    if not isinstance(exp, bool):
        with pytest.raises(exp):

# 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: i3configger/partials.py
# SPECIAL_SELECTORS = {"hostname": socket.gethostname()}
# EXCLUDE_MARKER = "."
# class Partial:
#     def __init__(self, path: Path):
#     def __repr__(self):
#     def __lt__(self, other):
#     def get_pruned_content(self) -> str:
#     def contain_something(lines):
#     def context(self):
# def find(
#     prts: List[Partial], key: str, value: str = None
# ) -> Union[Partial, List[Partial]]:
# def select(partials, selection, excludes=None) -> List[Partial]:
#     def _select():
# def create(partialsPath) -> List[Partial]:


# Path: tests/test_partials.py
from pathlib import Path
from i3configger import exc, partials
import pytest




SCHEMES = Path(__file__).parents[1] / "examples" / "4-schemes" / "config.d"


def test_create():
    prts = partials.create(SCHEMES)
    assert len(prts) == 3


@pytest.mark.parametrize(
    "key, value, exp",
    (
        ("", "", exc.ConfigError),
        ("some-key", "", exc.ConfigError),
        ("", "", exc.ConfigError),
        (None, None, exc.ConfigError),
        ("non-existing-key", "some-value", exc.ConfigError),
        ("non-existing-key", "none-existing-value", exc.ConfigError),
        ("some-category", "none-existing-value", exc.ConfigError),
        ("some-key", "value1", True),
        ("some-key", "value2", True),
    ),
)
def test_select(key, value, exp):
    prts = partials.create(SCHEMES)
    selector = {key: value}
    if not isinstance(exp, bool):
        with pytest.raises(exp):

            partials.select(prts, selector)