Skip to content

Commit

Permalink
FIND-81:update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TNA-Allan committed Dec 11, 2024
1 parent 030d0ff commit bc1403e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 1 addition & 2 deletions test/ciim/factories.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
def create_record(
template_details=None,
iaid="C0000000",
source="CAT",
):
"""
Return a sample response for a record.
Useful for tidying up tests where response needs to be mocked.
otherwise creates a record with iaid
"""
if not template_details:
template_details = {"iaid": iaid, "source": source}
template_details = {"iaid": iaid}

# a typical record
record = {"@template": {"details": template_details}}
Expand Down
9 changes: 8 additions & 1 deletion test/records/test_views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from test.ciim.factories import create_record, create_response

import responses
from app.records.models import Record
from django.conf import settings
from django.test import TestCase

Expand Down Expand Up @@ -36,7 +37,9 @@ def test_record_rendered_for_single_result(self):
f"{settings.CLIENT_BASE_URL}/get",
json=create_response(
records=[
create_record(iaid="C123456"),
create_record(
template_details={"iaid": "C123456", "source": "CAT"}
),
]
),
)
Expand All @@ -56,3 +59,7 @@ def test_record_rendered_for_single_result(self):
self.assertEqual(
response.context_data.get("page_title"), "Catalogue ID: C123456"
)
self.assertIsInstance(response.context_data.get("record"), Record)

# record attribute
self.assertEqual(response.context_data.get("record").source, "CAT")

0 comments on commit bc1403e

Please sign in to comment.