Skip to content

Commit

Permalink
CONCD-816 Create tests for cards in views
Browse files Browse the repository at this point in the history
  • Loading branch information
rasarkar committed May 20, 2024
1 parent cadba0d commit 3f11661
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions concordia/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
JSONAssertMixin,
create_asset,
create_campaign,
create_card_family,
create_item,
create_project,
create_topic,
Expand Down Expand Up @@ -375,6 +376,9 @@ def test_asset_detail_view(self):
)
self.transcription.save()

asset.item.project.campaign.card_family = create_card_family()
asset.item.project.campaign.save()

response = self.client.get(
reverse(
"transcriptions:asset-detail",
Expand All @@ -388,6 +392,7 @@ def test_asset_detail_view(self):
)

self.assertEqual(response.status_code, 200)
self.assertIn("cards", response.context)

@patch.object(Asset, "get_ocr_transcript")
def test_generate_ocr_transcription(self, mock):
Expand Down
8 changes: 8 additions & 0 deletions concordia/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
Asset,
Campaign,
Card,
CardFamily,
Item,
MediaType,
Project,
Expand Down Expand Up @@ -224,6 +225,13 @@ def create_card(*, title="Test Card", do_save=True, **kwargs):
return card


def create_card_family(*, do_save=True, **kwargs):
card_family = CardFamily(**kwargs)
if do_save:
card_family.save()
return card_family


class JSONAssertMixin(object):
def assertValidJSON(self, response, expected_status=200):
"""
Expand Down

0 comments on commit 3f11661

Please sign in to comment.