refactor!: organize project layout

This commit is contained in:
Travis Abendshien
2026-08-16 16:03:57 -07:00
parent 12fd4933be
commit fca3a4d206
129 changed files with 520 additions and 497 deletions
+4 -3
View File
@@ -20,8 +20,8 @@ sys.path.insert(0, str(CWD.parent))
from tagstudio.core.constants import THUMB_CACHE_NAME, TS_FOLDER_NAME
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.library.alchemy.models import Entry, Tag
from tagstudio.qt.thumb_grid_layout import ThumbGridLayout
from tagstudio.qt.ts_qt import QtDriver
from tagstudio.qt.qt_driver import QtDriver
from tagstudio.qt.views.layouts.thumb_grid_layout import ThumbGridLayout
@pytest.fixture
@@ -154,7 +154,8 @@ def qt_driver(library: Library, library_dir: Path):
open = library_dir
ci = True
with patch("tagstudio.qt.ts_qt.Consumer"), patch("tagstudio.qt.ts_qt.CustomRunnable"):
# NOTE: What the heck is this
with patch("tagstudio.qt.qt_driver.Consumer"), patch("tagstudio.qt.qt_driver.CustomRunnable"):
driver = QtDriver(Args()) # pyright: ignore[reportArgumentType]
driver.app = Mock()
@@ -4,7 +4,7 @@
from pathlib import Path
from tagstudio.qt.global_settings import GlobalSettings, Theme
from tagstudio.qt.app_settings import AppSettings, Theme
def test_read_settings(library_dir: Path):
@@ -23,7 +23,7 @@ def test_read_settings(library_dir: Path):
zero_padding = true
""")
settings = GlobalSettings.read_settings(settings_path)
settings = AppSettings.read_settings(settings_path)
assert settings.language == "de"
assert settings.open_last_loaded_on_startup
assert settings.autoplay
@@ -34,3 +34,21 @@ def test_read_settings(library_dir: Path):
assert settings.date_format == "%x"
assert settings.hour_format
assert settings.zero_padding
# NOTE: Other tests are affected by the settings made in this test, so as a temporary measure
# this just reverts the language back to English for subsequent tests.
with open(settings_path, "w") as settings_file:
settings_file.write("""
language = "en"
open_last_loaded_on_startup = true
autoplay = true
show_filenames_in_grid = true
page_size = 1337
show_filepath = 0
dark_mode = 2
date_format = "%x"
hour_format = true
zero_padding = true
""")
settings = AppSettings.read_settings(settings_path)
assert settings.language == "en"
+1 -1
View File
@@ -12,9 +12,9 @@ from pytestqt.qtbot import QtBot
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.library.alchemy.models import Tag, TagAlias
from tagstudio.core.utils.types import unwrap
from tagstudio.i18n.translations import Translations
from tagstudio.qt.mixed.build_tag import BuildTagPanel, CustomTableItem
from tagstudio.qt.mixed.tag_widget import TagWidget
from tagstudio.qt.translations import Translations
def test_build_tag_panel_add_sub_tag_callback(
+11 -11
View File
@@ -8,12 +8,12 @@ from tagstudio.core.library.alchemy.library import Library
# pyright: reportPrivateUsage=false
from tagstudio.core.library.alchemy.models import Entry, Tag
from tagstudio.core.utils.types import unwrap
from tagstudio.qt.controllers.preview_panel_controller import PreviewPanel
from tagstudio.qt.ts_qt import QtDriver
from tagstudio.qt.controllers.inspector import Inspector
from tagstudio.qt.qt_driver import QtDriver
def test_update_selection_empty(qt_driver: QtDriver):
panel = PreviewPanel(qt_driver)
panel = Inspector(qt_driver)
# Clear the library selection (selecting 1 then unselecting 1)
qt_driver.toggle_item_selection(1, append=False, bridge=False)
@@ -26,7 +26,7 @@ def test_update_selection_empty(qt_driver: QtDriver):
def test_update_selection_single(qt_driver: QtDriver, entry_full: Entry):
panel = PreviewPanel(qt_driver)
panel = Inspector(qt_driver)
# Select the single entry
qt_driver.toggle_item_selection(entry_full.id, append=False, bridge=False)
@@ -40,7 +40,7 @@ def test_update_selection_single(qt_driver: QtDriver, entry_full: Entry):
def test_update_selection_multiple(qt_driver: QtDriver):
# TODO: Implement mixed field editing. Currently these containers will be hidden,
# same as the empty selection behavior.
panel = PreviewPanel(qt_driver)
panel = Inspector(qt_driver)
# Select the multiple entries
qt_driver.toggle_item_selection(1, append=False, bridge=False)
@@ -53,7 +53,7 @@ def test_update_selection_multiple(qt_driver: QtDriver):
def test_add_tag_to_selection_single(qt_driver: QtDriver, entry_full: Entry):
panel = PreviewPanel(qt_driver)
panel = Inspector(qt_driver)
assert {t.id for t in entry_full.tags} == {1000}
@@ -70,7 +70,7 @@ def test_add_tag_to_selection_single(qt_driver: QtDriver, entry_full: Entry):
def test_add_same_tag_to_selection_single(qt_driver: QtDriver, entry_full: Entry):
panel = PreviewPanel(qt_driver)
panel = Inspector(qt_driver)
assert {t.id for t in entry_full.tags} == {1000}
@@ -87,7 +87,7 @@ def test_add_same_tag_to_selection_single(qt_driver: QtDriver, entry_full: Entry
def test_add_tag_to_selection_multiple(qt_driver: QtDriver):
panel = PreviewPanel(qt_driver)
panel = Inspector(qt_driver)
all_entries = qt_driver.lib.all_entries(with_joins=True)
# We want to verify that tag 1000 is on some, but not all entries already.
@@ -127,7 +127,7 @@ def test_add_tag_to_selection_multiple(qt_driver: QtDriver):
def test_meta_tag_category(qt_driver: QtDriver, entry_full: Entry):
panel = PreviewPanel(qt_driver)
panel = Inspector(qt_driver)
# Ensure the Favorite tag is on entry_full
qt_driver.lib.add_tags_to_entries(1, entry_full.id)
@@ -155,7 +155,7 @@ def test_meta_tag_category(qt_driver: QtDriver, entry_full: Entry):
def test_custom_tag_category(qt_driver: QtDriver, entry_full: Entry):
panel = PreviewPanel(qt_driver)
panel = Inspector(qt_driver)
# Set tag 1000 (foo) as a category
tag: Tag = unwrap(qt_driver.lib.get_tag(1000))
@@ -190,7 +190,7 @@ def test_custom_tag_category(qt_driver: QtDriver, entry_full: Entry):
def test_exclude_tag_category(
qt_driver: QtDriver, library: Library, generate_tag: Callable[..., Tag]
):
panel = PreviewPanel(qt_driver)
panel = Inspector(qt_driver)
category_parent = unwrap(generate_tag("category_parent", id=123, is_category=True))
library.add_tag(category_parent)
+3 -3
View File
@@ -17,9 +17,9 @@ from tagstudio.core.enums import ShowFilepathOption
from tagstudio.core.library.alchemy.library import Library, LibraryStatus
from tagstudio.core.library.alchemy.models import Entry
from tagstudio.core.utils.types import unwrap
from tagstudio.qt.controllers.preview_panel_controller import PreviewPanel
from tagstudio.qt.controllers.inspector import Inspector
from tagstudio.qt.mixed.settings_panel import SettingsPanel
from tagstudio.qt.ts_qt import QtDriver
from tagstudio.qt.qt_driver import QtDriver
# Tests to see if the file path setting is applied correctly
@@ -62,7 +62,7 @@ def test_file_path_display(
filepath_option: ShowFilepathOption,
expected_path: Callable[[Library], Path],
):
panel = PreviewPanel(qt_driver)
panel = Inspector(qt_driver)
# Select 2
qt_driver.toggle_item_selection(2, append=False, bridge=False)
@@ -4,12 +4,12 @@
# pyright: reportPrivateUsage=false
from tagstudio.core.library.alchemy.models import Entry
from tagstudio.qt.controllers.preview_panel_controller import PreviewPanel
from tagstudio.qt.ts_qt import QtDriver
from tagstudio.qt.controllers.inspector import Inspector
from tagstudio.qt.qt_driver import QtDriver
def test_update_selection_empty(qt_driver: QtDriver):
panel = PreviewPanel(qt_driver)
panel = Inspector(qt_driver)
# Clear the library selection (selecting 1 then unselecting 1)
qt_driver.toggle_item_selection(1, append=False, bridge=False)
@@ -25,7 +25,7 @@ def test_update_selection_empty(qt_driver: QtDriver):
def test_update_selection_single(qt_driver: QtDriver, entry_full: Entry):
panel = PreviewPanel(qt_driver)
panel = Inspector(qt_driver)
# Select the single entry
qt_driver.toggle_item_selection(entry_full.id, append=False, bridge=False)
@@ -37,7 +37,7 @@ def test_update_selection_single(qt_driver: QtDriver, entry_full: Entry):
def test_update_selection_multiple(qt_driver: QtDriver):
panel = PreviewPanel(qt_driver)
panel = Inspector(qt_driver)
# Select the multiple entries
qt_driver.toggle_item_selection(1, append=False, bridge=False)
+1 -1
View File
@@ -6,7 +6,7 @@ import pytest
from tagstudio.core.library.alchemy.enums import ItemType
from tagstudio.qt.mixed.item_thumb import BadgeType, ItemThumb
from tagstudio.qt.ts_qt import QtDriver
from tagstudio.qt.qt_driver import QtDriver
@pytest.mark.parametrize("new_value", (True, False))
+1 -1
View File
@@ -4,7 +4,7 @@
from tagstudio.core.library.alchemy.enums import BrowsingState
from tagstudio.core.utils.types import unwrap
from tagstudio.qt.ts_qt import QtDriver
from tagstudio.qt.qt_driver import QtDriver
def test_browsing_state_update(qt_driver: QtDriver):
+1 -1
View File
@@ -7,7 +7,7 @@ from pytestqt.qtbot import QtBot
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.library.alchemy.models import Tag
from tagstudio.qt.mixed.build_tag import BuildTagPanel
from tagstudio.qt.ts_qt import QtDriver
from tagstudio.qt.qt_driver import QtDriver
def test_tag_panel(qtbot: QtBot, library: Library):
+1 -1
View File
@@ -6,7 +6,7 @@ from PySide6.QtCore import SIGNAL
from pytestqt.qtbot import QtBot
from tagstudio.core.library.alchemy.library import Library
from tagstudio.qt.controllers.tag_search_panel_controller import TagSearchPanel
from tagstudio.qt.controllers.tag_search_panel import TagSearchPanel
from tagstudio.qt.mixed.tag_widget import TagWidget
from tagstudio.qt.views.search_panel_view import SearchPanelView
+1 -1
View File
@@ -9,7 +9,7 @@ from unittest.mock import Mock
import pytest
from PySide6.QtCore import Qt
from tagstudio.qt.global_settings import Theme
from tagstudio.qt.app_settings import Theme
@pytest.mark.parametrize(
+6 -6
View File
@@ -9,18 +9,18 @@ from PySide6.QtCore import QSettings
from tagstudio.core.driver import DriverMixin
from tagstudio.core.enums import AppCacheItems
from tagstudio.core.library.alchemy.library import LibraryStatus
from tagstudio.qt.global_settings import GlobalSettings
from tagstudio.qt.app_settings import AppSettings
class TestDriver(DriverMixin):
def __init__(self, settings: GlobalSettings, cache: QSettings):
def __init__(self, settings: AppSettings, cache: QSettings):
self.settings = settings
self.cached_values = cache
def test_evaluate_path_empty():
# Given
driver = TestDriver(GlobalSettings(), QSettings())
driver = TestDriver(AppSettings(), QSettings())
# When
result = driver.evaluate_path(None)
@@ -31,7 +31,7 @@ def test_evaluate_path_empty():
def test_evaluate_path_missing():
# Given
driver = TestDriver(GlobalSettings(), QSettings())
driver = TestDriver(AppSettings(), QSettings())
# When
result = driver.evaluate_path("/0/4/5/1/")
@@ -44,7 +44,7 @@ def test_evaluate_path_last_lib_not_exists():
# Given
cache = QSettings()
cache.setValue(AppCacheItems.LAST_LIBRARY, "/0/4/5/1/")
driver = TestDriver(GlobalSettings(), cache)
driver = TestDriver(AppSettings(), cache)
# When
result = driver.evaluate_path(None)
@@ -60,7 +60,7 @@ def test_evaluate_path_last_lib_present(library_dir: Path):
cache.setValue(AppCacheItems.LAST_LIBRARY, library_dir)
cache.sync()
settings = GlobalSettings()
settings = AppSettings()
settings.open_last_loaded_on_startup = True
driver = TestDriver(settings, cache)