当前位置: 首页>>代码示例>>Python>>正文


Python CLITest.random_string方法代码示例

本文整理汇总了Python中cli_test.CLITest.random_string方法的典型用法代码示例。如果您正苦于以下问题:Python CLITest.random_string方法的具体用法?Python CLITest.random_string怎么用?Python CLITest.random_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cli_test.CLITest的用法示例。


在下文中一共展示了CLITest.random_string方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_create_metric

# 需要导入模块: from cli_test import CLITest [as 别名]
# 或者: from cli_test.CLITest import random_string [as 别名]
    def test_create_metric(self):
        runner_create = CLIRunner(MetricCreate())
        metric_name = 'METRIC' + CLITest.random_string(6)
        display_name = 'Display Name ' + CLITest.random_string(20)
        display_name_short = 'Short Display Name' + CLITest.random_string(5)
        description = CLITest.random_string(30)
        aggregate = 'avg'
        unit = 'number'
        resolution = 60000
        disabled = False

        create = runner_create.get_output(['-n', metric_name,
                                           '-d', display_name,
                                           '-s', display_name_short,
                                           '-i', description,
                                           '-g', aggregate,
                                           '-r', str(resolution),
                                           '-u', unit,
                                           '-x', str(disabled).lower()])
        metric_create = json.loads(create)
        metric = metric_create['result']

        self.assertEqual(metric_name, metric['name'])
        self.assertEqual(display_name, metric['displayName'])
        self.assertEqual(display_name_short, metric['displayNameShort'])
        self.assertFalse(metric['isDisabled'])
        self.assertEqual(unit, metric['unit'])
        self.assertEqual(aggregate.upper(), metric['defaultAggregate'])
        self.assertEqual(resolution, int(metric['defaultResolutionMS']))
        self.assertEqual(description, metric['description'])

        runner_delete = CLIRunner(MetricDelete())
        delete = runner_delete.get_output(['-n', metric_name])
开发者ID:boundary,项目名称:pulse-api-cli,代码行数:35,代码来源:metric_create_test.py

示例2: test_update_alarm

# 需要导入模块: from cli_test import CLITest [as 别名]
# 或者: from cli_test.CLITest import random_string [as 别名]
    def test_update_alarm(self):
        alarm_name = 'my-alarm-' + CLITest.random_string(6)
        metric_name = 'CPU'
        note = CLITest.random_string(50)
        aggregate = 'max'
        op = 'gt'
        value = 0.75
        trigger_interval = 900000
        is_disabled = True
        runner_create = CLIRunner(AlarmCreate())
        create = runner_create.get_output(['-n', alarm_name,
                                           '-m', metric_name,
                                           '-d', note,
                                           '-g', aggregate,
                                           '-o', op,
                                           '-v', str(value),
                                           '-r', str(trigger_interval),
                                           '-x', str(is_disabled).lower()])
        alarm_create = json.loads(create)

        note = CLITest.random_string(50)
        aggregate = 'max'
        op = 'gt'
        value = 0.75
        trigger_interval = 300000
        is_disabled = False

        runner_update = CLIRunner(AlarmUpdate())
        update = runner_update.get_output(['-i', str(int(alarm_create['id'])),
                                           '-n', alarm_name,
                                           '-m', metric_name,
                                           '-d', note,
                                           '-g', aggregate,
                                           '-o', op,
                                           '-v', str(value),
                                           '-r', str(trigger_interval),
                                           '-x', str(is_disabled).lower()])
        alarm = json.loads(update)

        self.assertEqual(trigger_interval, alarm['triggerInterval'])
        self.assertEqual(1, alarm['familyId'])
        self.assertFalse(is_disabled, alarm['isDisabled'])
        self.assertEqual(metric_name, alarm['metric'])
        self.assertEqual(alarm_name, alarm['name'])
        self.assertEqual(aggregate, alarm['triggerPredicate']['agg'])
        self.assertEqual(op, alarm['triggerPredicate']['op'])
        self.assertEqual(value, alarm['triggerPredicate']['val'])
        self.assertEqual(3, int(alarm['typeId']))
        self.assertEqual(note, alarm['note'])

        runner_delete = CLIRunner(AlarmDelete())
        delete = runner_delete.get_output(['-i', str(alarm['id'])])
开发者ID:boundary,项目名称:pulse-api-cli,代码行数:54,代码来源:alarm_update_test.py

示例3: test_api_call

# 需要导入模块: from cli_test import CLITest [as 别名]
# 或者: from cli_test.CLITest import random_string [as 别名]
    def test_api_call(self):
        api = API()
        name = 'ALARM_DELETE_API_TEST' + CLITest.random_string(6)
        metric = 'CPU'
        trigger_interval = 60000
        aggregate = 'sum'
        operation = 'gt'
        threshold = '0.80'
        note = CLITest.random_string(20)
        alarm = api.alarm_create(name=name,
                                 metric=metric,
                                 trigger_interval=trigger_interval,
                                 aggregate=aggregate,
                                 operation=operation,
                                 threshold=threshold,
                                 note=note)

        self.api.alarm_delete(id=alarm.id)
开发者ID:boundary,项目名称:pulse-api-cli,代码行数:20,代码来源:alarm_delete_test.py

示例4: test_delete_alarm

# 需要导入模块: from cli_test import CLITest [as 别名]
# 或者: from cli_test.CLITest import random_string [as 别名]
    def test_delete_alarm(self):
        name = 'ALARM_DELETE_TEST' + CLITest.random_string(6)
        metric = 'CPU'
        trigger_interval = 60000
        aggregate = 'sum'
        operation = 'gt'
        threshold = '0.80'
        note = CLITest.random_string(20)

        runner_create = CLIRunner(AlarmCreate())
        create = runner_create.get_output(['-n', name,
                                           '-m', metric,
                                           '-g', aggregate,
                                           '-o', operation,
                                           '-v', str(threshold),
                                           '-r', str(trigger_interval),
                                           '-d', note])
        alarm = json.loads(create)
        runner_delete = CLIRunner(AlarmDelete())
        delete = runner_delete.get_output(['-i', str(alarm['id'])])
开发者ID:boundary,项目名称:pulse-api-cli,代码行数:22,代码来源:alarm_delete_test.py

示例5: test_api_call

# 需要导入模块: from cli_test import CLITest [as 别名]
# 或者: from cli_test.CLITest import random_string [as 别名]
    def test_api_call(self):
        aggregate = 'sum'
        trigger_interval = 60
        is_disabled = True
        metric_name = 'CPU'
        note = 'This is a note'
        alarm_name = 'ALARM_CREATE_TEST' + CLITest.random_string(4)
        operation = 'gt'
        per_host_modify = True
        threshold = '0.80'
        alarm_create = self.api.alarm_create(aggregate=aggregate,
                                             trigger_interval=trigger_interval,
                                             is_disabled=is_disabled,
                                             metric_name=metric_name,
                                             name=alarm_name,
                                             note=note,
                                             operation=operation,
                                             per_host_modify=per_host_modify,
                                             threshold=threshold)

        aggregate = 'avg'
        trigger_interval = 3600000
        is_disabled = False
        metric_name = 'CPU'
        note = 'This is a updated note'
        operation = 'lt'
        per_host_modify = True
        threshold = '0.50'

        alarm_update = self.api.alarm_update(id=alarm_create.id,
                                             aggregate=aggregate,
                                             trigger_interval=trigger_interval,
                                             is_disabled=is_disabled,
                                             metric_name=metric_name,
                                             name=alarm_name,
                                             note=note,
                                             operation=operation,
                                             per_host_modify=per_host_modify,
                                             threshold=threshold)

        self.assertEqual(aggregate, alarm_update.aggregate)
        self.assertEqual(trigger_interval, alarm_update.trigger_interval)
        self.assertEqual(is_disabled, alarm_update.is_disabled)
        self.assertEqual(metric_name, alarm_update.metric_name)
        self.assertEqual(alarm_name, alarm_update.name)
        self.assertEqual(note, alarm_update.note)
        self.assertEqual(operation, alarm_update.operation)
        self.assertEqual(per_host_modify, alarm_update.per_host_modify)
        self.assertEqual(threshold, alarm_update.threshold)

        self.api.alarm_delete(id=alarm_create.id)
开发者ID:boundary,项目名称:pulse-api-cli,代码行数:53,代码来源:alarm_update_test.py

示例6: test_search_alarm

# 需要导入模块: from cli_test import CLITest [as 别名]
# 或者: from cli_test.CLITest import random_string [as 别名]
    def test_search_alarm(self):
        alarm_name = 'alarm_test' + CLITest.random_string(6)
        metric_name = 'CPU'
        aggregate = 'max'
        op = 'gt'
        value = 0.50
        trigger_interval = 300000
        note = CLITest.random_string(20)
        enabled = True
        runner_create = CLIRunner(AlarmCreate())

        create = runner_create.get_output(['-n', alarm_name,
                                           '-m', metric_name,
                                           '-g', aggregate,
                                           '-o', op,
                                           '-v', str(value),
                                           '-r', str(trigger_interval),
                                           '-d', note,
                                           '-x', str(enabled).lower()])

        runner_search = CLIRunner(AlarmSearch())
        search = runner_search.get_output(['-n', alarm_name])
        result_search = json.loads(search)
        alarm = result_search['result'][0]
        self.assertEqual(trigger_interval, alarm['interval'])
        self.assertItemsEqual([], alarm['actions'])
        self.assertEqual(1, int(alarm['familyId']))
        self.assertFalse(False, alarm['isDisabled'])
        self.assertEqual(metric_name, alarm['metric'])
        self.assertEqual(alarm_name, alarm['name'])
        self.assertTrue(alarm['perHostNotify'])
        self.assertEqual(aggregate, alarm['triggerPredicate']['agg'])
        self.assertEqual(op, alarm['triggerPredicate']['op'])
        self.assertEqual(value, alarm['triggerPredicate']['val'])
        self.assertEqual(3, int(alarm['typeId']))

        runner_delete = CLIRunner(AlarmDelete())
        delete = runner_delete.get_output(['-i', str(alarm['id'])])
开发者ID:boundary,项目名称:pulse-api-cli,代码行数:40,代码来源:alarm_search_test.py

示例7: test_delete_metric

# 需要导入模块: from cli_test import CLITest [as 别名]
# 或者: from cli_test.CLITest import random_string [as 别名]
    def test_delete_metric(self):
        runner_create = CLIRunner(MetricCreate())
        metric_name = 'METRIC' + CLITest.random_string(6)
        display_name = 'Display Name ' + CLITest.random_string(20)
        display_name_short = 'Short Display Name' + CLITest.random_string(5)
        description = CLITest.random_string(30)
        aggregate = 'avg'
        unit = 'number'
        resolution = 60000
        disabled = False

        create = runner_create.get_output(['-n', metric_name,
                                           '-d', display_name,
                                           '-s', display_name_short,
                                           '-i', description,
                                           '-g', aggregate,
                                           '-r', str(resolution),
                                           '-u', unit,
                                           '-x', str(disabled).lower()])
        metric_create = json.loads(create)
        metric = metric_create['result']

        runner_delete = CLIRunner(MetricDelete())
        delete = runner_delete.get_output(['-n', metric_name])
开发者ID:boundary,项目名称:pulse-api-cli,代码行数:26,代码来源:metric_delete_test.py

示例8: test_create_filter

# 需要导入模块: from cli_test import CLITest [as 别名]
# 或者: from cli_test.CLITest import random_string [as 别名]
    def test_create_filter(self):
        runner_create = CLIRunner(HostgroupCreate())
        filter_name = 'Filter' + CLITest.random_string(6)
        sources = 'foo,bar,red,green'

        create = runner_create.get_output(['-n', filter_name,
                                           '-s', sources])
        filter_create = json.loads(create)
        filter = filter_create['result']

        self.assertEqual(filter_name, filter['name'])
        self.assertItemsEqual(split(sources, ','), filter['hostnames'])

        filter_id = filter['id']

        runner_delete = CLIRunner(HostgroupDelete())
        delete = runner_delete.get_output(['-i', str(filter_id)])
        delete_result = json.loads(delete)
        self.assertTrue(delete_result['result']['success'])
开发者ID:boundary,项目名称:pulse-api-cli,代码行数:21,代码来源:hostgroup_create_test.py


注:本文中的cli_test.CLITest.random_string方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。