diff --git a/crm/main.py b/crm/main.py index f728f87dd9..9b0d06e89a 100644 --- a/crm/main.py +++ b/crm/main.py @@ -237,9 +237,9 @@ def polling(ctx): @polling.command() @click.pass_context -@click.argument('interval', type=click.INT) +@click.argument('interval', type=click.IntRange(1, 9999)) def interval(ctx, interval): - """CRM polling interval configuration""" + """CRM polling interval configuration in seconds (range: 1-9999)""" ctx.obj["crm"].config('polling_interval', interval) @config.group() diff --git a/tests/crm_test.py b/tests/crm_test.py index 24ced116ce..6b3f32ed9d 100644 --- a/tests/crm_test.py +++ b/tests/crm_test.py @@ -1033,6 +1033,8 @@ """ +crm_config_interval_too_big = "Error: Invalid value for \"INTERVAL\": 30000 is not in the valid range of 1 to 9999." + class TestCrm(object): @classmethod def setup_class(cls): @@ -1053,6 +1055,18 @@ def test_crm_show_summary(self): assert result.exit_code == 0 assert result.output == crm_new_show_summary + def test_crm_config_polling_interval(self): + runner = CliRunner() + db = Db() + result = runner.invoke(crm.cli, ['config', 'polling', 'interval', '10'], obj=db) + print(sys.stderr, result.output) + assert result.exit_code == 0 + result = runner.invoke(crm.cli, ['config', 'polling', 'interval', '30000'], obj=db) + print(sys.stderr, result.output) + assert result.exit_code == 2 + assert crm_config_interval_too_big in result.output + + def test_crm_show_thresholds_acl_group(self): runner = CliRunner() db = Db()