Skip to content

Commit

Permalink
Merge pull request #1327 from pyiron/test_remove_job
Browse files Browse the repository at this point in the history
Add test for remove_job and remove additional query for job_id
  • Loading branch information
jan-janssen authored Feb 14, 2024
2 parents 43d5c0f + c171907 commit e1c0861
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 1 addition & 2 deletions pyiron_base/project/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1202,8 +1202,7 @@ def remove_job(self, job_specifier, _unprotect=False):
state.logger.debug(
"hdf file does not exist. Removal from database will be attempted."
)
job_id = self.get_job_id(job_specifier)
self.db.delete_item(job_id)
self.db.delete_item(job.job_id)
else:
raise EnvironmentError("copy_to: is not available in Viewermode !")

Expand Down
12 changes: 12 additions & 0 deletions tests/job/test_genericJob.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,18 @@ def test_compress(self):
self.assertEqual(len(wd_files), 1, "Only one zipped file should be present in the working directory")
self.assertEqual(wd_files[0], f"{job.name}.tar.bz2", "Inconsistent name for the zipped file")

def test_remove_job(self):
job = self.project.create_job(ReturnCodeJob, "job_without_hdf5")
job.run()
self.assertTrue(isinstance(job.job_id, int))
self.assertTrue(os.path.isfile(job.project_hdf5.file_name))
os.remove(job.project_hdf5.file_name)
with open(job.project_hdf5.file_name, "w") as f:
f.writelines(["wrong file"])
self.assertTrue(os.path.isfile(job.project_hdf5.file_name))
self.project.remove_job(job_specifier=job.job_name)
self.assertIsNone(self.project.load(job_specifier=job.job_name))

def test_restart(self):
wd_warn_key = "write_work_dir_warnings"
previous_wd_warn_setting = self.project.state.settings.configuration[
Expand Down

0 comments on commit e1c0861

Please sign in to comment.