예제 #1
0
 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())
예제 #2
0
 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())
예제 #3
0
 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())
예제 #4
0
 def test_invalid_duration(self, *mock):
     with self.assertRaises(CommandError):
         PurgeRequest().handle(amount=1, duration='foo')
     self.assertEqual(2, Request.objects.count())
예제 #5
0
 def test_duration_without_s(self, *mock):
     PurgeRequest().handle(amount=1, duration='day')
     self.assertEqual(1, Request.objects.count())
예제 #6
0
 def test_purge_requests(self, *mock):
     PurgeRequest().handle(amount=1, duration='days')
     self.assertEqual(1, Request.objects.count())
예제 #7
0
 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())
예제 #8
0
 def test_no_request_to_delete(self, *mock):
     PurgeRequest().handle(amount=1, duration='days')