Esempio n. 1
0
    def test_negative_fields(self):
        data = dict(limit_days=-1, limit_size=-1)
        form = ManualCleanupForm(data=data,
                                 initial=dict(type='feedback__Feedback'))

        self.assertFalse(form.is_valid())
        self.assertCountEqual(list(form.errors.keys()),
                              ['limit_size', 'limit_days'])
Esempio n. 2
0
    def test_form(self):
        data = dict(limit_days=10, limit_size=10)
        form = ManualCleanupForm(data=data, initial=dict(type='feedback__Feedback'))
        self.assertTrue(form.is_valid())
        self.assertEqual(form.cleaned_data['limit_days'], 10)
        self.assertEqual(form.cleaned_data['limit_size'], 10)
        self.assertEqual(type(form.fields), OrderedDict)
        self.assertEqual(form.fields.keys(), ['limit_days', 'limit_size'])

        with mock.patch('omaha.tasks.deferred_manual_cleanup.apply_async') as mocked:
            form.cleanup()
        mock_args, mock_kwargs = mocked.call_args

        self.assertTrue(mocked.called)
        self.assertDictEqual(mock_args[1], data)
    def test_negative_fields(self):
        data = dict(limit_days=-1, limit_size=-1)
        form = ManualCleanupForm(data=data, initial=dict(type='feedback__Feedback'))

        self.assertFalse(form.is_valid())
        self.assertItemsEqual(form.errors.keys(), ['limit_size', 'limit_days'])