Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/snapjaw.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ def format_dt(dt: datetime | None) -> str:
headers.append("error")

cr.init()
print(tabulate.tabulate(table, tablefmt="psql", headers=headers))
if table:
print(tabulate.tabulate(table, tablefmt="psql", headers=headers))
if not args.verbose:
num_updated = Counter(s.status for s in addon_states)[AddonStatus.UpToDate]
if num_updated > 0:
Expand Down
13 changes: 11 additions & 2 deletions tests/test_snapjaw_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ def test_no_addons_prints_message(self, tmp_path, monkeypatch, capsys):
assert "No addons found" in capsys.readouterr().out

def test_with_addons_shows_table(self, tmp_path, monkeypatch, fixed_now, capsys):
"""Addons are displayed in table format."""
"""Non-verbose mode shows only addons needing attention."""
monkeypatch.setattr(
"snapjaw.get_addon_states",
lambda config, d: [
Expand All @@ -791,7 +791,10 @@ def test_with_addons_shows_table(self, tmp_path, monkeypatch, fixed_now, capsys)
args = SimpleNamespace(addons_dir=str(tmp_path), verbose=False)
cmd_status(config, args)
out = capsys.readouterr().out
assert "+---" in out
assert "| addon" in out
assert "MyAddon" in out
assert "Other" not in out
assert "1 other addon is up to date" in out

def test_verbose_shows_all_addons(self, tmp_path, monkeypatch, fixed_now, capsys):
Expand All @@ -800,13 +803,17 @@ def test_verbose_shows_all_addons(self, tmp_path, monkeypatch, fixed_now, capsys
"snapjaw.get_addon_states",
lambda config, d: [
AddonState("MyAddon", AddonStatus.UpToDate, None, fixed_now, fixed_now),
AddonState("Other", AddonStatus.UpToDate, None, fixed_now, fixed_now),
],
)
config = Config(addons_by_key={})
args = SimpleNamespace(addons_dir=str(tmp_path), verbose=True)
cmd_status(config, args)
out = capsys.readouterr().out
assert "+---" in out
assert "| addon" in out
assert "MyAddon" in out
assert "Other" in out

def test_with_errors_shows_error_column(self, tmp_path, monkeypatch, fixed_now, capsys):
"""Addons with errors show error message."""
Expand All @@ -823,7 +830,7 @@ def test_with_errors_shows_error_column(self, tmp_path, monkeypatch, fixed_now,
assert "connection refused" in out

def test_all_up_to_date_shows_summary(self, tmp_path, monkeypatch, fixed_now, capsys):
"""All up-to-date shows count summary without table rows."""
"""All up-to-date shows count summary without a table."""
monkeypatch.setattr(
"snapjaw.get_addon_states",
lambda config, d: [
Expand All @@ -836,6 +843,8 @@ def test_all_up_to_date_shows_summary(self, tmp_path, monkeypatch, fixed_now, ca
cmd_status(config, args)
out = capsys.readouterr().out
assert "2 addons are up to date" in out
assert "+---" not in out
assert "| addon" not in out

def test_none_dates_handled(self, tmp_path, monkeypatch, capsys):
"""Addons with None dates (untracked) don't crash."""
Expand Down