Skip to content

Commit

Permalink
update watcher tests and fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
mbthornton-lbl committed Oct 5, 2024
1 parent 5703d71 commit df35a06
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
3 changes: 1 addition & 2 deletions tests/fixtures/new_state_job.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,5 @@
"done": false,
"failed_count": 1,
"start": "2024-09-16T19:33:32.562412+00:00",
"end": "2024-09-16T21:52:12.873101+00:00",
"opid": "nmdc:sys0m369xp60"
"end": "2024-09-16T21:52:12.873101+00:00"
}
32 changes: 31 additions & 1 deletion tests/test_watch_nmdc.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def test_file_handler_write_metadata_if_not_exists(site_config, initial_state_fi
assert metadata_path.is_file()



# JobManager tests
def test_job_manager_init(site_config, initial_state_file):
# Arrange
fh = FileHandler(site_config, initial_state_file)
Expand Down Expand Up @@ -213,6 +213,36 @@ def test_job_manager_save_checkpoint(site_config, initial_state_file):
# cleanup
fh.state_file.unlink()

def test_job_manager_find_job_by_opid(site_config, initial_state_file):
# Arrange
fh = FileHandler(site_config, initial_state_file)
jm = JobManager(site_config, fh)
# Act
job = jm.find_job_by_opid("nmdc:test-opid")
# Assert
assert job
assert isinstance(job, WorkflowJob)
assert job.opid == "nmdc:test-opid"
assert not job.done


def test_job_manager_prepare_and_cache_new_job(site_config, initial_state_file, fixtures_dir):
# Arrange
fh = FileHandler(site_config, initial_state_file)
jm = JobManager(site_config, fh)
new_job_state = json.load(open(fixtures_dir / "new_state_job.json"))
assert new_job_state
new_job = WorkflowJob(site_config, new_job_state)
# Act
opid = "nmdc:test-opid-2"
job = jm.prepare_and_cache_new_job(new_job, opid)
# Assert
assert job
assert isinstance(job, WorkflowJob)
assert job.opid == opid
assert not job.done
# cleanup
jm.job_cache = []



Expand Down

0 comments on commit df35a06

Please sign in to comment.