9 from unittest.mock
import MagicMock
10 from clustercontroldrmaa
import Cluster
11 from validationscript
import Script
16 Test for for the DRMAA-backend of the clustercontrol
20 Class to mock a DRMAA session
25 Possible DRMAA Job States
35 jobStatusReturn = JobState.RUNNING
38 """ to support python with syntax"""
42 """ to support python with syntax"""
46 """fake creating job template"""
50 """fake job running"""
54 """fake job status terun"""
58 """fake job deletion"""
63 Overwrite drmaa module and see what happens ...
65 sys.modules[
'drmaa'] =
None
66 self.assertFalse(Cluster.is_supported())
70 Test to submit and monitor a regular job
73 with tempfile.TemporaryDirectory()
as td:
78 drmaa_mock = MagicMock()
82 sys.modules[
'drmaa'] = drmaa_mock
86 self.assertTrue(Cluster.is_supported())
88 job = Script(path=
"myscript1.py", package=
"test_package", log=
None)
94 self.assertTrue(job.job_id)
97 self.assertFalse(cc.is_job_finished(job)[0])
103 self.assertTrue(cc.is_job_finished(job)[0])
108 if __name__ ==
"__main__":