コード例 #1
0
    def test_main_gen_cfg(self):
        cronner = Cronner()
        cronner.configure(serializer=lambda es: '\n'.join(
            '{}'.format(e['schedule']) for e in es))

        @cronner.register('* * * * *')
        def fn():
            pass

        with self.captureOutput(assert_stdout='* * * * *\n'):
            cronner.main(['gen-cfg'])
コード例 #2
0
    def test_main_no_input(self):
        cronner = Cronner()

        @cronner.register('* * * * *')
        def fn():
            pass

        with self.captureOutput():
            try:
                cronner.main([])
            except SystemExit as e:
                self.assertTrue(e.code > 0)
コード例 #3
0
    def test_main_help(self):
        cronner = Cronner()

        @cronner.register('* * * * *')
        def fn():
            pass

        with self.captureOutput():
            try:
                cronner.main(['--help'])
            except SystemExit as e:
                self.assertEqual(e.code, 0)
コード例 #4
0
    def test_main_run(self):
        cronner = Cronner()

        @cronner.register('* * * * *')
        def fn(*args):
            print('+'.join(args))

        with self.captureOutput(assert_stdout='a+b+c\n'):
            cronner.main([
                'run', '{}.{}'.format(fn.__module__, fn.__name__), '--params',
                'a', 'b', 'c'
            ])