def test_non_interactive(self, *mock): PurgeRequest().handle(amount=1, duration='days', interactive=False) self.assertFalse(mock[0].called) self.assertEqual(1, Request.objects.count())
def test_no_request_to_delete(self, mock_stdout): Request.objects.all().delete() PurgeRequest().handle(amount=1, duration='day', interactive=False) self.assertIn('There are no requests to delete.', mock_stdout.getvalue())
def test_interactive_non_confirmed(self, mock_stdout, mock_input): PurgeRequest().handle(amount=1, duration='days', interactive=True) self.assertTrue(mock_input.called) self.assertEqual(2, Request.objects.count()) self.assertEqual('Purge cancelled\n', mock_stdout.getvalue())
def test_invalid_duration(self, *mock): with self.assertRaises(CommandError): PurgeRequest().handle(amount=1, duration='foo') self.assertEqual(2, Request.objects.count())
def test_duration_without_s(self, *mock): PurgeRequest().handle(amount=1, duration='day') self.assertEqual(1, Request.objects.count())
def test_purge_requests(self, *mock): PurgeRequest().handle(amount=1, duration='days') self.assertEqual(1, Request.objects.count())
def test_interactive_non_confirmed(self, *mock): PurgeRequest().handle(amount=1, duration='days', interactive=True) self.assertTrue(mock[0].called) self.assertEqual(2, Request.objects.count())
def test_no_request_to_delete(self, *mock): PurgeRequest().handle(amount=1, duration='days')