Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[crm] add CLI validation for CRM polling interval range #2293

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crm/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
14 changes: 14 additions & 0 deletions tests/crm_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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()
Expand Down