Skip to content
Snippets Groups Projects
Commit cdb43fee authored by Charlotte Hausman's avatar Charlotte Hausman
Browse files

fix tests

parent 4d6cb932
No related branches found
No related tags found
1 merge request!1299catch the case where directory no longer exists
Pipeline #9356 passed
This commit is part of merge request !1299. Comments created here will be created in the context of that merge request.
......@@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with Workspaces. If not, see <https://www.gnu.org/licenses/>.
from datetime import datetime
from unittest.mock import patch
from unittest.mock import patch, MagicMock
from test.test_workflow_info import FakeWorkflowInfo
from workspaces.system.schema import AbstractFile
......@@ -92,6 +92,7 @@ class TestCapoInjector:
@patch("pathlib.Path.unlink")
@patch("glob.glob")
@patch("os.listdir")
@patch("pathlib.Path.exists", MagicMock(return_value=True))
def test_clear_subspace(self, mock_os, mock_glob, mock_remove):
injector.clear_subspace()
assert mock_os.call_count == 1
......
......@@ -115,7 +115,7 @@ class CapoInjector:
path.write_bytes(subspace.content)
logger.info(f"Writing capo subspace file to {self.dir_path.__str__()}")
def clear_subspace(self):
def clear_subspace(self) -> bool:
logger.info(f"Clearing capo subspace file from {self.dir_path.__str__()}...")
if self.dir_path.exists():
for file in os.listdir(self.dir_path):
......@@ -125,5 +125,7 @@ class CapoInjector:
check = glob.glob("*.properties")
if check is None:
logger.info("Capo subspace cleared successfully.")
return True
else:
logger.info(f"Directory {self.dir_path} has already been cleaned.")
logger.info(f"Directory {self.dir_path.__str__()} has already been cleaned.")
return False
......@@ -1141,7 +1141,10 @@ class WorkflowMessageHandler:
if injector.is_remote_workflow():
logger.debug("Cleaning remote workflow")
injector.clear_subspace()
result = injector.clear_subspace()
if result is False:
# the processing directory somehow disappeared, mark as cleaned to avoid further errors
request.cleaned = True
@staticmethod
def clean_workflow(request: WorkflowRequest):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment