コード例 #1
0
    def test_template_source_is_not_project(self):
        task_template = MagicMock()
        task_template.objects.filter = MagicMock()
        with patch(TASKFLOW_MODEL_TASK_TEMPLATE, task_template):

            taskflow = TaskFlowInstance()
            taskflow.template_source = "common"
            self.assertEqual(taskflow.executor_proxy, None)
            task_template.objects.filter.assert_not_called()

            taskflow = TaskFlowInstance()
            taskflow.template_source = "onetime"
            self.assertEqual(taskflow.executor_proxy, None)
            task_template.objects.filter.assert_not_called()
コード例 #2
0
    def test_normal(self):
        task_template = MagicMock()
        values_list_return = MagicMock()
        values_list_return.first = MagicMock(return_value="dummy")
        _filter_return = MagicMock()
        _filter_return.values_list = MagicMock(return_value=values_list_return)
        _filter = MagicMock(return_value=_filter_return)
        task_template.objects.filter = _filter
        with patch(TASKFLOW_MODEL_TASK_TEMPLATE, task_template):

            taskflow = TaskFlowInstance()
            taskflow.template_source = "project"
            self.assertEqual(taskflow.executor_proxy, "dummy")

            taskflow = TaskFlowInstance()
            taskflow.template_source = "business"
            self.assertEqual(taskflow.executor_proxy, "dummy")