def process_request(self, request, *args, **kwargs): form = SignoffFilterForm(request.GET) if form.is_valid(): self.appver = form.cleaned_data['av'] self.up_until = form.cleaned_data['up_until'] else: raise BadRequestData(list(form.errors.items()))
def process_request(self, request, *args, **kwargs): form = SignoffFilterForm(request.GET) if form.is_valid(): self.appver = form.cleaned_data['av'] self.up_until = form.cleaned_data['up_until'] else: raise BadRequestData(form.errors.items())
def test_signoff_filter_form(self): form = SignoffFilterForm({}) self.assertFalse(form.is_valid()) form = SignoffFilterForm({ 'av': '', 'up_until': '', }) self.assertFalse(form.is_valid()) # check a couple of recognized recognized up_until values form = SignoffFilterForm({ 'up_until': '2012-08-17 14:50:00', }) self.assertFalse(form.is_valid()) self.assertEqual( form.cleaned_data['up_until'], datetime.datetime(2012, 8, 17, 14, 50, 0)) # not a valid date form = SignoffFilterForm({ 'up_until': '2012-02-32 14:50:00', }) self.assertFalse(form.is_valid()) self.assertTrue(form.errors) self.assertIn('up_until', form.errors) # try passing an AppVersion # ...left blank form = SignoffFilterForm({ 'av': '', }) self.assertFalse(form.is_valid()) # ...that doesn't exist form = SignoffFilterForm({ 'av': 'xxx', }) self.assertFalse(form.is_valid()) self.assertTrue(form.errors) self.assertIn('av', form.errors) # ...that does exist form = SignoffFilterForm({ 'av': self.appver.code, }) self.assertTrue(form.is_valid())
def test_signoff_filter_form(self): form = SignoffFilterForm({}) self.assertFalse(form.is_valid()) form = SignoffFilterForm({ 'av': '', 'up_until': '', }) self.assertFalse(form.is_valid()) # check a couple of recognized recognized up_until values form = SignoffFilterForm({ 'up_until': '2012-08-17 14:50:00', }) self.assertFalse(form.is_valid()) self.assertEqual( form.cleaned_data['up_until'], datetime.datetime(2012, 8, 17, 14, 50, 0)) # not a valid date form = SignoffFilterForm({ 'up_until': '2012-02-32 14:50:00', }) self.assertFalse(form.is_valid()) self.assertTrue(form.errors) self.assertIn('up_until', form.errors) # try passing an AppVersion # ...left blank form = SignoffFilterForm({ 'av': '', }) self.assertFalse(form.is_valid()) # ...that doesn't exist form = SignoffFilterForm({ 'av': 'xxx', }) self.assertFalse(form.is_valid()) self.assertTrue(form.errors) self.assertIn('av', form.errors) # ...that does exist form = SignoffFilterForm({ 'av': self.appver.code, }) self.assertTrue(form.is_valid())
def test_signoff_filter_form(self): form = SignoffFilterForm({}) ok_(form.is_valid()) eq_(form.cleaned_data['ms'], None) eq_(form.cleaned_data['av'], None) eq_(form.cleaned_data['up_until'], None) form = SignoffFilterForm({ 'av': '', 'ms': '', 'up_until': '', }) ok_(form.is_valid()) eq_(form.cleaned_data['ms'], None) eq_(form.cleaned_data['av'], None) eq_(form.cleaned_data['up_until'], None) # check a couple of recognized recognized up_until values form = SignoffFilterForm({ 'up_until': '2012-08-17 14:50:00', }) ok_(form.is_valid()) eq_(form.cleaned_data['up_until'], datetime.datetime(2012, 8, 17, 14, 50, 0)) # not a valid date form = SignoffFilterForm({ 'up_until': '2012-02-32 14:50:00', }) ok_(not form.is_valid()) ok_(form.errors) ok_('up_until' in form.errors) # try passing an AppVersion # ...left blank form = SignoffFilterForm({ 'av': '', }) ok_(form.is_valid()) # ...that doesn't exist form = SignoffFilterForm({ 'av': 'xxx', }) ok_(not form.is_valid()) ok_(form.errors) ok_('av' in form.errors) # ...that does exist form = SignoffFilterForm({ 'av': self.appver.code, }) ok_(form.is_valid()) # and a Milestone # ...that doesn't exist form = SignoffFilterForm({ 'ms': 'xx', }) ok_(not form.is_valid()) ok_(form.errors) ok_('ms' in form.errors) # ...that exists form = SignoffFilterForm({ 'ms': self.milestone.code, }) ok_(form.is_valid())
def test_signoff_filter_form(self): form = SignoffFilterForm({}) ok_(form.is_valid()) eq_(form.cleaned_data['ms'], None) eq_(form.cleaned_data['av'], None) eq_(form.cleaned_data['up_until'], None) form = SignoffFilterForm({ 'av': '', 'ms': '', 'up_until': '', }) ok_(form.is_valid()) eq_(form.cleaned_data['ms'], None) eq_(form.cleaned_data['av'], None) eq_(form.cleaned_data['up_until'], None) # check a couple of recognized recognized up_until values form = SignoffFilterForm({ 'up_until': '2012-08-17 14:50:00', }) ok_(form.is_valid()) eq_(form.cleaned_data['up_until'], datetime.datetime(2012, 8, 17, 14, 50, 0)) # not a valid date form = SignoffFilterForm({ 'up_until': '2012-02-32 14:50:00', }) ok_(not form.is_valid()) ok_(form.errors) ok_('up_until' in form.errors) # try passing an AppVersion # ...left blank form = SignoffFilterForm({ 'av': '', }) ok_(form.is_valid()) # ...that doesn't exist form = SignoffFilterForm({ 'av': 'xxx', }) ok_(not form.is_valid()) ok_(form.errors) ok_('av' in form.errors) # ...that does exist form = SignoffFilterForm({ 'av': self.appver.code, }) ok_(form.is_valid()) # and a Milestone # ...that doesn't exist form = SignoffFilterForm({ 'ms': 'xx', }) ok_(not form.is_valid()) ok_(form.errors) ok_('ms' in form.errors) # ...that exists form = SignoffFilterForm({ 'ms': self.milestone.code, }) ok_(form.is_valid())