Skip to content

Commit

Permalink
Fix reset and test
Browse files Browse the repository at this point in the history
  • Loading branch information
isuruf committed Oct 28, 2019
1 parent 706e7cc commit 4dafc64
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion course/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def back_to_form(form, form_info):
process_form_fields(form_info.fields, request.POST)
form = CreateForm(form_info.fields)

if "clear" in request.POST:
if "reset" in request.POST:
return back_to_form(form, form_info)

page_source, file_out = form.get_jinja_text()
Expand Down
9 changes: 9 additions & 0 deletions tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,12 @@ def test_instructor_form_access(self):
with self.temporarily_switch_to_user(self.get_instructor_with_perm()):
resp = self.c.get(self.get_view_form_url(form_id="instant"))
self.assertEqual(resp.status_code, 200)

def test_form_reset(self):
with self.temporarily_switch_to_user(self.get_instructor_with_perm()):
from time import time
new_duration = int(time())
data = {"reset": "", "duration": new_duration}
resp = self.c.post(self.get_view_form_url(form_id="instant"), data=data)
self.assertEqual(resp.status_code, 200)
self.assertNotIn(str(new_duration), resp.content.decode("utf-8"))

0 comments on commit 4dafc64

Please sign in to comment.