|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | | -from apify._configuration import Configuration |
| 3 | +from crawlee import service_locator |
| 4 | + |
| 5 | +from apify import Actor |
| 6 | +from apify._configuration import Configuration, ActorStorages |
| 7 | +from apify.storage_clients import SmartApifyStorageClient, ApifyStorageClient |
4 | 8 | from apify.storage_clients._apify._alias_resolving import AliasResolver |
5 | 9 |
|
6 | 10 |
|
@@ -76,3 +80,30 @@ async def test_get_alias_map_returns_in_memory_map() -> None: |
76 | 80 | AliasResolver._alias_map = {} |
77 | 81 | result = await AliasResolver._get_alias_map(config) |
78 | 82 | assert result == {} |
| 83 | + |
| 84 | + |
| 85 | +async def test_register_aliases() -> None: |
| 86 | + """Test that _get_alias_map loads the map from KVS when at home. |
| 87 | +
|
| 88 | + AliasResolver works locally only """ |
| 89 | + |
| 90 | + |
| 91 | + datasets = {"default": "default_dataset_id", "custom": "custom_dataset_id"} |
| 92 | + request_queues = {"default": "default_dataset_id", "custom": "custom_dataset_id"} |
| 93 | + key_value_stores = {"default": "default_dataset_id", "custom": "custom_dataset_id"} |
| 94 | + |
| 95 | + config = Configuration(is_at_home=False, |
| 96 | + token='test-token', |
| 97 | + actor_storages= ActorStorages( |
| 98 | + datasets = datasets, |
| 99 | + request_queues = request_queues, |
| 100 | + key_value_stores = key_value_stores |
| 101 | + ), |
| 102 | + ) |
| 103 | + storage_client = ApifyStorageClient() |
| 104 | + service_locator.set_storage_client( |
| 105 | + SmartApifyStorageClient(local_storage_client=storage_client, cloud_storage_client=storage_client) |
| 106 | + ) |
| 107 | + async with Actor(configuration=config): |
| 108 | + d = await Actor.open_dataset(alias='default') |
| 109 | + assert d |
0 commit comments