示例#1
0
 def test_short_and_long_arguments_be_the_same(self):
     for arg in "--app", "-A":
         appstr = '.'.join([__name__, 'APP'])
         x = CeleryCommand(app=self.app)
         x.execute = Mock()
         with pytest.raises(SystemExit):
             x.execute_from_commandline(['celery', arg, appstr, 'worker'])
         assert x.execute.called
         assert x.execute.call_args[0]
         assert x.execute.call_args[0][0] == "worker"
示例#2
0
    def test_execute_from_commandline(self):
        x = CeleryCommand(app=self.app)
        x.handle_argv = Mock()
        x.handle_argv.return_value = 1
        with self.assertRaises(SystemExit):
            x.execute_from_commandline()

        x.handle_argv.return_value = True
        with self.assertRaises(SystemExit):
            x.execute_from_commandline()

        x.handle_argv.side_effect = KeyboardInterrupt()
        with self.assertRaises(SystemExit):
            x.execute_from_commandline()

        x.respects_app_option = True
        with self.assertRaises(SystemExit):
            x.execute_from_commandline(['celery', 'multi'])
        self.assertFalse(x.respects_app_option)
        x.respects_app_option = True
        with self.assertRaises(SystemExit):
            x.execute_from_commandline(['manage.py', 'celery', 'multi'])
        self.assertFalse(x.respects_app_option)
示例#3
0
    def test_execute_from_commandline(self):
        x = CeleryCommand(app=self.app)
        x.handle_argv = Mock()
        x.handle_argv.return_value = 1
        with self.assertRaises(SystemExit):
            x.execute_from_commandline()

        x.handle_argv.return_value = True
        with self.assertRaises(SystemExit):
            x.execute_from_commandline()

        x.handle_argv.side_effect = KeyboardInterrupt()
        with self.assertRaises(SystemExit):
            x.execute_from_commandline()
示例#4
0
    def test_execute_from_commandline(self):
        x = CeleryCommand(app=self.app)
        x.handle_argv = Mock()
        x.handle_argv.return_value = 1
        with self.assertRaises(SystemExit):
            x.execute_from_commandline()

        x.handle_argv.return_value = True
        with self.assertRaises(SystemExit):
            x.execute_from_commandline()

        x.handle_argv.side_effect = KeyboardInterrupt()
        with self.assertRaises(SystemExit):
            x.execute_from_commandline()
示例#5
0
 def execute_from_commandline(self, argv=None):
     if argv is None:
         argv = self.setup_app_from_commandline(argv)
     print "ARGV", argv
     return CeleryCommand.execute_from_commandline(self, argv)
def start_celery(argv):
    cmd = CeleryCommand()
    cmd.maybe_patch_concurrency()
    cmd.execute_from_commandline(argv)