refactor: remove unnecessary methods and properties

This commit is contained in:
Travis Abendshien
2026-07-18 17:23:46 -07:00
parent c8ba9b15c2
commit f29f691a79
7 changed files with 38 additions and 48 deletions
+11 -10
View File
@@ -1,6 +1,7 @@
# SPDX-FileCopyrightText: (c) TagStudio Contributors
# SPDX-License-Identifier: GPL-3.0-only
# pyright: reportPrivateUsage=false
from tagstudio.core.library.alchemy.models import Entry, Tag
from tagstudio.core.utils.types import unwrap
@@ -17,7 +18,7 @@ def test_update_selection_empty(qt_driver: QtDriver):
panel.set_selection(qt_driver.selected)
# FieldContainer should hide all containers
for container in panel.field_containers_widget.containers:
for container in panel.containers._containers:
assert container.isHidden()
@@ -29,7 +30,7 @@ def test_update_selection_single(qt_driver: QtDriver, entry_full: Entry):
panel.set_selection(qt_driver.selected)
# FieldContainer should show all applicable tags and field containers
for container in panel.field_containers_widget.containers:
for container in panel.containers._containers:
assert not container.isHidden()
@@ -44,7 +45,7 @@ def test_update_selection_multiple(qt_driver: QtDriver):
panel.set_selection(qt_driver.selected)
# FieldContainer should show mixed field editing
for container in panel.field_containers_widget.containers:
for container in panel.containers._containers:
assert container.isHidden()
@@ -58,7 +59,7 @@ def test_add_tag_to_selection_single(qt_driver: QtDriver, entry_full: Entry):
panel.set_selection(qt_driver.selected)
# Add new tag
panel.field_containers_widget.add_tags_to_selected(2000)
panel.containers.add_tags_to_selected(2000)
# Then reload entry
refreshed_entry: Entry = next(qt_driver.lib.all_entries(with_joins=True))
@@ -75,7 +76,7 @@ def test_add_same_tag_to_selection_single(qt_driver: QtDriver, entry_full: Entry
panel.set_selection(qt_driver.selected)
# Add an existing tag
panel.field_containers_widget.add_tags_to_selected(1000)
panel.containers.add_tags_to_selected(1000)
# Then reload entry
refreshed_entry = next(qt_driver.lib.all_entries(with_joins=True))
@@ -105,7 +106,7 @@ def test_add_tag_to_selection_multiple(qt_driver: QtDriver):
panel.set_selection(qt_driver.selected)
# Add new tag
panel.field_containers_widget.add_tags_to_selected(1000)
panel.containers.add_tags_to_selected(1000)
# Then reload all entries and recheck the presence of tag 1000
refreshed_entries = qt_driver.lib.all_entries(with_joins=True)
@@ -133,8 +134,8 @@ def test_meta_tag_category(qt_driver: QtDriver, entry_full: Entry):
panel.set_selection(qt_driver.selected)
# FieldContainer should hide all containers
assert len(panel.field_containers_widget.containers) == 3
for i, container in enumerate(panel.field_containers_widget.containers):
assert len(panel.containers._containers) == 3
for i, container in enumerate(panel.containers._containers):
match i:
case 0:
# Check if the container is the Meta Tags category
@@ -166,8 +167,8 @@ def test_custom_tag_category(qt_driver: QtDriver, entry_full: Entry):
panel.set_selection(qt_driver.selected)
# FieldContainer should hide all containers
assert len(panel.field_containers_widget.containers) == 3
for i, container in enumerate(panel.field_containers_widget.containers):
assert len(panel.containers._containers) == 3
for i, container in enumerate(panel.containers._containers):
match i:
case 0:
# Check if the container is the Meta Tags category
+2 -2
View File
@@ -74,7 +74,7 @@ def test_file_path_display(
entry = qt_driver.lib.get_entry(2)
assert isinstance(entry, Entry)
filename = entry.path
panel.file_attributes_widget.update_stats(filepath=unwrap(qt_driver.lib.library_dir) / filename)
panel._layout.file_attrs.update_stats(filepath=unwrap(qt_driver.lib.library_dir) / filename)
# Generate the expected file string.
# This is copied directly from the file_attributes.py file
@@ -92,7 +92,7 @@ def test_file_path_display(
file_str += f"<b>{'\u200b'.join(part_)}</b>"
# Assert the file path is displayed correctly
assert panel.file_attributes_widget.file_label.text() == file_str
assert panel._layout.file_attrs.file_label.text() == file_str
@pytest.mark.parametrize(
+10 -3
View File
@@ -1,6 +1,7 @@
# SPDX-FileCopyrightText: (c) TagStudio Contributors
# SPDX-License-Identifier: GPL-3.0-only
# pyright: reportPrivateUsage=false
from tagstudio.core.library.alchemy.models import Entry
from tagstudio.qt.controllers.preview_panel import PreviewPanel
@@ -16,7 +17,11 @@ def test_update_selection_empty(qt_driver: QtDriver):
panel.set_selection(qt_driver.selected)
# Panel should disable UI that allows for entry modification
assert not panel.add_buttons_enabled
assert panel._layout.add_tag_button.isEnabled() == panel._layout.add_field_button.isEnabled()
assert (
not panel._layout.add_tag_button.isEnabled()
and not panel._layout.add_field_button.isEnabled()
)
def test_update_selection_single(qt_driver: QtDriver, entry_full: Entry):
@@ -27,7 +32,8 @@ def test_update_selection_single(qt_driver: QtDriver, entry_full: Entry):
panel.set_selection(qt_driver.selected)
# Panel should enable UI that allows for entry modification
assert panel.add_buttons_enabled
assert panel._layout.add_tag_button.isEnabled() == panel._layout.add_field_button.isEnabled()
assert panel._layout.add_tag_button.isEnabled() and panel._layout.add_field_button.isEnabled()
def test_update_selection_multiple(qt_driver: QtDriver):
@@ -39,4 +45,5 @@ def test_update_selection_multiple(qt_driver: QtDriver):
panel.set_selection(qt_driver.selected)
# Panel should enable UI that allows for entry modification
assert panel.add_buttons_enabled
assert panel._layout.add_tag_button.isEnabled() == panel._layout.add_field_button.isEnabled()
assert panel._layout.add_tag_button.isEnabled() and panel._layout.add_field_button.isEnabled()