def test_main_filters_names(the_loop): main.settings().checks.extend([ {'name': 'A', 'url': 'A'}, {'name': 'B', 'url': 'B'}, ]) assert 0 == main.main(names=['B']) assert the_loop.call_count == 1 assert the_loop.call_args[0][0][0].check.call_count == 1
def test_main_executes_all_checks_before_loop(the_loop): main.settings().checks.append({ 'name': 'A', 'script': {'python': 'ok, content = True, "ok"'} }) assert 0 == main.main() assert the_loop.call_count == 1 assert the_loop.call_args[0][0][0].check.call_count == 1
def test_dummy_schedule(): main.Checker.check.side_effect = interrupt_on_nth_call(2) main.settings().checks.append({ 'name': 'A', 'script': {'python': 'ok, content = True, "ok"'}, 'period': 0, }) assert 0 == main.main() assert main.Checker.check.call_count == 2
def run(ctx, name): """Run kibitzr in the foreground mode""" from kibitzr.main import main sys.exit(main(once=False, log_level=ctx.obj['log_level'], names=name))
def once(ctx, name): """Run kibitzr checks once and exit""" from kibitzr.main import main sys.exit(main(once=True, log_level=ctx.obj['log_level'], names=name))
def test_loop_aborts_without_checks(): assert 1 == main.main()