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

Python utils.create_test_audit_template函数代码示例

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

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



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

示例1: _data_setup

    def _data_setup(self):
        # All the 1's are soft_deleted and are expired
        # All the 2's are soft_deleted but are not expired
        # All the 3's are *not* soft_deleted

        # Number of days we want to keep in DB (no purge for them)
        self.cmd.age_in_days = 10
        self.cmd.max_number = None
        self.cmd.orphans = True
        gen_name = lambda: "Audit Template %s" % uuid.uuid4()
        self.audit_template1_name = gen_name()
        self.audit_template2_name = gen_name()
        self.audit_template3_name = gen_name()

        with freezegun.freeze_time(self.expired_date):
            self.audit_template1 = obj_utils.create_test_audit_template(
                self.context, name=self.audit_template1_name,
                id=self._generate_id(), uuid=None)
            self.audit_template2 = obj_utils.create_test_audit_template(
                self.context, name=self.audit_template2_name,
                id=self._generate_id(), uuid=None)
            self.audit_template3 = obj_utils.create_test_audit_template(
                self.context, name=self.audit_template3_name,
                id=self._generate_id(), uuid=None)
            self.audit_template1.soft_delete()

        with freezegun.freeze_time(self.expired_date):
            self.audit1 = obj_utils.create_test_audit(
                self.context, audit_template_id=self.audit_template1.id,
                id=self._generate_id(), uuid=None)
            self.audit2 = obj_utils.create_test_audit(
                self.context, audit_template_id=self.audit_template2.id,
                id=self._generate_id(), uuid=None)
            self.audit3 = obj_utils.create_test_audit(
                self.context, audit_template_id=self.audit_template3.id,
                id=self._generate_id(), uuid=None)
            self.audit1.soft_delete()

        with freezegun.freeze_time(self.expired_date):
            self.action_plan1 = obj_utils.create_test_action_plan(
                self.context, audit_id=self.audit1.id,
                id=self._generate_id(), uuid=None)
            self.action_plan2 = obj_utils.create_test_action_plan(
                self.context, audit_id=self.audit2.id,
                id=self._generate_id(), uuid=None)
            self.action_plan3 = obj_utils.create_test_action_plan(
                self.context, audit_id=self.audit3.id,
                id=self._generate_id(), uuid=None)

            self.action1 = obj_utils.create_test_action(
                self.context, action_plan_id=self.action_plan1.id,
                id=self._generate_id(), uuid=None)
            self.action2 = obj_utils.create_test_action(
                self.context, action_plan_id=self.action_plan2.id,
                id=self._generate_id(), uuid=None)
            self.action3 = obj_utils.create_test_action(
                self.context, action_plan_id=self.action_plan3.id,
                id=self._generate_id(), uuid=None)
            self.action_plan1.soft_delete()
开发者ID:Jean-Emile,项目名称:watcher,代码行数:59,代码来源:test_purge.py


示例2: setUp

 def setUp(self):
     super(TestPost, self).setUp()
     obj_utils.create_test_audit_template(self.context)
     p = mock.patch.object(db_api.BaseConnection, 'create_audit')
     self.mock_create_audit = p.start()
     self.mock_create_audit.side_effect = (
         self._simulate_rpc_audit_create)
     self.addCleanup(p.stop)
开发者ID:Oliverlyn,项目名称:watcher,代码行数:8,代码来源:test_audits.py


示例3: test_find_deleted_and_nonexpired_related_entries

    def test_find_deleted_and_nonexpired_related_entries(self):
        with freezegun.freeze_time(self.fake_today):
            # orphan audit template
            audit_template4 = obj_utils.create_test_audit_template(
                self.context, goal_id=404,  # Does not exist
                name=self.generate_unique_name(prefix="Audit Template 4 "),
                strategy_id=None, id=self._generate_id(), uuid=None)
            audit4 = obj_utils.create_test_audit(
                self.context, audit_template_id=audit_template4.id,
                id=self._generate_id(), uuid=None)
            action_plan4 = obj_utils.create_test_action_plan(
                self.context, audit_id=audit4.id,
                id=self._generate_id(), uuid=None)
            action4 = obj_utils.create_test_action(
                self.context, action_plan_id=action_plan4.id,
                id=self._generate_id(), uuid=None)

            audit_template5 = obj_utils.create_test_audit_template(
                self.context, goal_id=self.goal1.id,
                name=self.generate_unique_name(prefix="Audit Template 5 "),
                strategy_id=None, id=self._generate_id(), uuid=None)
            audit5 = obj_utils.create_test_audit(
                self.context, audit_template_id=audit_template5.id,
                id=self._generate_id(), uuid=None)
            action_plan5 = obj_utils.create_test_action_plan(
                self.context, audit_id=audit5.id,
                id=self._generate_id(), uuid=None)
            action5 = obj_utils.create_test_action(
                self.context, action_plan_id=action_plan5.id,
                id=self._generate_id(), uuid=None)

            self.goal2.soft_delete()
            self.strategy2.soft_delete()
            self.audit_template2.soft_delete()
            self.audit2.soft_delete()
            self.action_plan2.soft_delete()

            # All the 4's should be purged as well because they are orphans
            # even though they were not deleted

            # All the 5's should be purged as well even though they are not
            # expired because their related audit template is itself expired
            audit_template5.soft_delete()
            audit5.soft_delete()
            action_plan5.soft_delete()

        with freezegun.freeze_time(self.fake_today):
            objects_map = self.cmd.find_objects_to_delete()

        self.assertEqual(len(objects_map.goals), 1)
        self.assertEqual(len(objects_map.strategies), 1)
        self.assertEqual(len(objects_map.audit_templates), 3)
        self.assertEqual(len(objects_map.audits), 3)
        self.assertEqual(len(objects_map.action_plans), 3)
        self.assertEqual(len(objects_map.actions), 3)
        self.assertEqual(
            set([self.action1.id, action4.id, action5.id]),
            set([entry.id for entry in objects_map.actions]))
开发者ID:Oliverlyn,项目名称:watcher,代码行数:58,代码来源:test_purge.py


示例4: test_links

 def test_links(self):
     uuid = utils.generate_uuid()
     obj_utils.create_test_audit_template(self.context, id=1, uuid=uuid)
     response = self.get_json('/audit_templates/%s' % uuid)
     self.assertIn('links', response.keys())
     self.assertEqual(2, len(response['links']))
     self.assertIn(uuid, response['links'][0]['href'])
     for l in response['links']:
         bookmark = l['rel'] == 'bookmark'
         self.assertTrue(self.validate_link(l['href'], bookmark=bookmark))
开发者ID:XroLLla,项目名称:watcher,代码行数:10,代码来源:test_audit_templates.py


示例5: test_collection_links

    def test_collection_links(self):
        for id_ in range(5):
            obj_utils.create_test_audit_template(
                self.context, id=id_, uuid=utils.generate_uuid(),
                name='My Audit Template {0}'.format(id_))
        response = self.get_json('/audit_templates/?limit=3')
        self.assertEqual(3, len(response['audit_templates']))

        next_marker = response['audit_templates'][-1]['uuid']
        self.assertIn(next_marker, response['next'])
开发者ID:XroLLla,项目名称:watcher,代码行数:10,代码来源:test_audit_templates.py


示例6: test_collection_links_default_limit

    def test_collection_links_default_limit(self):
        cfg.CONF.set_override('max_limit', 3, 'api',
                              enforce_type=True)
        for id_ in range(5):
            obj_utils.create_test_audit_template(
                self.context, id=id_, uuid=utils.generate_uuid(),
                name='My Audit Template {0}'.format(id_))
        response = self.get_json('/audit_templates')
        self.assertEqual(3, len(response['audit_templates']))

        next_marker = response['audit_templates'][-1]['uuid']
        self.assertIn(next_marker, response['next'])
开发者ID:XroLLla,项目名称:watcher,代码行数:12,代码来源:test_audit_templates.py


示例7: test_filter_by_strategy_name

    def test_filter_by_strategy_name(self):
        for id_, strategy_id in enumerate(itertools.chain.from_iterable([
                itertools.repeat(self.fake_strategy1.id, 3),
                itertools.repeat(self.fake_strategy2.id, 2)]), 1):
            obj_utils.create_test_audit_template(
                self.context, id=id_, uuid=utils.generate_uuid(),
                name='My Audit Template {0}'.format(id_),
                strategy_id=strategy_id)

        response = self.get_json(
            '/audit_templates?strategy=%s' % self.fake_strategy2.name)
        self.assertEqual(2, len(response['audit_templates']))
开发者ID:shanling2004,项目名称:watcher,代码行数:12,代码来源:test_audit_templates.py


示例8: setUp

    def setUp(self):
        super(TestDefaultPlanner, self).setUp()
        self.default_planner = pbase.DefaultPlanner()
        obj_utils.create_test_audit_template(self.context)

        p = mock.patch.object(db_api.BaseConnection, "create_action_plan")
        self.mock_create_action_plan = p.start()
        self.mock_create_action_plan.side_effect = self._simulate_action_plan_create
        self.addCleanup(p.stop)

        q = mock.patch.object(db_api.BaseConnection, "create_action")
        self.mock_create_action = q.start()
        self.mock_create_action.side_effect = self._simulate_action_create
        self.addCleanup(q.stop)
开发者ID:XroLLla,项目名称:watcher,代码行数:14,代码来源:test_default_planner.py


示例9: test_filter_by_audit_template_name

    def test_filter_by_audit_template_name(self):
        audit_template_uuid = utils.generate_uuid()
        audit_template_name = 'My_Audit_Template'

        audit_template = obj_utils.create_test_audit_template(
            self.context,
            uuid=audit_template_uuid,
            name=audit_template_name)

        number_of_audits_with_audit_template_id = 5
        for id_ in range(number_of_audits_with_audit_template_id):
            obj_utils.create_test_audit(self.context, id=id_,
                                        uuid=utils.generate_uuid(),
                                        audit_template_id=audit_template.id)
        for id_ in range(6, 8):
            obj_utils.create_test_audit(self.context, id=id_,
                                        uuid=utils.generate_uuid())

        response = self.get_json('/audits/?audit_template=%s'
                                 % audit_template_name)

        audits = response['audits']
        self.assertEqual(5, len(audits))
        for audit in audits:
            self.assertEqual(audit_template_uuid,
                             audit['audit_template_uuid'])
开发者ID:Oliverlyn,项目名称:watcher,代码行数:26,代码来源:test_audits.py


示例10: test_execute_force_basic

    def test_execute_force_basic(self, mock_call):
        expected_strategy = "basic"
        mock_call.return_value = expected_strategy

        obj_utils.create_test_goal(self.context, id=50,
                                   uuid=utils.generate_uuid(),
                                   name="my_goal")

        strategy = obj_utils.create_test_strategy(self.context,
                                                  id=42,
                                                  uuid=utils.generate_uuid(),
                                                  name=expected_strategy)

        audit_template = obj_utils.create_test_audit_template(
            self.context,
            uuid=utils.generate_uuid(),
            strategy_id=strategy.id,
            name="my_template")

        audit = obj_utils.create_test_audit(
            self.context,
            audit_template_id=audit_template.id,
            uuid=utils.generate_uuid(),
        )

        solution = self.strategy_context.execute_strategy(
            audit.uuid, self.context)

        self.assertEqual(solution, expected_strategy)
开发者ID:Oliverlyn,项目名称:watcher,代码行数:29,代码来源:test_strategy_context.py


示例11: test_many_without_soft_deleted

 def test_many_without_soft_deleted(self):
     audit_template_list = []
     for id_ in [1, 2, 3]:
         audit_template = obj_utils.create_test_audit_template(
             self.context, id=id_, uuid=utils.generate_uuid(),
             name='My Audit Template {0}'.format(id_))
         audit_template_list.append(audit_template.uuid)
     for id_ in [4, 5]:
         audit_template = obj_utils.create_test_audit_template(
             self.context, id=id_, uuid=utils.generate_uuid(),
             name='My Audit Template {0}'.format(id_))
         audit_template.soft_delete()
     response = self.get_json('/audit_templates')
     self.assertEqual(3, len(response['audit_templates']))
     uuids = [s['uuid'] for s in response['audit_templates']]
     self.assertEqual(sorted(audit_template_list), sorted(uuids))
开发者ID:XroLLla,项目名称:watcher,代码行数:16,代码来源:test_audit_templates.py


示例12: test_one

 def test_one(self):
     audit_template = obj_utils.create_test_audit_template(
         self.context, strategy_id=self.fake_strategy1.id)
     response = self.get_json('/audit_templates')
     self.assertEqual(audit_template.uuid,
                      response['audit_templates'][0]["uuid"])
     self._assert_audit_template_fields(response['audit_templates'][0])
开发者ID:shanling2004,项目名称:watcher,代码行数:7,代码来源:test_audit_templates.py


示例13: test_policy_disallow_update

 def test_policy_disallow_update(self):
     audit_template = obj_utils.create_test_audit_template(self.context)
     self._common_policy_check(
         "audit_template:update", self.patch_json,
         '/audit_templates/%s' % audit_template.uuid,
         [{'path': '/state', 'value': 'SUBMITTED', 'op': 'replace'}],
         expect_errors=True)
开发者ID:Oliverlyn,项目名称:watcher,代码行数:7,代码来源:test_audit_templates.py


示例14: setUp

 def setUp(self):
     super(TestDefaultAuditHandler, self).setUp()
     self.audit_template = obj_utils.create_test_audit_template(
         self.context)
     self.audit = obj_utils.create_test_audit(
         self.context,
         audit_template_id=self.audit_template.id)
开发者ID:Jean-Emile,项目名称:watcher,代码行数:7,代码来源:test_default_audit_handler.py


示例15: test_execute_force_dummy

    def test_execute_force_dummy(self):
        obj_utils.create_test_goal(self.context, id=50,
                                   uuid=utils.generate_uuid(),
                                   name="my_goal")

        strategy = obj_utils.create_test_strategy(self.context,
                                                  id=42,
                                                  uuid=utils.generate_uuid(),
                                                  name="dummy")

        audit_template = obj_utils.create_test_audit_template(
            self.context,
            uuid=utils.generate_uuid(),
            strategy_id=strategy.id,
            name="my_template")

        audit = obj_utils.create_test_audit(
            self.context,
            audit_template_id=audit_template.id,
            uuid=utils.generate_uuid(),
        )

        solution = self.strategy_context.execute_strategy(
            audit.uuid, self.context)

        self.assertEqual(len(solution.actions), 3)
开发者ID:Oliverlyn,项目名称:watcher,代码行数:26,代码来源:test_strategy_context.py


示例16: setUp

 def setUp(self):
     super(TestAuditEndpoint, self).setUp()
     self.audit_template = obj_utils.create_test_audit_template(
         self.context)
     self.audit = obj_utils.create_test_audit(
         self.context,
         audit_template_id=self.audit_template.id)
开发者ID:Oliverlyn,项目名称:watcher,代码行数:7,代码来源:test_audit_endpoint.py


示例17: setUp

 def setUp(self):
     super(TestStrategyContext, self).setUp()
     obj_utils.create_test_goal(self.context, id=1, name="DUMMY")
     audit_template = obj_utils.create_test_audit_template(
         self.context, uuid=utils.generate_uuid())
     self.audit = obj_utils.create_test_audit(
         self.context, audit_template_id=audit_template.id)
开发者ID:Oliverlyn,项目名称:watcher,代码行数:7,代码来源:test_strategy_context.py


示例18: setUp

 def setUp(self):
     super(TestDefaultAuditHandler, self).setUp()
     obj_utils.create_test_goal(self.context, id=1, name="dummy")
     audit_template = obj_utils.create_test_audit_template(
         self.context)
     self.audit = obj_utils.create_test_audit(
         self.context,
         audit_template_id=audit_template.id)
开发者ID:digambar15,项目名称:watcher,代码行数:8,代码来源:test_default_audit_handler.py


示例19: test_filter_by_goal

    def test_filter_by_goal(self):
        cfg.CONF.set_override('goals', {"DUMMY": "DUMMY", "BASIC": "BASIC"},
                              group='watcher_goals', enforce_type=True)

        for id_ in range(2):
            obj_utils.create_test_audit_template(
                self.context, id=id_, uuid=utils.generate_uuid(),
                name='My Audit Template {0}'.format(id_),
                goal="DUMMY")

        for id_ in range(2, 5):
            obj_utils.create_test_audit_template(
                self.context, id=id_, uuid=utils.generate_uuid(),
                name='My Audit Template {0}'.format(id_),
                goal="BASIC")

        response = self.get_json('/audit_templates?goal=BASIC')
        self.assertEqual(3, len(response['audit_templates']))
开发者ID:XroLLla,项目名称:watcher,代码行数:18,代码来源:test_audit_templates.py


示例20: test_many_by_soft_deleted_audit_template

    def test_many_by_soft_deleted_audit_template(self):
        audit_list = []
        audit_template1 = obj_utils.create_test_audit_template(
            self.context,
            uuid=utils.generate_uuid(),
            name='at1',
            id=3,
        )

        audit_template2 = obj_utils.create_test_audit_template(
            self.context,
            uuid=utils.generate_uuid(),
            name='at2',
            id=4,
        )

        for id_ in range(0, 2):
            audit = obj_utils.create_test_audit(
                self.context, id=id_,
                uuid=utils.generate_uuid(),
                audit_template_id=audit_template1.id)
            audit_list.append(audit.uuid)

        for id_ in range(2, 4):
            audit = obj_utils.create_test_audit(
                self.context, id=id_,
                uuid=utils.generate_uuid(),
                audit_template_id=audit_template2.id)
            audit_list.append(audit.uuid)

        self.delete('/audit_templates/%s' % audit_template1.uuid)

        response = self.get_json('/audits')

        self.assertEqual(len(audit_list), len(response['audits']))

        for id_ in range(0, 2):
            audit = response['audits'][id_]
            self.assertIsNone(audit['audit_template_uuid'])

        for id_ in range(2, 4):
            audit = response['audits'][id_]
            self.assertEqual(audit_template2.uuid,
                             audit['audit_template_uuid'])
开发者ID:Oliverlyn,项目名称:watcher,代码行数:44,代码来源:test_audits.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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