A night's scan leaves hundreds of files, most worth nothing and a few of them the reason it was left running. Sorting that out meant leaving the browser and going at the directory with mv and rm. Five keys, meant to be pressed once each going down the list: S I N file it into saved/, investigate/ or noise/ u put the last one filed back d delete it and its sidecars, for good -- asks first m lock the frequency out, so no later scan stops on it Each of these acts on the whole capture -- the .wav, the JSON sidecar, the IQ, the transcript and the decoded data -- because a recording in one directory and its transcript in another is a pair nothing will ever put back together. A move that cannot be finished puts back whatever already moved. The cursor stays on the row it was on, which is now the next recording, since a cursor that jumped would make one-key-per-recording impossible. m writes to the lock-out list in the settings file, the same one the scanner's own l key maintains, so a birdie found while reading last night's recordings is gone from tonight's. It says "the next scan": one already running read its settings when it started. The subdirectories sit under the recordings directory, so a scan writing there never looks in them, and saunterbrowse ~/bandsaunter/saved reads one back. Also here, because this is the first part of the browser that writes: - The help screen is back inside eighty by twenty-four. It had grown past the bottom of an ordinary window, which puts "q quit" off the screen. - The footer drops keys in a deliberate order when the window is narrow, rather than ellipsising whichever happened to be at the end. - Moving or deleting what is playing stops the player first. - The pty harness accepted an env and ignored it, so a test aimed at a throwaway settings directory wrote to the real one. It honours it now, and conftest redirects the settings directory for every test besides. 1014 tests. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016PsWPTweCT6pwxKngvVxcg
39 lines
1.5 KiB
Python
39 lines
1.5 KiB
Python
"""Fixtures every test gets.
|
|
|
|
Both of them are about not touching the machine the tests run on.
|
|
|
|
The cache: a lookup writes to ``~/.cache`` by default, and a test run that
|
|
touches the real one leaves entries behind and reads back entries an earlier
|
|
version wrote. Redirecting it per test makes each run start from nothing.
|
|
|
|
The settings: locking a frequency out writes it into ``config.yaml``, and a
|
|
test that reached the real one would silently change what the next real scan
|
|
does. The constant is replaced in every module that holds a copy, so that
|
|
forgetting to pass a directory somewhere cannot end in someone's own settings.
|
|
"""
|
|
import pytest
|
|
|
|
import bandsaunter.browse
|
|
import bandsaunter.cli
|
|
import bandsaunter.config
|
|
import bandsaunter.tui
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def isolated_cache(tmp_path_factory, monkeypatch):
|
|
monkeypatch.setenv("XDG_CACHE_HOME",
|
|
str(tmp_path_factory.mktemp("cache")))
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def isolated_settings(tmp_path_factory, monkeypatch):
|
|
where = tmp_path_factory.mktemp("config")
|
|
for module in (bandsaunter.config, bandsaunter.browse, bandsaunter.cli,
|
|
bandsaunter.tui):
|
|
if hasattr(module, "DEFAULT_CONFIG_DIR"):
|
|
monkeypatch.setattr(module, "DEFAULT_CONFIG_DIR", where)
|
|
if hasattr(module, "DEFAULT_CONFIG_PATH"):
|
|
monkeypatch.setattr(module, "DEFAULT_CONFIG_PATH",
|
|
where / "config.yaml")
|
|
monkeypatch.setenv("BANDSAUNTER_CONFIG_DIR", str(where))
|
|
return where
|