# Path: i3configger/build.py
# def build_all():
# def generate_contents(cnf: config.I3configgerConfig, prts, msg):
# def make_header(partialsPath):
# def generate_main_content(partialsPath, selected, ctx):
# def get_bar_setting(barCnf, prts, ctx):
# def generate_i3bar_content(prts, selectValue, ctx):
# def check_config(content):
# def persist_results(pathContentsMap):
# 
# Path: i3configger/config.py
# class MARK:
# class I3configgerConfig:
#     COMMENT = "#"
#     SET = "set"
#     VAR = "$"
# SUFFIX = ".conf"
# I3BAR = "i3bar"
# DEFAULTS = {
#     "main": {
#         "target": "../config",
#         "i3_refresh_msg": "reload",
#         "status_command": "i3status",
#         "log": None,
#         "notify": False,
#     },
#     "bars": {
#         "defaults": {"template": "tpl", "target": "..", "select": "default"},
#         "targets": {},
#     },
# }
# CONFIG_CANDIDATES = [
#     Path("~/.i3").expanduser(),
#     Path(os.getenv("XDG_CONFIG_HOME", "~/.config/")).expanduser() / "i3",
# ]
#     PARTIALS_NAME = "config.d"
#     CONFIG_NAME = "i3configger.json"
#     MESSAGES_NAME = ".messages.json"
#     def __init__(self, load=True):
#     def __str__(self):
#     def load(self):
#     def get_bar_targets(self):
# def fetch(path: Path) -> dict:
# def freeze(path, obj):
# def ensure_i3_configger_sanity():
# def get_i3wm_config_path():
# 
# Path: i3configger/ipc.py
# def configure(cnf=None, deactivate=False):
# def communicate(msg="new config active", refresh=False, urgency="low"):
#     def configure(cls, which):
#     def reload_i3(cls):
#     def restart_i3(cls):
#     def _send_i3_msg(cls, msg):
#     def get_config_error_report(cls, path):
#     def configure(cls, notify):
#     def notify_send(cls, msg, urgency="low"):
#     def configure(cls, command):
#     def send_sigusr1(cls):
# def nop(*args, **kwargs):
# class I3:
# class Notify:
# class I3bar:
#     METHOD_MAP = {"restart": restart_i3, "reload": reload_i3}


from pathlib import Path
from i3configger import build, config, ipc
import pytest



HERE = Path(__file__).parent
EXAMPLES = HERE.parent / "examples"
REFERENCE = HERE / "examples"
FAKE_HEADER = """\
###############################################################################
# Built by i3configger /from/some/directory/who/cares  (some time after 1972) #
###############################################################################
"""
TEST_FOLDER_NAMES = sorted(
    list(
        [
            d.name
            for d in EXAMPLES.iterdir()
            if d.is_dir() and not str(d.name).startswith("_")
        ]
    )
)


@pytest.mark.parametrize("container", TEST_FOLDER_NAMES)
def test_build(container, monkeypatch):
    ipc.configure(deactivate=True)
    monkeypatch.setattr(config, "get_i3wm_config_path", lambda: EXAMPLES / container)
    monkeypatch.setattr(build, "make_header", lambda _: FAKE_HEADER)

# Path: i3configger/build.py
# def build_all():
# def generate_contents(cnf: config.I3configgerConfig, prts, msg):
# def make_header(partialsPath):
# def generate_main_content(partialsPath, selected, ctx):
# def get_bar_setting(barCnf, prts, ctx):
# def generate_i3bar_content(prts, selectValue, ctx):
# def check_config(content):
# def persist_results(pathContentsMap):
# 
# Path: i3configger/config.py
# class MARK:
# class I3configgerConfig:
#     COMMENT = "#"
#     SET = "set"
#     VAR = "$"
# SUFFIX = ".conf"
# I3BAR = "i3bar"
# DEFAULTS = {
#     "main": {
#         "target": "../config",
#         "i3_refresh_msg": "reload",
#         "status_command": "i3status",
#         "log": None,
#         "notify": False,
#     },
#     "bars": {
#         "defaults": {"template": "tpl", "target": "..", "select": "default"},
#         "targets": {},
#     },
# }
# CONFIG_CANDIDATES = [
#     Path("~/.i3").expanduser(),
#     Path(os.getenv("XDG_CONFIG_HOME", "~/.config/")).expanduser() / "i3",
# ]
#     PARTIALS_NAME = "config.d"
#     CONFIG_NAME = "i3configger.json"
#     MESSAGES_NAME = ".messages.json"
#     def __init__(self, load=True):
#     def __str__(self):
#     def load(self):
#     def get_bar_targets(self):
# def fetch(path: Path) -> dict:
# def freeze(path, obj):
# def ensure_i3_configger_sanity():
# def get_i3wm_config_path():
# 
# Path: i3configger/ipc.py
# def configure(cnf=None, deactivate=False):
# def communicate(msg="new config active", refresh=False, urgency="low"):
#     def configure(cls, which):
#     def reload_i3(cls):
#     def restart_i3(cls):
#     def _send_i3_msg(cls, msg):
#     def get_config_error_report(cls, path):
#     def configure(cls, notify):
#     def notify_send(cls, msg, urgency="low"):
#     def configure(cls, command):
#     def send_sigusr1(cls):
# def nop(*args, **kwargs):
# class I3:
# class Notify:
# class I3bar:
#     METHOD_MAP = {"restart": restart_i3, "reload": reload_i3}


# Path: tests/test_build.py
from pathlib import Path
from i3configger import build, config, ipc
import pytest




HERE = Path(__file__).parent
EXAMPLES = HERE.parent / "examples"
REFERENCE = HERE / "examples"
FAKE_HEADER = """\
###############################################################################
# Built by i3configger /from/some/directory/who/cares  (some time after 1972) #
###############################################################################
"""
TEST_FOLDER_NAMES = sorted(
    list(
        [
            d.name
            for d in EXAMPLES.iterdir()
            if d.is_dir() and not str(d.name).startswith("_")
        ]
    )
)


@pytest.mark.parametrize("container", TEST_FOLDER_NAMES)
def test_build(container, monkeypatch):
    ipc.configure(deactivate=True)
    monkeypatch.setattr(config, "get_i3wm_config_path", lambda: EXAMPLES / container)
    monkeypatch.setattr(build, "make_header", lambda _: FAKE_HEADER)

    monkeypatch.setattr(build, "check_config", lambda _: True)