Additional refactoring
Python CI / test (push) Successful in 1m17s
Lint / lint (push) Successful in 1m32s
Tests / test (3.10) (push) Successful in 1m10s
Tests / test (3.9) (push) Has been cancelled
Tests / test (3.11) (push) Has been cancelled

This commit is contained in:
2025-11-27 21:57:57 +01:00
parent d7786ede80
commit fae9e5bd2b
27 changed files with 472 additions and 204 deletions
+10 -2
View File
@@ -8,6 +8,7 @@ from PyQt6.QtCore import QMimeData, QUrl, QPoint
from PyQt6.QtGui import QDragEnterEvent, QDragMoveEvent, QDropEvent
from PyQt6.QtOpenGLWidgets import QOpenGLWidget
from pyPhotoAlbum.mixins.asset_drop import AssetDropMixin
from pyPhotoAlbum.mixins.asset_path import AssetPathMixin
from pyPhotoAlbum.mixins.viewport import ViewportMixin
from pyPhotoAlbum.mixins.page_navigation import PageNavigationMixin
from pyPhotoAlbum.project import Project, Page
@@ -16,14 +17,21 @@ from pyPhotoAlbum.models import ImageData
# Create test widget combining necessary mixins
class TestAssetDropWidget(AssetDropMixin, PageNavigationMixin, ViewportMixin, QOpenGLWidget):
"""Test widget combining asset drop, page navigation, and viewport mixins"""
class TestAssetDropWidget(AssetDropMixin, AssetPathMixin, PageNavigationMixin, ViewportMixin, QOpenGLWidget):
"""Test widget combining asset drop, asset path, page navigation, and viewport mixins"""
def _get_element_at(self, x, y):
"""Mock implementation for testing"""
# Will be overridden in tests that need it
return None
def _get_project_folder(self):
"""Override to access project via window mock"""
main_window = self.window()
if hasattr(main_window, 'project') and main_window.project:
return getattr(main_window.project, 'folder_path', None)
return None
class TestAssetDropInitialization:
"""Test AssetDropMixin initialization"""
+10 -5
View File
@@ -6,6 +6,7 @@ import pytest
from unittest.mock import Mock, MagicMock, patch, mock_open
from PyQt6.QtWidgets import QMainWindow, QFileDialog
from pyPhotoAlbum.mixins.operations.element_ops import ElementOperationsMixin
from pyPhotoAlbum.mixins.asset_path import AssetPathMixin
from pyPhotoAlbum.models import ImageData, TextBoxData, PlaceholderData
from pyPhotoAlbum.project import Project, Page
from pyPhotoAlbum.page_layout import PageLayout
@@ -13,7 +14,7 @@ from pyPhotoAlbum.commands import CommandHistory
# Create test window with ElementOperationsMixin
class TestElementWindow(ElementOperationsMixin, QMainWindow):
class TestElementWindow(ElementOperationsMixin, AssetPathMixin, QMainWindow):
"""Test window with element operations mixin"""
def __init__(self):
@@ -23,10 +24,10 @@ class TestElementWindow(ElementOperationsMixin, QMainWindow):
self.gl_widget = Mock()
# Mock project
self.project = Mock()
self.project.history = CommandHistory()
self.project.asset_manager = Mock()
self.project.folder_path = "/tmp/test_project"
self._project = Mock()
self._project.history = CommandHistory()
self._project.asset_manager = Mock()
self._project.folder_path = "/tmp/test_project"
# Track method calls
self._update_view_called = False
@@ -35,6 +36,10 @@ class TestElementWindow(ElementOperationsMixin, QMainWindow):
self._require_page_called = False
self._current_page_index = 0
@property
def project(self):
return self._project
def require_page(self):
"""Track require_page calls"""
self._require_page_called = True