Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧪 TESTS: Fix plumpy incompatibility #4751

Merged
merged 4 commits into from
Feb 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions tests/engine/test_work_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,19 +680,22 @@ def do_run(self):
run_and_check_success(MainWorkChain)

def test_if_block_persistence(self):
"""
"""Test a reloaded `If` conditional can be resumed.

This test was created to capture issue #902
"""
runner = get_manager().get_runner()
wc = IfTest()
runner.schedule(wc)

async def run_async(workchain):

# run the original workchain until paused
await run_until_paused(workchain)
self.assertTrue(workchain.ctx.s1)
self.assertFalse(workchain.ctx.s2)

# Now bundle the thing
# Now bundle the workchain
bundle = plumpy.Bundle(workchain)
# Need to close the process before recreating a new instance
workchain.close()
Expand All @@ -702,13 +705,20 @@ async def run_async(workchain):
self.assertTrue(workchain2.ctx.s1)
self.assertFalse(workchain2.ctx.s2)

# check bundling again creates the same saved state
bundle2 = plumpy.Bundle(workchain2)
self.assertDictEqual(bundle, bundle2)

workchain.play()
await workchain.future()
self.assertTrue(workchain.ctx.s1)
self.assertTrue(workchain.ctx.s2)
# run the loaded workchain to completion
runner.schedule(workchain2)
workchain2.play()
await workchain2.future()
self.assertTrue(workchain2.ctx.s1)
self.assertTrue(workchain2.ctx.s2)

# ensure the original paused workchain future is finalised
# to avoid warnings
workchain.future().set_result(None)

runner.loop.run_until_complete(run_async(wc))

Expand Down