Skip to content

Commit

Permalink
dont expunge subtags
Browse files Browse the repository at this point in the history
  • Loading branch information
yedpodtrzitko committed Sep 8, 2024
1 parent 51f0bb6 commit deeaef7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 0 additions & 2 deletions tagstudio/src/core/library/alchemy/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,6 @@ def tags(self) -> list[Tag]:

for tag in tags_list:
session.expunge(tag)
for subtag in tag.subtags:
session.expunge(subtag)

return list(tags_list)

Expand Down
11 changes: 8 additions & 3 deletions tagstudio/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,19 @@ def library(request):
name="foo",
color=TagColor.RED,
)
assert lib.add_tag(tag)

subtag = Tag(
name="subbar",
color=TagColor.YELLOW,
)

tag2 = Tag(
name="bar",
color=TagColor.BLUE,
subtags={subtag},
)

assert lib.add_tag(tag)

# default item with deterministic name
entry = Entry(
folder=lib.folder,
Expand Down Expand Up @@ -75,7 +80,7 @@ def library(request):
]

assert lib.add_entries([entry, entry2])
assert len(lib.tags) == 4
assert len(lib.tags) == 5

yield lib

Expand Down
4 changes: 2 additions & 2 deletions tagstudio/tests/qt/test_tag_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def test_tag_panel(qtbot, library):

def test_add_tag_callback(qt_driver):
# Given
assert len(qt_driver.lib.tags) == 4
assert len(qt_driver.lib.tags) == 5
qt_driver.add_tag_action_callback()

# When
Expand All @@ -20,5 +20,5 @@ def test_add_tag_callback(qt_driver):

# Then
tags: set[Tag] = qt_driver.lib.tags
assert len(tags) == 5
assert len(tags) == 6
assert "xxx" in {tag.name for tag in tags}
2 changes: 1 addition & 1 deletion tagstudio/tests/test_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_create_tag(library, generate_tag):
assert tag.id == 123

tag_inc = library.add_tag(generate_tag("yyy"))
assert tag_inc.id == 1002
assert tag_inc.id > 1000


def test_library_search(library, generate_tag, entry_full):
Expand Down

0 comments on commit deeaef7

Please sign in to comment.