示例#1
0
 def test_cleanup(self, mock_cleanup):
     audit_templates_mocks = [mock.Mock() for i in range(2)]
     self.context.update({
         "admin": {
             "credential": mock.MagicMock()
         },
         "audit_templates": audit_templates_mocks
     })
     audit_templates_ctx = audit_templates.AuditTemplateGenerator(
         self.context)
     audit_templates_ctx.cleanup()
     mock_cleanup.assert_called_once_with(
         names=["watcher.action_plan", "watcher.audit_template"],
         admin=self.context["admin"])
示例#2
0
    def test_setup(self, mock_osclients, mock_watcher_goal_transform,
                   mock_watcher_strategy_transform,
                   mock_watcher_scenario__create_audit_template):

        users = [{"id": 1, "tenant_id": 1, "credential": mock.MagicMock()}]
        self.context.update({
            "config": {
                "audit_templates": {
                    "audit_templates_per_admin":
                    1,
                    "fill_strategy":
                    "random",
                    "params": [{
                        "goal": {
                            "name": "workload_balancing"
                        },
                        "strategy": {
                            "name": "workload_stabilization"
                        },
                        "extra": {}
                    }, {
                        "goal": {
                            "name": "workload_balancing"
                        },
                        "strategy": {
                            "name": "workload_stabilization"
                        },
                        "extra": {}
                    }]
                },
            },
            "admin": {
                "credential": mock.MagicMock()
            },
            "users": users
        })
        audit_template = audit_templates.AuditTemplateGenerator(self.context)
        audit_template.setup()
        goal_id = mock_watcher_goal_transform.return_value
        strategy_id = mock_watcher_strategy_transform.return_value
        mock_calls = [mock.call(goal_id, strategy_id, {})]
        mock_watcher_scenario__create_audit_template.assert_has_calls(
            mock_calls)