Add version info. Add linter
This commit is contained in:
parent
c191d9f35c
commit
d338033333
7 changed files with 67 additions and 0 deletions
25
.forgejo/workflows/lint.yml
Normal file
25
.forgejo/workflows/lint.yml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
name: Lint
|
||||
|
||||
on:
|
||||
push:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: docker
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install system dependencies
|
||||
run: |
|
||||
apt-get update
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
||||
black pyflakes3
|
||||
|
||||
- name: Run linters
|
||||
run: |
|
||||
black bouquin/*
|
||||
black tests/*
|
||||
pyflakes3 bouquin/*
|
||||
pyflakes3 tests/*
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
* Fix a few small matters identified with tests
|
||||
* Make locales dynamically detected from the locales dir rather than hardcoded
|
||||
* Add version information in the navigation
|
||||
|
||||
# 0.2.1.8
|
||||
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@
|
|||
"documentation": "Documentation",
|
||||
"couldnt_open": "Couldn't open",
|
||||
"report_a_bug": "Report a bug",
|
||||
"version": "Version",
|
||||
"navigate": "Navigate",
|
||||
"current": "current",
|
||||
"selected": "selected",
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@
|
|||
"documentation": "Documentation",
|
||||
"couldnt_open": "Impossible d’ouvrir",
|
||||
"report_a_bug": "Signaler un bug",
|
||||
"version": "Version",
|
||||
"navigate": "Naviguer",
|
||||
"current": "actuel",
|
||||
"selected": "sélectionné",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import datetime
|
||||
import importlib.metadata
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
|
|
@ -263,6 +264,12 @@ class MainWindow(QMainWindow):
|
|||
act_bugs.triggered.connect(self._open_bugs)
|
||||
help_menu.addAction(act_bugs)
|
||||
self.addAction(act_bugs)
|
||||
act_version = QAction(strings._("version"), self)
|
||||
act_version.setShortcut("Ctrl+V")
|
||||
act_version.setShortcutContext(Qt.ApplicationShortcut)
|
||||
act_version.triggered.connect(self._open_version)
|
||||
help_menu.addAction(act_version)
|
||||
self.addAction(act_version)
|
||||
|
||||
# Autosave
|
||||
self._dirty = False
|
||||
|
|
@ -1177,6 +1184,11 @@ class MainWindow(QMainWindow):
|
|||
strings._("couldnt_open") + url.toDisplayString(),
|
||||
)
|
||||
|
||||
def _open_version(self):
|
||||
version = importlib.metadata.version("bouquin")
|
||||
version_formatted = f"{APP_NAME} {version}"
|
||||
QMessageBox.information(self, strings._("version"), version_formatted)
|
||||
|
||||
# ----------------- Idle handlers ----------------- #
|
||||
def _apply_idle_minutes(self, minutes: int):
|
||||
minutes = max(0, int(minutes))
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ _DEFAULT = "en"
|
|||
strings = {}
|
||||
translations = {}
|
||||
|
||||
|
||||
def load_strings(current_locale: str) -> None:
|
||||
global strings, translations
|
||||
translations = {}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
import pytest
|
||||
import importlib.metadata
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import bouquin.main_window as mwmod
|
||||
|
|
@ -906,9 +908,33 @@ def test_open_docs_and_bugs_show_warning_on_failure(
|
|||
)
|
||||
w._open_docs()
|
||||
w._open_bugs()
|
||||
|
||||
assert seen["docs"] and seen["bugs"]
|
||||
|
||||
|
||||
def test_open_version(qtbot, tmp_db_cfg, app, monkeypatch):
|
||||
w = _make_main_window(tmp_db_cfg, app, monkeypatch)
|
||||
qtbot.addWidget(w)
|
||||
|
||||
called = {"title": None, "text": None}
|
||||
|
||||
def fake_information(parent, title, text, *a, **k):
|
||||
called["title"] = title
|
||||
called["text"] = text
|
||||
# Return value of QMessageBox.information is an int; 0 is fine.
|
||||
return 0
|
||||
|
||||
# Patch whichever one you actually use in _open_version
|
||||
monkeypatch.setattr(QMessageBox, "information", fake_information)
|
||||
|
||||
w._open_version()
|
||||
|
||||
assert called["title"] is not None
|
||||
assert "version" in called["title"].lower()
|
||||
version = importlib.metadata.version("bouquin")
|
||||
assert version in called["text"]
|
||||
|
||||
|
||||
# ---- Idle/lock/event filter helpers (1176, 1181-1187, 1193-1202, 1231-1233) ----
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue