16from unittest.mock
import MagicMock
17from clustercontroldrmaa
import Cluster
18from validationscript
import Script
23 Test for for the DRMAA-backend of the clustercontrol
28 Class to mock a DRMAA session
33 Possible DRMAA Job States
44 jobStatusReturn = JobState.RUNNING
47 """ to support python with syntax"""
51 """ to support python with syntax"""
54 """fake creating job template"""
58 """fake job running"""
62 """fake job status terun"""
66 """fake job deletion"""
71 Overwrite drmaa module and see what happens ...
73 sys.modules["drmaa"] =
None
74 self.assertFalse(Cluster.is_supported())
78 Test to submit and monitor a regular job
81 with tempfile.TemporaryDirectory()
as td:
86 drmaa_mock = MagicMock()
87 drmaa_mock.Session = (
92 sys.modules[
"drmaa"] = drmaa_mock
96 self.assertTrue(Cluster.is_supported())
98 job = Script(path=
"myscript1.py", package=
"test_package", log=
None)
104 self.assertTrue(job.job_id)
107 self.assertFalse(cc.is_job_finished(job)[0])
113 self.assertTrue(cc.is_job_finished(job)[0])
118if __name__ ==
"__main__":
def createJobTemplate(self)
JobState jobStatusReturn
the job state this session mock will return
def __exit__(self, exc, value, tb)
def deleteJobTemplate(self, jt)
def test_submit_and_monitor_job(self)