def test_engine_cannot_find_task_by_id_if_not_saved(): """ Test that *unsaved* tasks are cannot be retrieved from the Engine given their ID only. """ with temporary_core() as core: with temporary_directory() as tmpdir: store = FilesystemStore(tmpdir) engine = Engine(core, store=store) task = SuccessfulApp() engine.add(task) store.save(task) # guarantee it has a `.persistent_id` task_id = task.persistent_id with pytest.raises(KeyError): engine.find_task_by_id(task_id)
def test_engine_find_task_by_id(): """ Test that saved tasks are can be retrieved from the Engine given their ID only. """ with temporary_core() as core: with temporary_directory() as tmpdir: store = FilesystemStore(tmpdir) engine = Engine(core, store=store) task = SuccessfulApp() store.save(task) engine.add(task) task_id = task.persistent_id assert engine.find_task_by_id(task_id) == task