Skip to content

Commit fe97df1

Browse files
committed
address some changes in tests
1 parent 73ae216 commit fe97df1

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

tests/unit/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def memory_storage_client(tmp_path: Path) -> MemoryStorageClient:
6666
return MemoryStorageClient(
6767
write_metadata=True,
6868
persist_storage=True,
69-
crawlee_storage_dir=str(tmp_path), # type: ignore[call-arg]
69+
storage_dir=str(tmp_path),
7070
)
7171

7272

tests/unit/test_configuration.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# TODO: type ignores and crawlee_storage_dir
1+
# TODO: Update crawlee_storage_dir args once the Pydantic bug is fixed
22
# https://github.com/apify/crawlee-python/issues/146
33

44
from __future__ import annotations
@@ -13,6 +13,8 @@
1313
if TYPE_CHECKING:
1414
from pathlib import Path
1515

16+
from yarl import URL
17+
1618

1719
def test_global_configuration_works() -> None:
1820
assert (
@@ -23,11 +25,11 @@ def test_global_configuration_works() -> None:
2325
)
2426

2527

26-
async def test_storage_not_persisted_when_disabled(tmp_path: Path) -> None:
28+
async def test_storage_not_persisted_when_disabled(tmp_path: Path, httpbin: URL) -> None:
2729
config = Configuration(
2830
persist_storage=False,
2931
write_metadata=False,
30-
crawlee_storage_dir=str(tmp_path), # type: ignore
32+
crawlee_storage_dir=str(tmp_path), # type: ignore[call-arg]
3133
)
3234
storage_client = MemoryStorageClient(config)
3335
set_storage_client(storage_client, force=True)
@@ -38,18 +40,18 @@ async def test_storage_not_persisted_when_disabled(tmp_path: Path) -> None:
3840
async def default_handler(context: HttpCrawlingContext) -> None:
3941
await context.push_data({'url': context.request.url})
4042

41-
await crawler.run(['https://crawlee.dev'])
43+
await crawler.run([str(httpbin)])
4244

4345
# Verify that no files were created in the storage directory.
4446
content = list(tmp_path.iterdir())
4547
assert content == [], 'Expected the storage directory to be empty, but it is not.'
4648

4749

48-
async def test_storage_persisted_when_enabled(tmp_path: Path) -> None:
50+
async def test_storage_persisted_when_enabled(tmp_path: Path, httpbin: URL) -> None:
4951
config = Configuration(
5052
persist_storage=True,
5153
write_metadata=True,
52-
crawlee_storage_dir=str(tmp_path), # type: ignore
54+
crawlee_storage_dir=str(tmp_path), # type: ignore[call-arg]
5355
)
5456
storage_client = MemoryStorageClient(config)
5557
set_storage_client(storage_client, force=True)
@@ -60,7 +62,7 @@ async def test_storage_persisted_when_enabled(tmp_path: Path) -> None:
6062
async def default_handler(context: HttpCrawlingContext) -> None:
6163
await context.push_data({'url': context.request.url})
6264

63-
await crawler.run(['https://crawlee.dev'])
65+
await crawler.run([str(httpbin)])
6466

6567
# Verify that files were created in the storage directory.
6668
content = list(tmp_path.iterdir())

0 commit comments

Comments
 (0)