From 8ee2dc9b1a7376218538d504f9887e2488a9b869 Mon Sep 17 00:00:00 2001
From: Valentin Rigal <rigal@teklia.com>
Date: Mon, 12 Oct 2020 08:06:22 +0000
Subject: [PATCH] Drop workflow start signal

---
 arkindex/dataimport/models.py                   | 2 ++
 arkindex/dataimport/tests/test_repos.py         | 1 +
 arkindex/dataimport/tests/test_workers.py       | 4 ++++
 arkindex/dataimport/tests/test_workflows_api.py | 1 +
 4 files changed, 8 insertions(+)

diff --git a/arkindex/dataimport/models.py b/arkindex/dataimport/models.py
index 08cc5a506f..f7e7c91106 100644
--- a/arkindex/dataimport/models.py
+++ b/arkindex/dataimport/models.py
@@ -214,6 +214,8 @@ class DataImport(IndexableModel):
     def start(self, chunks=None, thumbnails=False, corpus_id=None):
         self.workflow = self.build_workflow(chunks, thumbnails, corpus_id)
         self.save()
+        # Start the associated workflow
+        self.workflow.start()
 
     def retry(self):
         if self.mode == DataImportMode.Repository and self.revision is not None and not self.revision.repo.enabled:
diff --git a/arkindex/dataimport/tests/test_repos.py b/arkindex/dataimport/tests/test_repos.py
index 7d4966f51a..914feb0659 100644
--- a/arkindex/dataimport/tests/test_repos.py
+++ b/arkindex/dataimport/tests/test_repos.py
@@ -327,6 +327,7 @@ class TestRepositories(FixtureTestCase):
         )
 
         workflow = Workflow.objects.create(recipe=RECIPE)
+        workflow.start()
         task_1, task_2 = workflow.tasks.order_by('slug')
         artifact_1 = task_1.artifacts.create(
             path='path/to/file.tar.zst',
diff --git a/arkindex/dataimport/tests/test_workers.py b/arkindex/dataimport/tests/test_workers.py
index 95df62310a..9ec307e250 100644
--- a/arkindex/dataimport/tests/test_workers.py
+++ b/arkindex/dataimport/tests/test_workers.py
@@ -326,6 +326,7 @@ class TestWorkersWorkerVersions(FixtureAPITestCase):
         self.assertEqual(self.version_1.docker_image, None)
 
         workflow = Workflow.objects.create(recipe=RECIPE)
+        workflow.start()
         task = workflow.tasks.get(slug='first')
         artifact = task.artifacts.create(
             path='path/to/file.json',
@@ -354,6 +355,7 @@ class TestWorkersWorkerVersions(FixtureAPITestCase):
         self.assertEqual(self.version_1.docker_image, None)
 
         workflow = Workflow.objects.create(recipe=RECIPE)
+        workflow.start()
         task = workflow.tasks.get(slug='first')
         artifact = task.artifacts.create(
             path='path/to/file.json',
@@ -397,6 +399,7 @@ class TestWorkersWorkerVersions(FixtureAPITestCase):
 
     def test_update_version_available_docker_image_not_null(self):
         workflow = Workflow.objects.create(recipe=RECIPE)
+        workflow.start()
         task = workflow.tasks.get(slug='first')
         self.version_1.docker_image = task.artifacts.create(
             path='path/to/file.json',
@@ -421,6 +424,7 @@ class TestWorkersWorkerVersions(FixtureAPITestCase):
 
     def test_update_version_available_docker_image_iid_not_null(self):
         workflow = Workflow.objects.create(recipe=RECIPE)
+        workflow.start()
         task = workflow.tasks.get(slug='first')
         self.version_1.docker_image = task.artifacts.create(
             path='path/to/file.json',
diff --git a/arkindex/dataimport/tests/test_workflows_api.py b/arkindex/dataimport/tests/test_workflows_api.py
index b857606e26..5266901032 100644
--- a/arkindex/dataimport/tests/test_workflows_api.py
+++ b/arkindex/dataimport/tests/test_workflows_api.py
@@ -447,6 +447,7 @@ class TestWorkflows(FixtureAPITestCase):
         )
 
         workflow_tmp = Workflow.objects.create(recipe=RECIPE)
+        workflow_tmp.start()
         task_tmp = workflow_tmp.tasks.get(slug='first')
         artifact = task_tmp.artifacts.create(
             path='path/to/file.json',
-- 
GitLab