def test_rebuild_index_nocommit(self, *mocks): """ Confirm that command-line option parsing produces the same results as using call_command() directly, mostly as a sanity check for the logic in rebuild_index which combines the option_lists for its component commands. """ from haystack.management.commands.rebuild_index import Command Command().run_from_argv( ['django-admin.py', 'rebuild_index', '--noinput', '--nocommit']) for m in mocks: self.assertEqual(m.call_count, 1) args, kwargs = m.call_args self.assertIn('commit', kwargs) self.assertEqual(False, kwargs['commit']) self.assertIn('interactive', kwargs) self.assertEqual(False, kwargs['interactive'])
def test_rebuild_index_nocommit(self, update_mock, clear_mock): """ Confirm that command-line option parsing produces the same results as using call_command() directly, mostly as a sanity check for the logic in rebuild_index which combines the option_lists for its component commands. """ from haystack.management.commands.rebuild_index import Command Command().run_from_argv( ["django-admin.py", "rebuild_index", "--noinput", "--nocommit"]) for m in (clear_mock, update_mock): self.assertEqual(m.call_count, 1) args, kwargs = m.call_args self.assertIn("commit", kwargs) self.assertEqual(False, kwargs["commit"]) args, kwargs = clear_mock.call_args self.assertIn("interactive", kwargs) self.assertIs(kwargs["interactive"], False)
def rebuild_index(): cmd = RebuildIndexCommand() cmd.handle(interactive=False, verbosity=0)