Skip to content

Commit

Permalink
fixed dispatcher tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kessler-frost committed Sep 27, 2023
1 parent e2d2fc2 commit b3a2466
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
Binary file not shown.
2 changes: 2 additions & 0 deletions tests/covalent_dispatcher_tests/_core/data_manager_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ async def test_handle_built_sublattice(mocker):
return_value="mock-sub-dispatch-id",
)
mock_node_result = generate_node_result(
dispatch_id="mock-dispatch-id",
node_id=0,
node_name="mock_node_name",
status=RESULT_STATUS.COMPLETED,
Expand All @@ -125,6 +126,7 @@ async def test_handle_built_sublattice_exception(mocker):
return_value="mock-sub-dispatch-id",
)
mock_node_result = generate_node_result(
dispatch_id="mock-dispatch-id",
node_id=0,
node_name="mock_node_name",
status=RESULT_STATUS.COMPLETED,
Expand Down
10 changes: 6 additions & 4 deletions tests/covalent_dispatcher_tests/_core/runner_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
from covalent_dispatcher._core.runner import (
_cancel_task,
_gather_deps,
_get_cancel_requested,
_get_metadata_for_nodes,
_run_abstract_task,
_run_task,
cancel_tasks,
get_executor,
)
from covalent_dispatcher._core.runner_modules.executor_proxy import _get_cancel_requested
from covalent_dispatcher._db.datastore import DataStore

TEST_RESULTS_DIR = "/tmp/results"
Expand Down Expand Up @@ -130,7 +130,8 @@ async def test_run_abstract_task_exception_handling(mocker):
mock_get_result = mocker.patch(
"covalent_dispatcher._core.runner.datasvc.get_result_object", return_value=result_object
)
mock_get_task_input_values = mocker.patch(

mocker.patch(
"covalent_dispatcher._core.runner._get_task_input_values",
side_effect=RuntimeError(),
)
Expand Down Expand Up @@ -162,7 +163,7 @@ async def test_run_abstract_task_get_cancel_requested(mocker):
side_effect=RuntimeError(),
)
mock_get_cancel_requested = mocker.patch(
"covalent_dispatcher._core.runner._get_cancel_requested",
"covalent_dispatcher._core.runner_modules.executor_proxy._get_cancel_requested",
return_value=AsyncMock(return_value=True),
)
mock_generate_node_result = mocker.patch(
Expand Down Expand Up @@ -343,7 +344,8 @@ async def test__get_cancel_requested(mocker):
dispatch_id = "abcd"
task_id = 0
mock_get_jobs_metadata = mocker.patch(
"covalent_dispatcher._core.runner.get_jobs_metadata", return_value=AsyncMock()
"covalent_dispatcher._core.runner_modules.executor_proxy.job_manager.get_jobs_metadata",
return_value=AsyncMock(),
)

await _get_cancel_requested(dispatch_id, task_id)
Expand Down
2 changes: 2 additions & 0 deletions tests/covalent_dispatcher_tests/_db/update_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ def test_node(mocker, node_name):
end_time="mock_time",
status="COMPLETED",
output="mock_output",
qelectron_data_exists=False,
)
if node_name is None:
node_name = mock_result.lattice.transport_graph.get_node_value()
Expand All @@ -436,6 +437,7 @@ def test_node(mocker, node_name):
end_time="mock_time",
status="COMPLETED",
output="mock_output",
qelectron_data_exists=False,
error=None,
sub_dispatch_id=None,
sublattice_result=None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ def get_electron_kwargs(
deps_filename=DEPS_FILENAME,
call_before_filename=CALL_BEFORE_FILENAME,
call_after_filename=CALL_AFTER_FILENAME,
qelectron_data_exists=False,
cancel_requested=False,
created_at=None,
updated_at=None,
Expand Down Expand Up @@ -233,6 +234,7 @@ def get_electron_kwargs(
"deps_filename": deps_filename,
"call_before_filename": call_before_filename,
"call_after_filename": call_after_filename,
"qelectron_data_exists": qelectron_data_exists,
"cancel_requested": cancel_requested,
"created_at": created_at,
"updated_at": updated_at,
Expand Down Expand Up @@ -606,6 +608,7 @@ def test_update_electrons_data(test_db, mocker):
started_at=dt.now(timezone.utc),
updated_at=dt.now(timezone.utc),
completed_at=None,
qelectron_data_exists=False,
)

insert_electrons_data(
Expand All @@ -623,6 +626,7 @@ def test_update_electrons_data(test_db, mocker):
started_at=cur_time,
updated_at=cur_time,
completed_at=None,
qelectron_data_exists=False,
)

with test_db.session() as session:
Expand Down

0 comments on commit b3a2466

Please sign in to comment.