Ejemplo n.º 1
0
 def test_delete_workload_failure(self) -> None:
     """Test workload deletion - error due to exception."""
     with patch("os.path.isfile") as fake_isfile, patch(
             "shutil.rmtree", ) as fake_rmtree, patch.object(
                 Workdir, "load", autospec=True) as fake_load, patch.object(
                     Workdir,
                     "dump",
                 ) as fake_dump, self.assertRaises(InternalException, ):
         fake_isfile.return_value = True
         fake_rmtree.side_effect = _fake_raise_exception_mock
         fake_load.side_effect = _fake_load_mock
         fake_dump.return_value = None
         workdir = Workdir(workspace_path="/tmp/lpot")
         workdir.delete_workload("workload_1")
Ejemplo n.º 2
0
 def test_delete_workload_success(self) -> None:
     """Test workload deletion - success."""
     with patch("os.path.isfile") as fake_isfile, patch(
             "shutil.rmtree", ) as fake_rmtree, patch.object(
                 Workdir, "load", autospec=True) as fake_load, patch.object(
                     Workdir,
                     "dump",
                 ) as fake_dump:
         fake_isfile.return_value = True
         fake_rmtree.return_value = None
         fake_load.side_effect = _fake_load_mock
         fake_dump.return_value = None
         workdir = Workdir(workspace_path="/tmp/lpot")
         workdir.delete_workload("workload_1")
         self.assertNotIn("workload_1",
                          workdir.workloads_data.get("workloads", {}))
         self.assertIn("workload_2",
                       workdir.workloads_data.get("workloads", {}))
Ejemplo n.º 3
0
def delete_workload(data: dict) -> Dict[str, Any]:
    """Delete workload based on ID."""
    workdir = Workdir(workspace_path=os.environ["HOME"])
    workdir.delete_workload(data["request_id"])
    return {"message": "SUCCESS"}