Skip to content

Commit

Permalink
Merge pull request #2383 from LibraryOfCongress/CONCD-816-rsar-card-test
Browse files Browse the repository at this point in the history
CONCD-816 Create tests for cards in views
  • Loading branch information
joshuastegmaier authored May 21, 2024
2 parents e6938c8 + 5d8c39a commit 615d04b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 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_guide,
create_item,
create_project,
Expand Down Expand Up @@ -376,6 +377,8 @@ def test_asset_detail_view(self):
)
self.transcription.save()

asset.item.project.campaign.card_family = create_card_family()
asset.item.project.campaign.save()
title = "Transcription: Basic Rules"
create_guide(title=title)

Expand All @@ -391,6 +394,7 @@ def test_asset_detail_view(self):
)
)
self.assertEqual(response.status_code, 200)
self.assertIn("cards", response.context)
self.assertIn("guides", response.context)
self.assertEqual(title, response.context["guides"][0]["title"])

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,
Guide,
Item,
MediaType,
Expand Down Expand Up @@ -225,6 +226,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


def create_guide(*, do_save=True, **kwargs):
guide = Guide(**kwargs)
if do_save:
Expand Down

0 comments on commit 615d04b

Please sign in to comment.