• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python parser.simple_parse函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中senlin.engine.parser.simple_parse函数的典型用法代码示例。如果您正苦于以下问题:Python simple_parse函数的具体用法?Python simple_parse怎么用?Python simple_parse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_action_get_project_safe

 def test_action_get_project_safe(self):
     parser.simple_parse(shared.sample_action)
     action = _create_action(self.ctx)
     new_ctx = utils.dummy_context(project='another-project')
     retobj = db_api.action_get(new_ctx, action.id, project_safe=True)
     self.assertIsNone(retobj)
     retobj = db_api.action_get(new_ctx, action.id, project_safe=False)
     self.assertIsNotNone(retobj)
开发者ID:jonnary,项目名称:senlin,代码行数:8,代码来源:test_action_api.py


示例2: test_load

    def test_load(self):
        timestamp = timeutils.utcnow()
        spec = parser.simple_parse(sample_trigger)
        db_trigger = self._create_db_trigger('FAKE_ID',
                                             created_time=timestamp,
                                             updated_time=timestamp)

        self.assertIsNotNone(db_trigger)
        res = base.Trigger.load(self.ctx, trigger_id=db_trigger.id)

        self.assertIsInstance(res, base.Trigger)
        self.assertEqual('FAKE_ID', res.id)
        self.assertEqual('test-trigger', res.name)
        self.assertEqual('FakeTriggerType', res.type_name)
        self.assertEqual('blah blah', res.desc)
        self.assertEqual(base.INSUFFICIENT_DATA, res.state)
        self.assertTrue(res.enabled)
        self.assertEqual(base.S_CRITICAL, res.severity)
        self.assertEqual({'alarm_actions': ['http://url1']}, res.links)
        self.assertEqual(timestamp, res.created_time)
        self.assertEqual(timestamp, res.updated_time)
        self.assertIsNone(res.deleted_time)

        self.assertEqual(spec, res.spec)
        self.assertEqual(spec['type'], res.spec_data['type'])
        self.assertEqual(str(spec['version']), res.spec_data['version'])
        self.assertEqual(spec['rule'], res.spec_data['rule'])

        # load trigger via db trigger object
        res = base.Trigger.load(self.ctx, db_trigger=db_trigger)
        self.assertIsInstance(res, base.Trigger)
        self.assertEqual('FAKE_ID', res.id)
开发者ID:KongJustin,项目名称:senlin,代码行数:32,代码来源:test_trigger_base.py


示例3: _create_action

def _create_action(context, action_json=shared.sample_action, **kwargs):
    data = parser.simple_parse(action_json)
    data['user'] = context.user
    data['project'] = context.project
    data['domain'] = context.domain
    data.update(kwargs)
    return db_api.action_create(context, data)
开发者ID:jonnary,项目名称:senlin,代码行数:7,代码来源:test_action_api.py


示例4: test_trigger_list_with_limit_marker

    def test_trigger_list_with_limit_marker(self):
        spec = parser.simple_parse(trigger_spec)
        t1 = self.eng.trigger_create(self.ctx, 't-1', spec)
        t2 = self.eng.trigger_create(self.ctx, 't-2', spec)

        result = self.eng.trigger_list(self.ctx, limit=0)

        self.assertEqual(0, len(result))
        result = self.eng.trigger_list(self.ctx, limit=1)
        self.assertEqual(1, len(result))
        result = self.eng.trigger_list(self.ctx, limit=2)
        self.assertEqual(2, len(result))
        result = self.eng.trigger_list(self.ctx, limit=3)
        self.assertEqual(2, len(result))

        result = self.eng.trigger_list(self.ctx, marker=t1['id'])
        self.assertEqual(1, len(result))
        result = self.eng.trigger_list(self.ctx, marker=t2['id'])
        self.assertEqual(0, len(result))

        self.eng.trigger_create(self.ctx, 't-3', spec)
        result = self.eng.trigger_list(self.ctx, limit=1, marker=t1['id'])
        self.assertEqual(1, len(result))
        result = self.eng.trigger_list(self.ctx, limit=2, marker=t1['id'])
        self.assertEqual(2, len(result))
开发者ID:KongJustin,项目名称:senlin,代码行数:25,代码来源:test_triggers.py


示例5: test_trigger_create_invalid_spec

 def test_trigger_create_invalid_spec(self):
     spec = parser.simple_parse(trigger_spec)
     spec['KEY3'] = 'value3'
     ex = self.assertRaises(rpc.ExpectedException,
                            self.eng.trigger_create,
                            self.ctx, 't-1', spec)
     self.assertEqual(exception.SpecValidationFailed, ex.exc_info[0])
开发者ID:KongJustin,项目名称:senlin,代码行数:7,代码来源:test_triggers.py


示例6: test_profile_create

 def test_profile_create(self):
     data = parser.simple_parse(shared.sample_profile)
     profile = shared.create_profile(self.ctx)
     self.assertIsNotNone(profile.id)
     self.assertEqual(data['name'], profile.name)
     self.assertEqual(data['type'], profile.type)
     self.assertEqual(data['spec'], profile.spec)
开发者ID:jonnary,项目名称:senlin,代码行数:7,代码来源:test_profile_api.py


示例7: test_trigger_list_with_sort_keys

    def test_trigger_list_with_sort_keys(self):
        spec = parser.simple_parse(trigger_spec)
        t1 = self.eng.trigger_create(self.ctx, 'TB', spec, severity='low')
        t2 = self.eng.trigger_create(self.ctx, 'TA', spec, severity='low')
        t3 = self.eng.trigger_create(self.ctx, 'TC', spec, severity='high')

        # default by created_time
        result = self.eng.trigger_list(self.ctx)
        self.assertEqual(t1['id'], result[0]['id'])
        self.assertEqual(t2['id'], result[1]['id'])

        # use name for sorting
        result = self.eng.trigger_list(self.ctx, sort_keys=['name'])
        self.assertEqual(t2['id'], result[0]['id'])
        self.assertEqual(t1['id'], result[1]['id'])

        # use permission for sorting
        result = self.eng.trigger_list(self.ctx, sort_keys=['severity'])
        self.assertEqual(t3['id'], result[0]['id'])

        # use name and permission for sorting
        result = self.eng.trigger_list(self.ctx,
                                       sort_keys=['severity', 'name'])
        self.assertEqual(t3['id'], result[0]['id'])
        self.assertEqual(t2['id'], result[1]['id'])
        self.assertEqual(t1['id'], result[2]['id'])

        # unknown keys will be ignored
        result = self.eng.trigger_list(self.ctx, sort_keys=['duang'])
        self.assertIsNotNone(result)
开发者ID:KongJustin,项目名称:senlin,代码行数:30,代码来源:test_triggers.py


示例8: test_trigger_list_with_sort_dir

    def test_trigger_list_with_sort_dir(self):
        spec = parser.simple_parse(trigger_spec)
        t1 = self.eng.trigger_create(self.ctx, 'TB', spec, severity='low')
        t2 = self.eng.trigger_create(self.ctx, 'TA', spec, severity='low')
        t3 = self.eng.trigger_create(self.ctx, 'TC', spec, severity='high')

        # default by created_time, ascending
        result = self.eng.trigger_list(self.ctx)
        self.assertEqual(t1['id'], result[0]['id'])
        self.assertEqual(t2['id'], result[1]['id'])

        # sort by created_time, descending
        result = self.eng.trigger_list(self.ctx, sort_dir='desc')
        self.assertEqual(t3['id'], result[0]['id'])
        self.assertEqual(t2['id'], result[1]['id'])

        # use name for sorting, descending
        result = self.eng.trigger_list(self.ctx, sort_keys=['name'],
                                       sort_dir='desc')
        self.assertEqual(t3['id'], result[0]['id'])
        self.assertEqual(t1['id'], result[1]['id'])

        ex = self.assertRaises(ValueError,
                               self.eng.trigger_list, self.ctx,
                               sort_dir='Bogus')
        self.assertEqual("Unknown sort direction, must be one of: "
                         "asc-nullsfirst, asc-nullslast, desc-nullsfirst, "
                         "desc-nullslast", six.text_type(ex))
开发者ID:KongJustin,项目名称:senlin,代码行数:28,代码来源:test_triggers.py


示例9: test_to_dict

    def test_to_dict(self):
        spec = parser.simple_parse(sample_trigger)
        trigger = base.Trigger('t1', spec, id='FAKE_ID', desc='DESC',
                               user=self.ctx.user, project=self.ctx.project,
                               domain=self.ctx.domain)

        expected = {
            'id': 'FAKE_ID',
            'name': 't1',
            'type': 'FakeTriggerType',
            'desc': 'DESC',
            'state': base.INSUFFICIENT_DATA,
            'enabled': True,
            'severity': base.S_LOW,
            'links': {},
            'spec': spec,
            'user': self.ctx.user,
            'project': self.ctx.project,
            'domain': self.ctx.domain,
            'created_time': None,
            'updated_time': None,
            'deleted_time': None
        }

        res = trigger.to_dict()

        self.assertEqual(expected, res)
开发者ID:KongJustin,项目名称:senlin,代码行数:27,代码来源:test_trigger_base.py


示例10: create_profile

def create_profile(context, profile=sample_profile, **kwargs):
    data = parser.simple_parse(profile)
    data['user'] = context.user
    data['project'] = context.project
    data['domain'] = context.domain
    data.update(kwargs)
    return db_api.profile_create(context, data)
开发者ID:jonnary,项目名称:senlin,代码行数:7,代码来源:shared.py


示例11: test_trigger_create_type_not_found

 def test_trigger_create_type_not_found(self):
     spec = parser.simple_parse(trigger_spec)
     spec['type'] = 'Bogus'
     ex = self.assertRaises(rpc.ExpectedException,
                            self.eng.trigger_create,
                            self.ctx, 't-1', spec)
     self.assertEqual(exception.TriggerTypeNotFound, ex.exc_info[0])
开发者ID:KongJustin,项目名称:senlin,代码行数:7,代码来源:test_triggers.py


示例12: test_profile_create

 def test_profile_create(self):
     data = parser.simple_parse(shared.sample_profile)
     profile = shared.create_profile(self.ctx)
     self.assertIsNotNone(profile.id)
     self.assertEqual(data["name"], profile.name)
     self.assertEqual(data["type"], profile.type)
     self.assertEqual(data["spec"], profile.spec)
     self.assertEqual(data["permission"], profile.permission)
开发者ID:MountainWei,项目名称:senlin,代码行数:8,代码来源:test_profile_api.py


示例13: test_trigger_create_failed_validation

 def test_trigger_create_failed_validation(self):
     spec = parser.simple_parse(trigger_spec)
     self.patchobject(fakes.TestTrigger, 'validate',
                      side_effect=exception.InvalidSpec(message='BOOM'))
     ex = self.assertRaises(rpc.ExpectedException,
                            self.eng.trigger_create,
                            self.ctx, 't1', spec)
     self.assertEqual(exception.InvalidSpec, ex.exc_info[0])
开发者ID:KongJustin,项目名称:senlin,代码行数:8,代码来源:test_triggers.py


示例14: test_validate_illegal_tc_timezone

    def test_validate_illegal_tc_timezone(self):
        spec = parser.simple_parse(threshold_alarm)
        spec["time_constraints"][0]["timezone"] = "Moon/Back"
        a = alarm.Alarm("A1", spec)

        ex = self.assertRaises(exc.InvalidSpec, a.validate)
        expected = "Invalid timezone value specified for property 'timezone' " "(Moon/Back): 'Moon/Back'"
        self.assertEqual(expected, six.text_type(ex))
开发者ID:KongJustin,项目名称:senlin,代码行数:8,代码来源:test_ceilo_alarm.py


示例15: test_combination_alarm

    def test_combination_alarm(self):
        spec = parser.simple_parse(combination_alarm)
        a = alarm.CombinationAlarm('A1', spec)

        self.assertIsNotNone(a.rule)
        self.assertEqual('combination', a.namespace)
        self.assertEqual('and', a.rule['operator'])
        self.assertIn('alarm_001', a.rule['alarm_ids'])
        self.assertIn('alarm_001', a.rule['alarm_ids'])
开发者ID:Alzon,项目名称:senlin,代码行数:9,代码来源:test_ceilo_alarm.py


示例16: test_validate_illegal_tc_start

    def test_validate_illegal_tc_start(self):
        spec = parser.simple_parse(threshold_alarm)
        spec['time_constraints'][0]['start'] = 'XYZ'
        a = alarm.Alarm('A1', spec)

        ex = self.assertRaises(exc.InvalidSpec, a.validate)
        expected = ("Invalid cron expression specified for property 'start' "
                    "(XYZ): Exactly 5 or 6 columns has to be specified for "
                    "iteratorexpression.")
        self.assertEqual(expected, six.text_type(ex))
开发者ID:Alzon,项目名称:senlin,代码行数:10,代码来源:test_ceilo_alarm.py


示例17: test_trigger_delete

    def test_trigger_delete(self):
        spec = parser.simple_parse(trigger_spec)
        t1 = self.eng.trigger_create(self.ctx, 'T1', spec)
        tid = t1['id']
        result = self.eng.trigger_delete(self.ctx, tid)
        self.assertIsNone(result)

        ex = self.assertRaises(rpc.ExpectedException,
                               self.eng.trigger_get, self.ctx, tid)

        self.assertEqual(exception.TriggerNotFound, ex.exc_info[0])
开发者ID:KongJustin,项目名称:senlin,代码行数:11,代码来源:test_triggers.py


示例18: test_store_for_create

    def test_store_for_create(self):
        spec = parser.simple_parse(sample_trigger)
        trigger = base.Trigger('t1', spec)
        trigger_id = trigger.store(self.ctx)

        res = base.Trigger.load(self.ctx, trigger_id)
        self.assertIsNotNone(res)
        self.assertIsNotNone(res.id)
        self.assertIsNotNone(res.created_time)
        self.assertIsNone(res.updated_time)
        self.assertIsNone(res.deleted_time)
开发者ID:KongJustin,项目名称:senlin,代码行数:11,代码来源:test_trigger_base.py


示例19: test_create_with_failure

    def test_create_with_failure(self, mock_senlindriver):
        cc = mock.Mock()
        sd = mock.Mock()
        sd.telemetry.return_value = cc
        mock_senlindriver.return_value = sd
        cc.alarm_create.side_effect = exc.ResourceCreationFailure(rtype="Alarm")
        spec = parser.simple_parse(threshold_alarm)
        a = alarm.ThresholdAlarm("A1", spec)
        res, reason = a.create(self.ctx)

        self.assertFalse(res)
        self.assertEqual("Failed in creating Alarm.", reason)
开发者ID:KongJustin,项目名称:senlin,代码行数:12,代码来源:test_ceilo_alarm.py


示例20: test_trigger_create_with_parameters

 def test_trigger_create_with_parameters(self):
     spec = parser.simple_parse(trigger_spec)
     result = self.eng.trigger_create(self.ctx, 't-1', spec,
                                      description='DESC',
                                      enabled=False,
                                      state='OK',
                                      severity='high')
     self.assertEqual(spec, result['spec'])
     self.assertEqual('DESC', result['desc'])
     self.assertFalse(result['enabled'])
     self.assertEqual('OK', result['state'])
     self.assertEqual('high', result['severity'])
开发者ID:KongJustin,项目名称:senlin,代码行数:12,代码来源:test_triggers.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.create_a_profile函数代码示例发布时间:2022-05-27
下一篇:
Python environment.global_env函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap