The jobs module tests (test_jobs.py) verify the job management and scheduling functionality, including environment variable handling and job directory management.
deftest_get_jobid(self,mock_pbs_env):"""Test get_jobid function."""jobid=jobs.get_jobid()assertisinstance(jobid,str)# Should be the job ID without the domain partassertjobid=="12345"
deftest_get_jobdir_from_env(self,mock_pbs_env):"""Test get_jobdir_from_env function."""jobdir=jobs.get_jobdir_from_env()assertisinstance(jobdir,Path)assertjobdir.exists()# Should be in the home directory under SCHEDULER-jobs/jobidassertstr(jobdir).startswith(str(Path.home()))
deftest_jobfile_functions(self,mock_pbs_env):"""Test jobfile path functions."""# Test shell jobfilejobfile_sh=jobs.get_jobfile_sh()assertisinstance(jobfile_sh,Path)assertjobfile_sh.suffix==".sh"# Test yaml jobfilejobfile_yaml=jobs.get_jobfile_yaml()assertisinstance(jobfile_yaml,Path)assertjobfile_yaml.suffix==".yaml"# Test json jobfilejobfile_json=jobs.get_jobfile_json()assertisinstance(jobfile_json,Path)assertjobfile_json.suffix==".json"
deftest_check_scheduler(self):"""Test check_scheduler function."""# Test with valid schedulerassertjobs.check_scheduler("PBS")isTrue# Test with invalid scheduler should raisewithpytest.raises(AssertionError):jobs.check_scheduler("INVALID_SCHEDULER")