Skip to content

Commit

Permalink
[crm] add checking for CRM interval range
Browse files Browse the repository at this point in the history
Signed-off-by: Andriy Yurkiv <ayurkiv@nvidia.com>
  • Loading branch information
ayurkiv-nvda authored and ayurkiv committed Aug 3, 2022
1 parent 05c79ef commit 88109cf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
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

0 comments on commit 88109cf

Please sign in to comment.