aboutsummaryrefslogtreecommitdiffstats
path: root/pyblackbird_cc/resources/tests
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-05-16 16:57:14 +0100
committerMatthew Lemon <y@yulqen.org>2024-05-16 16:57:14 +0100
commit55e5dfbd51924f1f23e5a651d830206be01e376c (patch)
treee3ea881742b3afc2c473c890cbfd8d98d20cc4a9 /pyblackbird_cc/resources/tests
parent65c49ea41ecd8e1cce07db1b258a93132cb634d4 (diff)
wip: starting to test feature resource functionality with factories
Diffstat (limited to 'pyblackbird_cc/resources/tests')
-rw-r--r--pyblackbird_cc/resources/tests/conftest.py8
-rw-r--r--pyblackbird_cc/resources/tests/test_models.py10
2 files changed, 16 insertions, 2 deletions
diff --git a/pyblackbird_cc/resources/tests/conftest.py b/pyblackbird_cc/resources/tests/conftest.py
new file mode 100644
index 0000000..0d1ed87
--- /dev/null
+++ b/pyblackbird_cc/resources/tests/conftest.py
@@ -0,0 +1,8 @@
+import pytest
+
+from pyblackbird_cc.resources.factories import ResourceModelFactory
+
+
+@pytest.fixture()
+def resources():
+ return ResourceModelFactory.create_batch(5)
diff --git a/pyblackbird_cc/resources/tests/test_models.py b/pyblackbird_cc/resources/tests/test_models.py
index e1fe290..c54120c 100644
--- a/pyblackbird_cc/resources/tests/test_models.py
+++ b/pyblackbird_cc/resources/tests/test_models.py
@@ -1,6 +1,7 @@
import unittest
from unittest.mock import patch
+import pytest
from django.test import TestCase
from pyblackbird_cc.resources.models import PDFPageSnapshot
@@ -12,10 +13,15 @@ from pyblackbird_cc.resources.views import ResourceInfo
from pyblackbird_cc.resources.views import _extract_metadata_from_resource
+@pytest.mark.django_db
+def test_resource_model(resources):
+ assert Resource.objects.filter(name="Default Resource 1").exists()
+
+
class ResourceModelTest(TestCase):
def test_string_representation(self):
resource = Resource(name="Test Resource")
- assert str(resource) == "Test Resource"
+ assert str(resource) == "Test Resource"
@unittest.skip("Skipping this test for now as it is broken")
@@ -39,7 +45,7 @@ class TestExtractMetadata(TestCase):
result = _extract_metadata_from_resource(mock_resource)
self.assertIsInstance(result, ResourceInfo)
assert result.name == "Test Resource"
- assert result.pdf_filenames == "test.pdf"
+ assert result.pdf_filenames == "test.pdf"
assert result.thumbnail_filenames in ["thumb.jpg", "thumb2.jpg"]
assert result.created == "2022-01-01"
assert result.updated == "2022-01-02"