aboutsummaryrefslogtreecommitdiffstats
path: root/pyblackbird_cc/resources/tests/test_models.py
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-05-20 20:17:25 +0100
committerMatthew Lemon <y@yulqen.org>2024-05-20 20:17:25 +0100
commitff1aa3aa113e507f870eba4c96099946f154fb22 (patch)
treedb14562172d6936bdcc993b6af45ccbd2f2d8d89 /pyblackbird_cc/resources/tests/test_models.py
parentd048429fefaa92c7600b46fec9d38e1e9e862457 (diff)
wip:
- Passing test for raw ORM handling to find snapshot files from an object - Quietens down pytest output
Diffstat (limited to 'pyblackbird_cc/resources/tests/test_models.py')
-rw-r--r--pyblackbird_cc/resources/tests/test_models.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/pyblackbird_cc/resources/tests/test_models.py b/pyblackbird_cc/resources/tests/test_models.py
index 5adcd14..56416f4 100644
--- a/pyblackbird_cc/resources/tests/test_models.py
+++ b/pyblackbird_cc/resources/tests/test_models.py
@@ -4,6 +4,7 @@ from unittest.mock import patch
import pytest
from django.test import TestCase
+from pyblackbird_cc.resources.factories import PDFPageSnapshotModelFactory
from pyblackbird_cc.resources.models import PDFPageSnapshot
from pyblackbird_cc.resources.models import PDFResource
from pyblackbird_cc.resources.models import Resource
@@ -12,10 +13,25 @@ from pyblackbird_cc.resources.models import ResourceType
from pyblackbird_cc.resources.views import ResourceInfo
from pyblackbird_cc.resources.views import _extract_metadata_from_resource
+# TODO - convert this test into the test of a function
+# that takes a Resource object and returns all the PDF snapshots
+# file names
+
@pytest.mark.django_db()
def test_resource_model(resources):
+ # Create a resource
+ r1 = resources[0]
+ # Get the first pdf resource on the resource
+ pdf_on_rw = r1.pdf_resources.first()
+ # Create a single pdf_page_shapshot and associate it with the pdf resource on the resource
+ pdf_page_snapshot = PDFPageSnapshotModelFactory(pdf_file=pdf_on_rw)
assert Resource.objects.filter(name="Default Resource 1").exists()
+ assert "test_0.pdf" in r1.get_pdf_file_names()
+ assert "test_1.pdf" in r1.get_pdf_file_names()
+ assert "test_2.pdf" in r1.get_pdf_file_names()
+ assert "test_3.pdf" not in r1.get_pdf_file_names()
+ assert "pdf_page_snapshot_0.jpg" in r1.get_pdf_snapshot_file_names()
class ResourceModelTest(TestCase):