2021-01-05 14:44:31 +00:00
|
|
|
from apiserver.config_repo import config
|
2021-01-05 14:28:49 +00:00
|
|
|
from apiserver.tests.automated import TestService
|
2019-07-08 21:04:26 +00:00
|
|
|
|
|
|
|
log = config.logger(__file__)
|
|
|
|
|
|
|
|
|
|
|
|
class TestTasksDiff(TestService):
|
|
|
|
def setUp(self, version="2.0"):
|
|
|
|
super(TestTasksDiff, self).setUp(version=version)
|
|
|
|
|
|
|
|
def new_task(self, **kwargs):
|
|
|
|
return self.create_temp(
|
|
|
|
"tasks", name="test", type="testing", input=dict(view=dict()), **kwargs
|
|
|
|
)
|
|
|
|
|
2020-06-01 10:07:35 +00:00
|
|
|
def _compare_script(self, task_id, script):
|
|
|
|
task = self.api.tasks.get_by_id(task=task_id).task
|
|
|
|
if not script:
|
2020-08-10 05:45:25 +00:00
|
|
|
self.assertTrue(
|
|
|
|
task.get(
|
|
|
|
"script",
|
|
|
|
dict(
|
|
|
|
binary="python", repository="", entry_point="", requirements={}
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
2020-06-01 10:07:35 +00:00
|
|
|
else:
|
|
|
|
for key, value in script.items():
|
|
|
|
self.assertEqual(task.script[key], value)
|
2019-07-08 21:04:26 +00:00
|
|
|
|
|
|
|
def test_not_deleted(self):
|
|
|
|
task_id = self.new_task()
|
|
|
|
script = dict(
|
|
|
|
requirements=dict(pip=["six"]),
|
|
|
|
repository="https://example.come/foo/bar",
|
|
|
|
entry_point="test.py",
|
|
|
|
diff="foo",
|
|
|
|
)
|
|
|
|
self.api.tasks.edit(task=task_id, script=script)
|
|
|
|
self.api.tasks.started(task=task_id)
|
2020-06-01 10:07:35 +00:00
|
|
|
|
2019-07-08 21:04:26 +00:00
|
|
|
self.api.tasks.reset(task=task_id)
|
2020-06-01 10:07:35 +00:00
|
|
|
self._compare_script(task_id, script)
|
|
|
|
|
2019-07-08 21:04:26 +00:00
|
|
|
new_reqs = dict()
|
|
|
|
self.api.tasks.set_requirements(task=task_id, requirements=new_reqs)
|
|
|
|
script["requirements"] = new_reqs
|
2020-06-01 10:07:35 +00:00
|
|
|
self._compare_script(task_id, script)
|
|
|
|
|
|
|
|
self.api.tasks.reset(task=task_id, clear_all=True)
|
|
|
|
self._compare_script(task_id, {})
|