示例#1
0
    def test_add_workload(self, mock_subtask_create, mock_workload):
        mock_subtask_create.return_value = self.subtask
        subtask = objects.Subtask("bar", title="foo")

        name = "w"
        description = "descr"
        position = 0
        runner = {"type": "runner"}
        context = {"users": {}}
        sla = {"failure_rate": {"max": 0}}
        args = {"arg": "xxx"}
        hooks = [{"config": {"foo": "bar"}}]

        workload = subtask.add_workload(name,
                                        description=description,
                                        position=position,
                                        runner=runner,
                                        context=context,
                                        sla=sla,
                                        args=args,
                                        hooks=hooks)
        mock_workload.assert_called_once_with(
            task_uuid=self.subtask["task_uuid"],
            subtask_uuid=self.subtask["uuid"],
            name=name,
            description=description,
            position=position,
            runner=runner,
            context=context,
            sla=sla,
            args=args,
            hooks=hooks)
        self.assertIs(workload, mock_workload.return_value)
示例#2
0
 def test_init(self, mock_subtask_create):
     mock_subtask_create.return_value = self.subtask
     subtask = objects.Subtask("bar", title="foo")
     mock_subtask_create.assert_called_once_with("bar",
                                                 title="foo",
                                                 context=None,
                                                 description=None)
     self.assertEqual(subtask["uuid"], self.subtask["uuid"])
示例#3
0
    def test_add_workload(self, mock_subtask_create, mock_workload):
        mock_subtask_create.return_value = self.subtask
        subtask = objects.Subtask("bar", title="foo")

        workload = subtask.add_workload({"bar": "baz"})
        mock_workload.assert_called_once_with(self.subtask["task_uuid"],
                                              self.subtask["uuid"],
                                              {"bar": "baz"})
        self.assertIs(workload, mock_workload.return_value)
示例#4
0
 def test_update_status(self, mock_subtask_create, mock_subtask_update):
     mock_subtask_create.return_value = self.subtask
     subtask = objects.Subtask("bar", title="foo")
     subtask.update_status(consts.SubtaskStatus.FINISHED)
     mock_subtask_update.assert_called_once_with(
         self.subtask["uuid"], {"status": consts.SubtaskStatus.FINISHED})