Skip to content

Commit deeaef7

Browse files
committed
dont expunge subtags
1 parent 51f0bb6 commit deeaef7

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

tagstudio/src/core/library/alchemy/library.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,6 @@ def tags(self) -> list[Tag]:
273273

274274
for tag in tags_list:
275275
session.expunge(tag)
276-
for subtag in tag.subtags:
277-
session.expunge(subtag)
278276

279277
return list(tags_list)
280278

tagstudio/tests/conftest.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,19 @@ def library(request):
3939
name="foo",
4040
color=TagColor.RED,
4141
)
42+
assert lib.add_tag(tag)
43+
44+
subtag = Tag(
45+
name="subbar",
46+
color=TagColor.YELLOW,
47+
)
4248

4349
tag2 = Tag(
4450
name="bar",
4551
color=TagColor.BLUE,
52+
subtags={subtag},
4653
)
4754

48-
assert lib.add_tag(tag)
49-
5055
# default item with deterministic name
5156
entry = Entry(
5257
folder=lib.folder,
@@ -75,7 +80,7 @@ def library(request):
7580
]
7681

7782
assert lib.add_entries([entry, entry2])
78-
assert len(lib.tags) == 4
83+
assert len(lib.tags) == 5
7984

8085
yield lib
8186

tagstudio/tests/qt/test_tag_panel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def test_tag_panel(qtbot, library):
1010

1111
def test_add_tag_callback(qt_driver):
1212
# Given
13-
assert len(qt_driver.lib.tags) == 4
13+
assert len(qt_driver.lib.tags) == 5
1414
qt_driver.add_tag_action_callback()
1515

1616
# When
@@ -20,5 +20,5 @@ def test_add_tag_callback(qt_driver):
2020

2121
# Then
2222
tags: set[Tag] = qt_driver.lib.tags
23-
assert len(tags) == 5
23+
assert len(tags) == 6
2424
assert "xxx" in {tag.name for tag in tags}

tagstudio/tests/test_library.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test_create_tag(library, generate_tag):
4646
assert tag.id == 123
4747

4848
tag_inc = library.add_tag(generate_tag("yyy"))
49-
assert tag_inc.id == 1002
49+
assert tag_inc.id > 1000
5050

5151

5252
def test_library_search(library, generate_tag, entry_full):

0 commit comments

Comments
 (0)