task.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # Licensed to the Apache Software Foundation (ASF) under one
  2. # or more contributor license agreements. See the NOTICE file
  3. # distributed with this work for additional information
  4. # regarding copyright ownership. The ASF licenses this file
  5. # to you under the Apache License, Version 2.0 (the
  6. # "License"); you may not use this file except in compliance
  7. # with the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing,
  12. # software distributed under the License is distributed on an
  13. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  14. # KIND, either express or implied. See the License for the
  15. # specific language governing permissions and limitations
  16. # under the License.
  17. """Mock class Task for other test."""
  18. import uuid
  19. from pydolphinscheduler.core.task import Task as SourceTask
  20. class Task(SourceTask):
  21. """Mock class :class:`pydolphinscheduler.core.task.Task` for unittest."""
  22. DEFAULT_VERSION = 1
  23. def gen_code_and_version(self):
  24. """Mock java gateway code and version, convenience method for unittest."""
  25. return uuid.uuid1().time, self.DEFAULT_VERSION
  26. class TaskWithCode(SourceTask):
  27. """Mock class :class:`pydolphinscheduler.core.task.Task` and it return some code and version."""
  28. def __init__(
  29. self, name: str, task_type: str, code: int, version: int, *args, **kwargs
  30. ):
  31. self._constant_code = code
  32. self._constant_version = version
  33. super().__init__(name, task_type, *args, **kwargs)
  34. def gen_code_and_version(self):
  35. """Mock java gateway code and version, convenience method for unittest."""
  36. return self._constant_code, self._constant_version