Prevent traceback on trying to edit a tag with the same name as another tag. Various other tweaks. Bump version
All checks were successful
CI / test (push) Successful in 3m31s
Lint / test (push) Successful in 16s
Trivy / test (push) Successful in 21s

This commit is contained in:
Miguel Jacq 2025-11-14 17:30:58 +11:00
parent 02a60ca656
commit 1becb7900e
Signed by: mig5
GPG key ID: 59B3F0C24135C6A9
15 changed files with 153 additions and 83 deletions

View file

@ -435,7 +435,7 @@ def test_init_exits_when_prompt_rejected(app, monkeypatch, tmp_path):
# Avoid accidentaly creating DB by short-circuiting the prompt loop
class MW(MainWindow):
def _prompt_for_key_until_valid(self, first_time: bool) -> bool: # noqa: N802
assert first_time is True # hit line 73 path
assert first_time is True
return False
with pytest.raises(SystemExit):
@ -938,7 +938,7 @@ def test_apply_idle_minutes_paths_and_unlock(qtbot, tmp_db_cfg, app, monkeypatch
# remove timer to hit early return
delattr(w, "_idle_timer")
w._apply_idle_minutes(5) # no crash => line 1176 branch
w._apply_idle_minutes(5) # no crash
# re-create a timer and simulate locking then disabling idle
w._idle_timer = QTimer(w)
@ -1474,7 +1474,7 @@ def test_closeEvent_swallows_exceptions(qtbot, app, tmp_db_cfg, monkeypatch):
# ============================================================================
# Tag Save Handler Tests (lines 1050-1068)
# Tag Save Handler Tests
# ============================================================================
@ -1525,7 +1525,7 @@ def test_main_window_do_tag_save_no_editor(app, fresh_db, tmp_db_cfg, monkeypatc
def test_main_window_on_tag_added_triggers_deferred_save(
app, fresh_db, tmp_db_cfg, monkeypatch
):
"""Test that _on_tag_added defers the save (lines 1043-1048)"""
"""Test that _on_tag_added defers the save"""
monkeypatch.setattr(
"bouquin.main_window.KeyPrompt",
lambda *args, **kwargs: Mock(exec=lambda: True, key=lambda: tmp_db_cfg.key),
@ -1546,7 +1546,7 @@ def test_main_window_on_tag_added_triggers_deferred_save(
# ============================================================================
# Tag Activation Tests (lines 1070-1080)
# Tag Activation Tests
# ============================================================================
@ -1600,7 +1600,7 @@ def test_main_window_on_tag_activated_with_tag_name(
# ============================================================================
# Settings Path Change Tests (lines 1105-1116)
# Settings Path Change Tests
# ============================================================================
@ -1651,7 +1651,7 @@ def test_main_window_settings_path_change_success(
def test_main_window_settings_path_change_failure(
app, fresh_db, tmp_db_cfg, tmp_path, monkeypatch
):
"""Test failed database path change shows warning (lines 1108-1113)"""
"""Test failed database path change shows warning"""
monkeypatch.setattr(
"bouquin.main_window.KeyPrompt",
lambda *args, **kwargs: Mock(exec=lambda: True, key=lambda: tmp_db_cfg.key),
@ -1691,7 +1691,7 @@ def test_main_window_settings_path_change_failure(
def test_main_window_settings_no_path_change(app, fresh_db, tmp_db_cfg, monkeypatch):
"""Test settings change without path change (lines 1105 condition False)"""
"""Test settings change without path change"""
monkeypatch.setattr(
"bouquin.main_window.KeyPrompt",
lambda *args, **kwargs: Mock(exec=lambda: True, key=lambda: tmp_db_cfg.key),
@ -1729,7 +1729,7 @@ def test_main_window_settings_no_path_change(app, fresh_db, tmp_db_cfg, monkeypa
def test_main_window_settings_cancelled(app, fresh_db, tmp_db_cfg, monkeypatch):
"""Test cancelling settings dialog (line 1085-1086)"""
"""Test cancelling settings dialog"""
monkeypatch.setattr(
"bouquin.main_window.KeyPrompt",
lambda *args, **kwargs: Mock(exec=lambda: True, key=lambda: tmp_db_cfg.key),
@ -1753,7 +1753,7 @@ def test_main_window_settings_cancelled(app, fresh_db, tmp_db_cfg, monkeypatch):
# ============================================================================
# Update Tag Views Tests (lines 1039-1041)
# Update Tag Views Tests
# ============================================================================

View file

@ -374,7 +374,7 @@ def test_theme_change_rehighlight(highlighter):
@pytest.fixture
def hl_light(app):
# Light theme path (covers lines ~74-75 in _on_theme_changed)
# Light theme path
tm = ThemeManager(app, ThemeConfig(theme=Theme.LIGHT))
doc = QTextDocument()
hl = MarkdownHighlighter(doc, tm)
@ -435,7 +435,7 @@ def test_code_block_light_colors(hl_light):
def test_end_guard_skips_italic_followed_by_marker(hl_light):
"""
Triggers the end-following guard for italic (line ~208), e.g. '*i**'.
Triggers the end-following guard for italic e.g. '*i**'.
"""
doc, hl = hl_light
doc.setPlainText("*i**")
@ -543,7 +543,7 @@ def test_insert_image_from_path_invalid_returns(editor_hello, tmp_path):
# ============================================================================
# setDocument Tests (lines 75-81)
# setDocument Tests
# ============================================================================
@ -582,7 +582,7 @@ def test_markdown_editor_set_document_with_highlighter(app):
# ============================================================================
# showEvent Tests (lines 83-86)
# showEvent Tests
# ============================================================================
@ -604,7 +604,7 @@ def test_markdown_editor_show_event(app, qtbot):
# ============================================================================
# Checkbox Transformation Tests (lines 100-133)
# Checkbox Transformation Tests
# ============================================================================
@ -645,7 +645,7 @@ def test_markdown_editor_transform_checked_checkbox(app, qtbot):
def test_markdown_editor_transform_todo(app, qtbot):
"""Test transforming TODO to unchecked checkbox (lines 110-114)"""
"""Test transforming TODO to unchecked checkbox"""
themes = ThemeManager(app, ThemeConfig(theme=Theme.LIGHT))
editor = MarkdownEditor(themes)
editor.show()
@ -726,7 +726,7 @@ def test_markdown_editor_no_transform_when_updating(app):
editor.insertPlainText("- [ ] Task")
# Should NOT transform since _updating is True
# This tests the early return in _on_text_changed (lines 90-91)
# This tests the early return in _on_text_changed
assert editor._updating
@ -779,7 +779,7 @@ def test_markdown_editor_update_code_block_backgrounds(app):
# ============================================================================
# Image Insertion Tests (lines 336-366)
# Image Insertion Tests
# ============================================================================
@ -811,7 +811,7 @@ def test_markdown_editor_insert_image_from_path(app, tmp_path):
# ============================================================================
# Formatting Tests (missing lines in various formatting methods)
# Formatting Tests
# ============================================================================
@ -886,7 +886,7 @@ def test_markdown_editor_toggle_code_empty_selection(app):
# ============================================================================
# Heading Tests (lines 455-459)
# Heading Tests
# ============================================================================
@ -932,7 +932,7 @@ def test_markdown_editor_set_heading_zero_removes_heading(app):
# ============================================================================
# List Tests (lines 483-519)
# List Tests
# ============================================================================
@ -972,7 +972,7 @@ def test_markdown_editor_toggle_list_ordered(app):
# ============================================================================
# Code Block Tests (lines 540-577)
# Code Block Tests
# ============================================================================
@ -1016,7 +1016,7 @@ def test_markdown_editor_apply_code_remove(app):
# ============================================================================
# Checkbox Tests (lines 596-600)
# Checkbox Tests
# ============================================================================
@ -1032,7 +1032,7 @@ def test_markdown_editor_insert_checkbox_unchecked(app):
# ============================================================================
# Toggle Checkboxes Tests (lines 659-660, 686-691)
# Toggle Checkboxes Tests
# ============================================================================
@ -1071,7 +1071,7 @@ def test_markdown_editor_toggle_checkboxes_mixed(app):
# ============================================================================
# Markdown Conversion Tests (lines 703, 710-714, 731)
# Markdown Conversion Tests
# ============================================================================
@ -1113,7 +1113,7 @@ def test_markdown_editor_from_markdown_with_links(app):
# ============================================================================
# Selection and Cursor Tests (lines 747-752)
# Selection and Cursor Tests
# ============================================================================
@ -1152,7 +1152,7 @@ def test_markdown_editor_get_selected_blocks(app):
# ============================================================================
# Key Event Tests (lines 795, 806-809)
# Key Event Tests
# ============================================================================
@ -1194,7 +1194,7 @@ def test_markdown_editor_key_press_return_in_list(app):
# ============================================================================
# Link Handling Tests (lines 898, 922, 949, 990)
# Link Handling Tests
# ============================================================================
@ -1229,12 +1229,12 @@ def test_markdown_editor_mouse_move_over_link(app):
# ============================================================================
# Theme Mode Tests (lines 72-79)
# Theme Mode Tests
# ============================================================================
def test_markdown_highlighter_light_mode(app):
"""Test highlighter in light mode (lines 74-77)"""
"""Test highlighter in light mode"""
doc = QTextDocument()
themes = ThemeManager(app, ThemeConfig(theme=Theme.LIGHT))
highlighter = MarkdownHighlighter(doc, themes)
@ -1252,7 +1252,7 @@ def test_markdown_highlighter_light_mode(app):
def test_markdown_highlighter_dark_mode(app):
"""Test highlighter in dark mode (lines 70-71)"""
"""Test highlighter in dark mode"""
doc = QTextDocument()
themes = ThemeManager(app, ThemeConfig(theme=Theme.DARK))
highlighter = MarkdownHighlighter(doc, themes)
@ -1266,7 +1266,7 @@ def test_markdown_highlighter_dark_mode(app):
# ============================================================================
# Highlighting Pattern Tests (lines 196, 208, 211, 213)
# Highlighting Pattern Tests
# ============================================================================

View file

@ -786,7 +786,7 @@ def test_tag_page_without_content(fresh_db):
# ============================================================================
# TagChip Mouse Event Tests (tags_widget.py lines 70-73)
# TagChip Mouse Event Tests
# ============================================================================
@ -844,12 +844,12 @@ def test_tag_chip_right_click_no_signal(app, qtbot):
# ============================================================================
# PageTagsWidget Edge Cases (tags_widget.py missing lines)
# PageTagsWidget Edge Cases
# ============================================================================
def test_page_tags_widget_add_tag_with_completer_popup_visible(app, fresh_db):
"""Test adding tag when completer popup is visible (line 148)"""
"""Test adding tag when completer popup is visible"""
widget = PageTagsWidget(fresh_db)
widget.show()
date_iso = "2024-01-15"
@ -906,12 +906,12 @@ def test_page_tags_widget_no_current_date_remove_tag(app, fresh_db):
# ============================================================================
# TagBrowserDialog Interactive Tests (tag_browser.py lines 124-126, 139-205)
# TagBrowserDialog Interactive Tests
# ============================================================================
def test_tag_browser_button_states_with_page_item(app, fresh_db):
"""Test that buttons are disabled when clicking a page item (lines 124-126)"""
"""Test that buttons are disabled when clicking a page item"""
fresh_db.save_new_version("2024-01-15", "Content", "note")
fresh_db.set_tags_for_page("2024-01-15", ["test"])
@ -936,7 +936,7 @@ def test_tag_browser_button_states_with_page_item(app, fresh_db):
def test_tag_browser_edit_tag_name_no_item(app, fresh_db):
"""Test editing tag name when no item is selected (lines 139-141)"""
"""Test editing tag name when no item is selected"""
dialog = TagBrowserDialog(fresh_db)
# Try to edit without selecting anything
@ -947,7 +947,7 @@ def test_tag_browser_edit_tag_name_no_item(app, fresh_db):
def test_tag_browser_edit_tag_name_page_item(app, fresh_db):
"""Test editing tag name when a page item is selected (lines 143-145)"""
"""Test editing tag name when a page item is selected"""
fresh_db.save_new_version("2024-01-15", "Content", "note")
fresh_db.set_tags_for_page("2024-01-15", ["test"])
@ -969,7 +969,7 @@ def test_tag_browser_edit_tag_name_page_item(app, fresh_db):
def test_tag_browser_change_color_no_item(app, fresh_db):
"""Test changing color when no item is selected (lines 164-166)"""
"""Test changing color when no item is selected"""
dialog = TagBrowserDialog(fresh_db)
# Try to change color without selecting anything
@ -980,7 +980,7 @@ def test_tag_browser_change_color_no_item(app, fresh_db):
def test_tag_browser_change_color_page_item(app, fresh_db):
"""Test changing color when a page item is selected (lines 168-170)"""
"""Test changing color when a page item is selected"""
fresh_db.save_new_version("2024-01-15", "Content", "note")
fresh_db.set_tags_for_page("2024-01-15", ["test"])
@ -1002,7 +1002,7 @@ def test_tag_browser_change_color_page_item(app, fresh_db):
def test_tag_browser_delete_tag_no_item(app, fresh_db):
"""Test deleting tag when no item is selected (lines 183-185)"""
"""Test deleting tag when no item is selected"""
dialog = TagBrowserDialog(fresh_db)
# Try to delete without selecting anything
@ -1013,7 +1013,7 @@ def test_tag_browser_delete_tag_no_item(app, fresh_db):
def test_tag_browser_delete_tag_page_item(app, fresh_db):
"""Test deleting tag when a page item is selected (lines 187-189)"""
"""Test deleting tag when a page item is selected"""
fresh_db.save_new_version("2024-01-15", "Content", "note")
fresh_db.set_tags_for_page("2024-01-15", ["test"])
@ -1036,12 +1036,12 @@ def test_tag_browser_delete_tag_page_item(app, fresh_db):
# ============================================================================
# FlowLayout Edge Case (flow_layout.py line 28)
# FlowLayout Edge Case
# ============================================================================
def test_flow_layout_take_at_out_of_bounds(app):
"""Test FlowLayout.takeAt with invalid index (line 28)"""
"""Test FlowLayout.takeAt with invalid index"""
layout = FlowLayout()
# Try to take item at index that doesn't exist
@ -1063,7 +1063,7 @@ def test_flow_layout_take_at_negative(app):
# ============================================================================
# DB Edge Case (db.py line 434)
# DB Edge Case for tags
# ============================================================================