Add a test for update_tag integrity guard
All checks were successful
CI / test (push) Successful in 3m18s
Lint / test (push) Successful in 15s
Trivy / test (push) Successful in 23s

This commit is contained in:
Miguel Jacq 2025-11-14 17:57:23 +11:00
parent 1becb7900e
commit b1ae56270a
Signed by: mig5
GPG key ID: 59B3F0C24135C6A9

View file

@ -1,10 +1,13 @@
import pytest
from PySide6.QtCore import Qt, QPoint, QEvent
from PySide6.QtGui import QMouseEvent
from PySide6.QtWidgets import QApplication, QMessageBox, QInputDialog, QColorDialog
from bouquin.db import DBManager
from bouquin.strings import load_strings
from bouquin.tags_widget import PageTagsWidget, TagChip
from bouquin.tag_browser import TagBrowserDialog
from bouquin.flow_layout import FlowLayout
from sqlcipher3.dbapi2 import IntegrityError
# ============================================================================
@ -154,6 +157,20 @@ def test_update_tag_name_and_color(fresh_db):
assert updated_tags[0][2] == "#FF0000"
def test_update_tag_existing_name_fails(fresh_db):
"""Test updating a tag's name to an existing tag fails"""
load_strings("en")
date_iso = "2024-01-15"
fresh_db.set_tags_for_page(date_iso, ["tag1", "tag2"])
tags = fresh_db.list_tags()
tag_id = tags[0][0]
with pytest.raises(IntegrityError) as excinfo:
fresh_db.update_tag(tag_id, "tag2", "#111111")
assert str(excinfo.value) == "A tag already exists with that name"
def test_delete_tag(fresh_db):
"""Test deleting a tag removes it globally"""
fresh_db.set_tags_for_page("2024-01-15", ["tag1", "tag2"])