Skip to content

Commit

Permalink
correctly name file
Browse files Browse the repository at this point in the history
  • Loading branch information
zzstoatzz committed Dec 25, 2024
1 parent e05a050 commit 82217d2
Showing 1 changed file with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pathlib import Path
from unittest.mock import patch

import anyio
import pytest
Expand Down Expand Up @@ -34,17 +35,25 @@ async def awrite_path(self, path: str, content: bytes) -> str:
async def test_async_method_used_in_async_context(
custom_storage_block: LocalFileSystem,
):
@task(result_storage=custom_storage_block, result_storage_key="testing")
async def t():
return "this is a test"

@flow
async def f():
return await t()

result = await f()
assert result == "this is a test"
store = ResultStore(result_storage=custom_storage_block)
stored_result_record = await store.aread("testing")

assert stored_result_record.result == result == "this is a test"
# this is a regression test for https://github.com/PrefectHQ/prefect/issues/16486
with patch.object(
custom_storage_block, "awrite_path", wraps=custom_storage_block.awrite_path
) as mock_awrite:

@task(result_storage=custom_storage_block, result_storage_key="testing")
async def t():
return "this is a test"

@flow
async def f():
return await t()

result = await f()
assert result == "this is a test"
store = ResultStore(result_storage=custom_storage_block)
stored_result_record = await store.aread("testing")

assert stored_result_record.result == result == "this is a test"
# Verify awrite_path was called
mock_awrite.assert_awaited_once()
assert mock_awrite.await_args[0][0] == "testing" # Check path argument

0 comments on commit 82217d2

Please sign in to comment.