示例#1
0
 def setUp(self):
     self.timedelta = datetime.timedelta(weeks=2)
     self.form = ExemptionForm(data={
         'requestor': 1,
         'hosts': [1],
         'expires': timezone.now() + self.timedelta,
         'request': 'foo',
         'response': 'bar',
     })
示例#2
0
class TestExemptionForm(TestCase):
    fixtures = ['fixtures.json']

    def setUp(self):
        self.timedelta = datetime.timedelta(weeks=2)
        self.form = ExemptionForm(data={
            'requestor': 1,
            'hosts': [1],
            'expires': timezone.now() + self.timedelta,
            'request': 'foo',
            'response': 'bar',
        })

    def test_initial_conditions(self):
        self.assertTrue(self.form.is_valid())

    def test_invalid_expiration(self):
        self.form.data['expires'] = self.form.data['expires'] - (self.timedelta * 2) 
        self.assertFalse(self.form.is_valid())