Skip to content

Commit

Permalink
Remove incorrect mock_cromwell fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
mbthornton-lbl committed Oct 8, 2024
1 parent b86cb21 commit 15f5d7d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion nmdc_automation/workflow_automation/watch_nmdc.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def process_successful_job(self, job: WorkflowJob) -> Database:
workflow_execution_record = job.make_workflow_execution_record(data_objects)
database.workflow_execution_set = [workflow_execution_record]

self.file_handler.write_metadata_if_not_exists(job, output_path)
self.file_handler.write_metadata_if_not_exists(job)
return database


Expand Down
39 changes: 20 additions & 19 deletions tests/test_watch_nmdc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import shutil
from unittest.mock import patch, PropertyMock, Mock

from nmdc_schema.nmdc import Database
from nmdc_automation.workflow_automation.watch_nmdc import (
Watcher,
FileHandler,
Expand All @@ -14,23 +15,6 @@
from tests.fixtures import db_utils


@fixture(autouse=True)
def mock_cromwell(requests_mock, test_data_dir):
requests_mock.real_http = True
data = {"id": "1234"}
cromwell_url = "http://localhost:8088/api/workflows/v1"
requests_mock.post(cromwell_url, json=data)
afile_path = test_data_dir / "afile"
bfile_path = test_data_dir / "bfile"
metadata = {'outputs': {"nmdc_rqcfilter.filtered_final": str(afile_path),
"nmdc_rqcfilter.filtered_stats_final": str(bfile_path),
"nmdc_rqcfilter.stats": {"input_read_count": 11431762, "input_read_bases": 1726196062,
"output_read_bases": 1244017053, "output_read_count": 8312566}, }}
requests_mock.get(f"{cromwell_url}/1234/metadata", json=metadata)
data = {"status": "Succeeded"}
requests_mock.get(f"{cromwell_url}/1234/status", json=data)


# FileHandler init tests
def test_file_handler_init_from_state_file(site_config, initial_state_file, tmp_path):
copy_state_file = tmp_path / "copy_state.json"
Expand Down Expand Up @@ -267,8 +251,6 @@ def test_job_manager_get_finished_jobs(site_config, initial_state_file, fixtures
# sanity check
assert len(jm.job_cache) == 3



# Act
successful_jobs, failed_jobs = jm.get_finished_jobs()
# Assert
Expand All @@ -278,6 +260,25 @@ def test_job_manager_get_finished_jobs(site_config, initial_state_file, fixtures
jm.job_cache = []


def test_job_manager_process_successful_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 / "mags_workflow_state.json"))
assert new_job_state
new_job = WorkflowJob(site_config, new_job_state)
jm.job_cache.append(new_job)
# Act
db = jm.process_successful_job(new_job)
# Assert
assert db
assert isinstance(db, Database)
assert new_job.done
assert new_job.job_status == "Succeeded"
# cleanup
jm.job_cache = []


@fixture
def mock_runtime_api_handler(site_config, mock_api):
pass
Expand Down

0 comments on commit 15f5d7d

Please sign in to comment.