Skip to content

Commit 381e7a2

Browse files
committed
Workspace(fix[importers]): Assert importer warnings on schema fields
why: The socket-override warning carried no structured fields and the import tests matched message substrings against the logging standards; the override message also used present tense for an event. what: - Add tmux_session extra to the socket-override warning and change "overrides" to "overrode" - Assert the override and dropped-pane-key warnings via record extras and args instead of message text
1 parent fce6cdd commit 381e7a2

3 files changed

Lines changed: 26 additions & 5 deletions

File tree

src/tmuxp/workspace/importers.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,15 @@ def import_tmuxinator(
268268
and tmuxp_workspace[socket_key] != explicit_value
269269
):
270270
logger.warning(
271-
"explicit %s %s overrides tmux option value %s",
271+
"explicit %s %s overrode tmux option value %s",
272272
socket_key,
273273
explicit_value,
274274
tmuxp_workspace[socket_key],
275+
extra={
276+
"tmux_session": str(
277+
tmuxp_workspace.get("session_name") or "",
278+
),
279+
},
275280
)
276281
tmuxp_workspace[socket_key] = explicit_value
277282

tests/workspace/test_import_teamocil.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,5 +240,15 @@ def test_import_teamocil_warns_and_drops_pane_dimensions(
240240
result = importers.import_teamocil(workspace)
241241

242242
assert result["windows"][0]["panes"] == [{"shell_command": "vim"}]
243-
assert any("width" in record.message for record in caplog.records)
244-
assert any("height" in record.message for record in caplog.records)
243+
dropped = [
244+
record
245+
for record in caplog.records
246+
if record.levelno == logging.WARNING and hasattr(record, "tmux_window")
247+
]
248+
dropped_keys = sorted(
249+
str(record.args[0])
250+
for record in dropped
251+
if isinstance(record.args, tuple) and record.args
252+
)
253+
assert dropped_keys == ["height", "width"]
254+
assert all(record.tmux_window == "main" for record in dropped)

tests/workspace/test_import_tmuxinator.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,14 @@ def test_import_tmuxinator_socket_name_conflict_warns(
274274
result = importers.import_tmuxinator(workspace)
275275

276276
assert result["socket_name"] == "explicit"
277-
assert any("explicit" in record.message for record in caplog.records)
278-
assert any("from_cli" in record.message for record in caplog.records)
277+
conflict_warnings = [
278+
record
279+
for record in caplog.records
280+
if record.levelno == logging.WARNING and hasattr(record, "tmux_session")
281+
]
282+
assert len(conflict_warnings) == 1
283+
assert conflict_warnings[0].tmux_session == "conflict"
284+
assert conflict_warnings[0].args == ("socket_name", "explicit", "from_cli")
279285

280286

281287
def test_import_tmuxinator_attached_tmux_flags() -> None:

0 commit comments

Comments
 (0)