Skip to content

Commit

Permalink
Fixed test for semester activation
Browse files Browse the repository at this point in the history
  • Loading branch information
florian-str committed Dec 5, 2022
1 parent 3413a11 commit 789a39c
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions evap/rewards/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,21 +205,30 @@ def setUpTestData(cls):
course=course,
)

cls.url = f"/rewards/reward_semester_activation/{cls.semester.pk}/"
cls.url = f"/rewards/reward_semester_activation/{cls.semester.pk}/edit"

def test_activate(self):
baker.make(SemesterActivation, semester=self.semester, is_active=False)
self.app.post(self.url + "on", user=self.manager)
response = self.app.post(self.url, user=self.manager)
form = response.forms["form_activation_status"]
form.set("activation_status", "on")
form.submit()
self.assertTrue(is_semester_activated(self.semester))

def test_deactivate(self):
baker.make(SemesterActivation, semester=self.semester, is_active=True)
self.app.post(self.url + "off", user=self.manager)
response = self.app.post(self.url, user=self.manager)
form = response.forms["form_activation_status"]
form.set("activation_status", "off")
form.submit()
self.assertFalse(is_semester_activated(self.semester))

def test_activate_after_voting(self):
baker.make(SemesterActivation, semester=self.semester, is_active=False)
self.assertEqual(0, reward_points_of_user(self.student))
response = self.app.post(self.url + "on", user=self.manager)
response = self.app.post(self.url, user=self.manager)
form = response.forms["form_activation_status"]
form.set("activation_status", "on")
response = form.submit()
self.assertContains(response, "3 reward points were granted")
self.assertEqual(3, reward_points_of_user(self.student))

0 comments on commit 789a39c

Please sign in to comment.