# 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/watch.py
# _MASK = (
#     flags.CREATE
#     | flags.ATTRIB
#     | flags.DELETE
#     | flags.MODIFY
#     | flags.CLOSE_WRITE
#     | flags.MOVED_FROM
#     | flags.MOVED_TO
#     | flags.DELETE_SELF
#     | flags.MOVE_SELF
# )
# def watch_guarded():
# def watch_unguarded():
# def get_i3configger_process():
# def daemonized(verbosity, logPath):
# def exorcise():
# 
# 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():


import shutil
import subprocess
import pytest
from contextlib import suppress
from i3configger import exc, watch, config
    assert ret == 0
    assert not err
    assert "usage:" in out


def test_daemon(runner):
    ret, out, err = runner(["--daemon"])
    assert ret == 0
    assert not err
    assert not out
    assert watch.get_i3configger_process()
    watch.exorcise()
    assert not watch.get_i3configger_process()


def test_kill_with_running_i3configger_works(runner):
    runner(["--daemon"])
    assert watch.get_i3configger_process()
    ret, out, err = runner(["--kill"])
    assert ret == 0
    assert not err
    assert not out
    assert not watch.get_i3configger_process()


def test_kill_without_running_i3configger_gives_good_error(runner):
    ret, out, err = runner(["--kill"])
    assert ret == 1
    assert "no daemon running - nothing to kill" in err
    assert not out

# 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/watch.py
# _MASK = (
#     flags.CREATE
#     | flags.ATTRIB
#     | flags.DELETE
#     | flags.MODIFY
#     | flags.CLOSE_WRITE
#     | flags.MOVED_FROM
#     | flags.MOVED_TO
#     | flags.DELETE_SELF
#     | flags.MOVE_SELF
# )
# def watch_guarded():
# def watch_unguarded():
# def get_i3configger_process():
# def daemonized(verbosity, logPath):
# def exorcise():
# 
# 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: tests/test_cli.py
import shutil
import subprocess
import pytest
from contextlib import suppress
from i3configger import exc, watch, config

    assert ret == 0
    assert not err
    assert "usage:" in out


def test_daemon(runner):
    ret, out, err = runner(["--daemon"])
    assert ret == 0
    assert not err
    assert not out
    assert watch.get_i3configger_process()
    watch.exorcise()
    assert not watch.get_i3configger_process()


def test_kill_with_running_i3configger_works(runner):
    runner(["--daemon"])
    assert watch.get_i3configger_process()
    ret, out, err = runner(["--kill"])
    assert ret == 0
    assert not err
    assert not out
    assert not watch.get_i3configger_process()


def test_kill_without_running_i3configger_gives_good_error(runner):
    ret, out, err = runner(["--kill"])
    assert ret == 1
    assert "no daemon running - nothing to kill" in err
    assert not out

    assert not watch.get_i3configger_process()