61 lines
2.1 KiB
Python
61 lines
2.1 KiB
Python
"""
|
|
Simplified unit tests for abstract document elements using test mixins.
|
|
|
|
This demonstrates how test mixins can eliminate duplication and simplify tests.
|
|
"""
|
|
|
|
import unittest
|
|
from pyWebLayout.abstract.document import Document, Chapter
|
|
from tests.mixins.font_registry_tests import FontRegistryTestMixin, FontRegistryParentDelegationTestMixin
|
|
from tests.mixins.metadata_tests import MetadataContainerTestMixin
|
|
|
|
|
|
class TestDocumentFontRegistry(FontRegistryTestMixin, unittest.TestCase):
|
|
"""Test FontRegistry behavior for Document - simplified with mixin."""
|
|
|
|
def create_test_object(self):
|
|
"""Create a Document instance for testing."""
|
|
return Document("Test Document", "en-US")
|
|
|
|
|
|
class TestDocumentMetadata(MetadataContainerTestMixin, unittest.TestCase):
|
|
"""Test MetadataContainer behavior for Document - simplified with mixin."""
|
|
|
|
def create_test_object(self):
|
|
"""Create a Document instance for testing."""
|
|
return Document("Test Document", "en-US")
|
|
|
|
|
|
class TestChapterFontRegistry(FontRegistryTestMixin, unittest.TestCase):
|
|
"""Test FontRegistry behavior for Chapter - simplified with mixin."""
|
|
|
|
def create_test_object(self):
|
|
"""Create a Chapter instance for testing."""
|
|
return Chapter("Test Chapter", level=1)
|
|
|
|
|
|
class TestChapterFontRegistryParentDelegation(
|
|
FontRegistryParentDelegationTestMixin,
|
|
unittest.TestCase):
|
|
"""Test FontRegistry parent delegation for Chapter - simplified with mixin."""
|
|
|
|
def create_parent(self):
|
|
"""Create a Document as parent."""
|
|
return Document("Parent Document", "en-US")
|
|
|
|
def create_child(self, parent):
|
|
"""Create a Chapter with parent reference."""
|
|
return Chapter("Child Chapter", level=1, parent=parent)
|
|
|
|
|
|
class TestChapterMetadata(MetadataContainerTestMixin, unittest.TestCase):
|
|
"""Test MetadataContainer behavior for Chapter - simplified with mixin."""
|
|
|
|
def create_test_object(self):
|
|
"""Create a Chapter instance for testing."""
|
|
return Chapter("Test Chapter", level=1)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|