`ruff format .` across the repo: 153 files, no behaviour change. This is the second gate CONTRIBUTING.md promises, and until now it reported 154 files needing reformat — so a first contributor ran the command the guide told them to run and could not tell their own diff from the background. Landed on its own, with nothing else in it, because a whole-repo reformat is only safe to skip past in blame if it is provably nothing but layout. It was checked that way rather than assumed: every changed file was formatted in memory and compared by full `ast.dump()`, and 152 of 153 come out structurally identical (the one exception was a docstring opening on a quote character, fixed in the commit before this one). The string and comment token streams were diffed separately, so a quote flip or an edited comment could not hide inside a re-layout — five quote-style normalisations and sixteen implicit-concatenation joins, all value-identical, and one commented-out line gaining the space after its `#`. `meshterm specimen` is byte-identical on both platforms, and the suite is 1888 green, gallery gate and `test_theme16` included. What actually changed, in order of how much of the diff it is: wrapped calls and signatures rejoin onto one line where they fit inside the hundred columns; the magic trailing comma expands what it is there to expand; complex slices gain their spaces (`[len(noise) :]`); a few redundant parens go. The tables that are laid out to be read were fenced in the previous commit and are untouched here. The aligned trailing-comment column is gone from about ninety lanes that were not fenced — including the `heat.*` ladder in `MESH_THEME`, which cannot be fenced where it sits. Every comment stays on the entry it describes, so nothing there reads wrong; it just no longer lines up. Add this commit to `.git-blame-ignore-revs`, which follows immediately. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
45 lines
1.8 KiB
Python
45 lines
1.8 KiB
Python
"""Tests for machine-setup loading (where things live, and which device to talk to).
|
|
|
|
MeshTerm's *behaviour* settings are preferences and live in ``tests/test_preferences.py``;
|
|
this file is only what ``config.toml`` still answers for.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from meshterm.core.config import Settings
|
|
|
|
|
|
def test_connect_on_start_defaults_true() -> None:
|
|
"""Eager connect-at-launch is the default when nothing is configured."""
|
|
assert Settings().connect_on_start is True
|
|
|
|
|
|
def test_connect_on_start_loads_from_toml(tmp_path: Path) -> None:
|
|
"""Whether the session opens the radio link at launch round-trips from the config file."""
|
|
config = tmp_path / "config.toml"
|
|
config.write_text("connect_on_start = false\n", encoding="utf-8")
|
|
assert Settings.load(config).connect_on_start is False
|
|
|
|
|
|
def test_tcp_profile_inferred_and_loaded(tmp_path: Path) -> None:
|
|
"""A profile with a ``host`` loads as a TCP profile and exposes its host:port endpoint."""
|
|
config = tmp_path / "config.toml"
|
|
config.write_text(
|
|
'[profiles.wifi]\nhost = "192.168.1.50"\ntcp_port = 6000\n',
|
|
encoding="utf-8",
|
|
)
|
|
profile = Settings.load(config).profiles["wifi"]
|
|
assert profile.is_tcp and profile.transport == "tcp"
|
|
assert profile.host == "192.168.1.50" and profile.tcp_port == 6000
|
|
assert profile.tcp_endpoint == "192.168.1.50:6000"
|
|
|
|
|
|
def test_tcp_profile_defaults_port(tmp_path: Path) -> None:
|
|
"""A TCP profile naming only a host takes the default port in its endpoint."""
|
|
config = tmp_path / "config.toml"
|
|
config.write_text('[profiles.wifi]\nhost = "meshcore.local"\n', encoding="utf-8")
|
|
profile = Settings.load(config).profiles["wifi"]
|
|
assert profile.is_tcp and profile.tcp_endpoint == "meshcore.local:5000"
|