Exemple #1
0
 def test_librarian_renew_form_validation_error_for_renewal_date_above_two_weeks(
         self):
     date = datetime.date.today() + datetime.timedelta(
         weeks=2) + datetime.timedelta(days=1)
     form = LibrarianRenewBookModelForm(data={'due_back': date})
     error_message = ['Invalid date - renewal more than 2 weeks ahead']
     self.assertEquals(form.errors, {'due_back': error_message})
Exemple #2
0
 def test_librarian_only_due_back_field_is_displayed(self):
     available_fields = [
         'due_back',
     ]
     form = LibrarianRenewBookModelForm()
     self.assertEquals(list(form.base_fields), available_fields)
Exemple #3
0
 def test_librarian_renew_form_renewal_max_date_of_two_weeks(self):
     date = timezone.localtime() + datetime.timedelta(weeks=2)
     form = LibrarianRenewBookModelForm(data={'due_back': date})
     self.assertTrue(form.is_valid())
Exemple #4
0
 def test_librarian_renew_form_validation_error_for_renewal_date_in_the_past(
         self):
     date = datetime.date.today() - datetime.timedelta(days=1)
     form = LibrarianRenewBookModelForm(data={'due_back': date})
     form_error_message = ['Invalid date - renewal in past']
     self.assertEquals(form.errors, {'due_back': form_error_message})
Exemple #5
0
 def test_librarian_renew_form_renewal_date_is_today(self):
     date = datetime.date.today()
     form = LibrarianRenewBookModelForm(data={'due_back': date})
     self.assertTrue(form.is_valid())
Exemple #6
0
 def test_librarian_renew_form_renewal_date_too_far_in_future(self):
     date = datetime.date.today() + datetime.timedelta(
         weeks=2) + datetime.timedelta(days=1)
     form = LibrarianRenewBookModelForm(data={'due_back': date})
     self.assertFalse(form.is_valid())
Exemple #7
0
 def test_librarian_renew_form_renewal_date_in_past(self):
     date = datetime.date.today() - datetime.timedelta(days=1)
     form = LibrarianRenewBookModelForm(data={'due_back': date})
     self.assertFalse(form.is_valid())
Exemple #8
0
 def test_librarian_renew_form_renewal_date_help_text(self):
     form = LibrarianRenewBookModelForm()
     form_field_help_text = form.fields['due_back'].help_text
     self.assertEquals(form_field_help_text,
                       "Enter a date between now and 2 weeks (default 1).")
Exemple #9
0
 def test_librarian_renew_form_due_back_label_is_renewal_date(self):
     form = LibrarianRenewBookModelForm()
     # Testing for None here because Django will return None if
     # the value is not explicitly set
     self.assertTrue(form.fields['due_back'].label is None
                     or form.fields['due_back'].label == 'Renewal date')