Add a test for update_tag integrity guard
This commit is contained in:
parent
1becb7900e
commit
b1ae56270a
1 changed files with 17 additions and 0 deletions
|
|
@ -1,10 +1,13 @@
|
||||||
|
import pytest
|
||||||
from PySide6.QtCore import Qt, QPoint, QEvent
|
from PySide6.QtCore import Qt, QPoint, QEvent
|
||||||
from PySide6.QtGui import QMouseEvent
|
from PySide6.QtGui import QMouseEvent
|
||||||
from PySide6.QtWidgets import QApplication, QMessageBox, QInputDialog, QColorDialog
|
from PySide6.QtWidgets import QApplication, QMessageBox, QInputDialog, QColorDialog
|
||||||
from bouquin.db import DBManager
|
from bouquin.db import DBManager
|
||||||
|
from bouquin.strings import load_strings
|
||||||
from bouquin.tags_widget import PageTagsWidget, TagChip
|
from bouquin.tags_widget import PageTagsWidget, TagChip
|
||||||
from bouquin.tag_browser import TagBrowserDialog
|
from bouquin.tag_browser import TagBrowserDialog
|
||||||
from bouquin.flow_layout import FlowLayout
|
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"
|
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):
|
def test_delete_tag(fresh_db):
|
||||||
"""Test deleting a tag removes it globally"""
|
"""Test deleting a tag removes it globally"""
|
||||||
fresh_db.set_tags_for_page("2024-01-15", ["tag1", "tag2"])
|
fresh_db.set_tags_for_page("2024-01-15", ["tag1", "tag2"])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue