Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MetRonnie committed Nov 18, 2024
1 parent 0925320 commit 8187a4a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
9 changes: 8 additions & 1 deletion tests/functional/cylc-remove/03-flow.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# Integration tests exist for more comprehensive coverage.

. "$(dirname "$0")/test_header"
set_test_number 4
set_test_number 6

init_workflow "${TEST_NAME_BASE}" <<'__EOF__'
[scheduler]
Expand All @@ -40,4 +40,11 @@ poll_workflow_stopped

grep_workflow_log_ok "${TEST_NAME_BASE}-grep" "Removed task(s): 1/foo (flows=1)"

# Simple additional test of DB:
TEST_NAME="${TEST_NAME_BASE}-workflow-state"
run_ok "$TEST_NAME" cylc workflow-state "$WORKFLOW_NAME"
cmp_ok "${TEST_NAME}.stdout" <<__EOF__
1/foo:waiting(flows=none)
__EOF__

purge
31 changes: 15 additions & 16 deletions tests/unit/test_workflow_db_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,33 +48,32 @@ def test_remove_task_from_flows(
{5},
set(), # FLOW_NONE
]
expected_remaining = {
serialise_set(flow - expected_removed) for flow in db_flows
}
db_mgr = WorkflowDatabaseManager(tmp_path)
schd_tokens = Tokens('~asterix/gaul')
tdef = TaskDef('a', {}, None, None, None)
with db_mgr.get_pri_dao() as dao:
db_mgr.pri_dao = dao
db_mgr.pub_dao = Mock()
for flow in db_flows:
db_mgr.put_insert_task_states(
TaskProxy(
schd_tokens,
tdef,
IntegerPoint('1'),
flow_nums=flow,
),
itask = TaskProxy(
schd_tokens, tdef, IntegerPoint('1'), flow_nums=flow
)
db_mgr.put_insert_task_states(itask)
db_mgr.put_insert_task_outputs(itask)
db_mgr.process_queued_ops()

removed_fnums = db_mgr.remove_task_from_flows('1', 'a', flow_nums)
assert removed_fnums == expected_removed

db_mgr.process_queued_ops()
remaining_fnums: Set[str] = {
fnums_str
for fnums_str, *_ in dao.connect().execute(
'SELECT flow_nums FROM task_states'
)
}
assert remaining_fnums == {
serialise_set(flow - expected_removed) for flow in db_flows
}
for table in ('task_states', 'task_outputs'):
remaining_fnums: Set[str] = {
fnums_str
for fnums_str, *_ in dao.connect().execute(
f'SELECT flow_nums FROM {table}'
)
}
assert remaining_fnums == expected_remaining

0 comments on commit 8187a4a

Please sign in to comment.