diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-02 12:16:38 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-02 12:16:38 -0500 |
| commit | b10cba594db836c0747066addad48bda4d30cd02 (patch) | |
| tree | 063119a623fa3f7139feda4ef302896d8f5f934c /tests/waybar-touchpad | |
| parent | 49c2ba9c4510bf6e1acd306687473bc8ba9ad8dd (diff) | |
| download | archsetup-b10cba594db836c0747066addad48bda4d30cd02.tar.gz archsetup-b10cba594db836c0747066addad48bda4d30cd02.zip | |
refactor: drop in-repo dotfiles/, move stow tooling to the dotfiles repo
Since the installer clones DOTFILES_REPO into ~/.dotfiles and stows from there, the in-repo dotfiles/ tree was dead weight. Nothing reads it at install time. I removed it (831 files) now that both machines are migrated.
The Makefile's stow / restow / reset / unstow / import targets and the dotfile-script unit suites moved to the dotfiles repo. They sit alongside the scripts they manage and run standalone (cd ~/.dotfiles && make ...). This Makefile keeps the VM-integration targets and the installer-helper suite (safe-rm-rf).
I updated CLAUDE.md and README.md so stow operations run from ~/.dotfiles, and the dotfile-management, theme, and unit-test sections point at the standalone repo. The README was already describing the old in-repo model from before the installer switched to cloning. This brings it in line.
Diffstat (limited to 'tests/waybar-touchpad')
| -rw-r--r-- | tests/waybar-touchpad/test_waybar_touchpad.py | 104 |
1 files changed, 0 insertions, 104 deletions
diff --git a/tests/waybar-touchpad/test_waybar_touchpad.py b/tests/waybar-touchpad/test_waybar_touchpad.py deleted file mode 100644 index 3133bb4..0000000 --- a/tests/waybar-touchpad/test_waybar_touchpad.py +++ /dev/null @@ -1,104 +0,0 @@ -"""Tests for dotfiles/hyprland/.local/bin/waybar-touchpad. - -The script emits one JSON line for waybar's custom/touchpad module, derived -from the touchpad state file that toggle-touchpad / touchpad-auto maintain -at $XDG_RUNTIME_DIR/touchpad-state. Tests point XDG_RUNTIME_DIR at a temp -dir and assert on the emitted JSON for each state — enabled, disabled, and -the missing-file default. No mocking: the real script runs against a real -state file. - -Run from repo root: - python3 -m unittest tests.waybar-touchpad.test_waybar_touchpad -""" - -import json -import os -import shutil -import subprocess -import tempfile -import unittest - - -REPO_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")) -SCRIPT = os.path.join(REPO_ROOT, "dotfiles/hyprland/.local/bin/waybar-touchpad") - - -class WaybarTouchpadHarness(unittest.TestCase): - - def setUp(self): - self.tmp = tempfile.mkdtemp(prefix="waybar-touchpad-test-") - self.state_file = os.path.join(self.tmp, "touchpad-state") - - def tearDown(self): - shutil.rmtree(self.tmp, ignore_errors=True) - - def set_state(self, value): - with open(self.state_file, "w") as f: - f.write(value) - - def run_script(self): - env = os.environ.copy() - env["XDG_RUNTIME_DIR"] = self.tmp - return subprocess.run( - [SCRIPT], env=env, capture_output=True, text=True, timeout=10, - ) - - def emitted_json(self): - result = self.run_script() - self.assertEqual(result.returncode, 0, msg=result.stderr) - return json.loads(result.stdout) - - -# ----------------------------------------------------------------------------- -# Normal cases -# ----------------------------------------------------------------------------- - -class TestWaybarTouchpadNormal(WaybarTouchpadHarness): - - def test_enabled_state_emits_enabled_class_and_mouse_icon(self): - self.set_state("enabled") - data = self.emitted_json() - self.assertEqual(data["class"], "enabled") - self.assertIn("\U000f037d", data["text"]) # mouse - self.assertIn("enabled", data["tooltip"].lower()) - - def test_disabled_state_emits_disabled_class_and_mouse_off_icon(self): - self.set_state("disabled") - data = self.emitted_json() - self.assertEqual(data["class"], "disabled") - self.assertIn("\U000f037e", data["text"]) # mouse-off - self.assertIn("disabled", data["tooltip"].lower()) - - -# ----------------------------------------------------------------------------- -# Boundary cases -# ----------------------------------------------------------------------------- - -class TestWaybarTouchpadBoundary(WaybarTouchpadHarness): - - def test_missing_state_file_defaults_to_enabled(self): - # No state file written → script should treat the touchpad as enabled. - data = self.emitted_json() - self.assertEqual(data["class"], "enabled") - - def test_state_with_trailing_newline_is_handled(self): - self.set_state("disabled\n") - data = self.emitted_json() - self.assertEqual(data["class"], "disabled") - - def test_unknown_state_value_treated_as_enabled(self): - # Anything that isn't "disabled" reads as enabled (fail-safe: the - # pointer is usable rather than hidden). - self.set_state("garbage") - data = self.emitted_json() - self.assertEqual(data["class"], "enabled") - - def test_output_is_a_single_json_object(self): - self.set_state("enabled") - result = self.run_script() - lines = [ln for ln in result.stdout.splitlines() if ln.strip()] - self.assertEqual(len(lines), 1, msg=f"expected one line, got {lines!r}") - - -if __name__ == "__main__": - unittest.main() |
