Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
test(Testing): ✅ Improve test coverage
Browse files Browse the repository at this point in the history
Fixes #147

Signed-off-by: Matthew Gray <44288823+mmoomocow@users.noreply.github.com>
  • Loading branch information
mmoomocow committed May 18, 2023
1 parent 0a52f88 commit 6f00106
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions commendations/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ def test_Commendation(self):
f"Commendation student was not set correctly, expected {self.student.student}, got {commendation.students.first()}",
)

self.assertEqual(
commendation.__str__(),
f"Commendation ID: {commendation.id}",
f"Commendation __str__ was not set correctly, expected Commendation ID: {commendation.id}, got {commendation.__str__()}",
)


class commendationsCommendationAdminTest(TestCase):
def setUp(self):
Expand Down Expand Up @@ -292,3 +298,35 @@ def test_giveCommendation_post_reason_AND_quickReason(self):
commendation.exists(),
"Commendation was not created from post request",
)

def test_giveCommendation_post_only_quickReason(self):
testHelper.post_page(
self,
"/commendations/award/",
{
"commendationType": Commendation.EXCELLENCE,
"students": [self.student.student.id],
"teacher": self.teacher.teacher.id,
"reason": "",
"quickReason": "Being truthful",
},
status_code=302,
)

# Check that the commendation was created
commendation = Commendation.objects.filter(
commendation_type=Commendation.EXCELLENCE,
reason="Being truthful",
teacher=self.teacher.teacher.id,
students=self.student.student.id,
)
self.assertTrue(
commendation.exists(),
"Commendation was not created from post request",
)

self.assertEqual(
commendation.first().reason,
"Being truthful",
f"Commendation reason was not set correctly, expected Being truthful, got {commendation.first().reason}",
)

0 comments on commit 6f00106

Please sign in to comment.