Skip to content

Commit

Permalink
Expand ChantCreateViewTest.test_initial_values
Browse files Browse the repository at this point in the history
adding subtests for folio, sequence, and image link
  • Loading branch information
jacobdgm committed Apr 4, 2024
1 parent c16bcb2 commit 7aba709
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions django/cantusdb_project/main_app/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2910,30 +2910,50 @@ def test_volpiano_signal(self):
self.assertEqual(chant_2.volpiano_intervals, "1-12-23-34-45-56-67-78-8")

def test_initial_values(self):
# create a chant with a known folio, feast, office, c_sequence and image_link
source: Source = make_fake_source()
folio: str = "001r"
sequence: int = 1
feast: Feast = make_fake_feast()
office: Office = make_fake_office()
# create a chant with a known feast and office
image_link: str = "https://www.youtube.com/watch?v=9bZkp7q19f0"
self.client.post(
reverse("chant-create", args=[source.id]),
{
"manuscript_full_text_std_spelling": "this is a bog standard manuscript spelling textful",
"folio": "001r",
"c_sequence": "1",
"manuscript_full_text_std_spelling": "this is a bog standard manuscript textful spelling",
"folio": folio,
"c_sequence": str(sequence),
"feast": feast.id,
"office": office.id,
"image_link": image_link,
},
)
# when we request the page, the same feast and office should be preselected
request = self.client.get(

# when we request the Chant Create page, the same folio, feast, office and image_link should
# be preselected, and c_sequence should be incremented by 1.
response = self.client.get(
reverse("chant-create", args=[source.id]),
)
observed_initial_feast: int = request.context["form"].initial["feast"]
observed_intitial_office: int = request.context["form"].initial["office"]

observed_initial_folio: int = response.context["form"].initial["folio"]
with self.subTest(subtest="test initial value of folio field"):
self.assertEqual(observed_initial_folio, folio)

observed_initial_feast: int = response.context["form"].initial["feast"]
with self.subTest(subtest="test initial value of feast feild"):
self.assertEqual(observed_initial_feast, feast.id)

observed_initial_office: int = response.context["form"].initial["office"]
with self.subTest(subtest="test initial value of office field"):
self.assertEqual(observed_intitial_office, office.id)
self.assertEqual(observed_initial_office, office.id)

observed_initial_sequence: int = response.context["form"].initial["c_sequence"]
with self.subTest(subtest="test initial value of c_sequence field"):
self.assertEqual(observed_initial_sequence, sequence + 1)

observed_initial_image: int = response.context["form"].initial["image_link"]
with self.subTest(subtest="test initial value of image_link field"):
self.assertEqual(observed_initial_image, image_link)


class ChantDeleteViewTest(TestCase):
Expand Down

0 comments on commit 7aba709

Please sign in to comment.