Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f0ba351

Browse filesBrowse files
authored
feat: Use Actor env vars (#105)
1 parent b96e135 commit f0ba351
Copy full SHA for f0ba351

File tree

Expand file treeCollapse file tree

12 files changed

+55
-54
lines changed
Filter options
Expand file treeCollapse file tree

12 files changed

+55
-54
lines changed

‎pyproject.toml

Copy file name to clipboardExpand all lines: pyproject.toml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies = [
2626
"aiofiles >= 22.1.0",
2727
"aioshutil >= 1.0",
2828
"apify-client >= 1.3.1",
29-
"apify-shared >= 1.0.0",
29+
"apify-shared >= 1.0.2",
3030
"colorama >= 0.4.6",
3131
"cryptography >= 39.0.0",
3232
"httpx >= 0.24.1",

‎src/apify/_utils.py

Copy file name to clipboardExpand all lines: src/apify/_utils.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
INTEGER_ENV_VARS,
3535
INTEGER_ENV_VARS_TYPE,
3636
STRING_ENV_VARS_TYPE,
37+
ActorEnvVars,
3738
ApifyEnvVars,
3839
)
3940
from apify_shared.utils import ignore_docs, is_content_type_json, is_content_type_text, is_content_type_xml, maybe_extract_enum_member_value
@@ -144,7 +145,7 @@ def _fetch_and_parse_env_var(env_var: STRING_ENV_VARS_TYPE) -> Optional[str]:
144145

145146

146147
@overload
147-
def _fetch_and_parse_env_var(env_var: ApifyEnvVars) -> Optional[Any]:
148+
def _fetch_and_parse_env_var(env_var: Union[ActorEnvVars, ApifyEnvVars]) -> Optional[Any]:
148149
...
149150

150151

‎src/apify/actor.py

Copy file name to clipboardExpand all lines: src/apify/actor.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from typing import Any, Awaitable, Callable, Dict, List, Optional, Type, TypeVar, Union, cast
1010

1111
from apify_client import ApifyClientAsync
12-
from apify_shared.consts import ActorEventTypes, ActorExitCodes, ApifyEnvVars, WebhookEventType
12+
from apify_shared.consts import ActorEnvVars, ActorEventTypes, ActorExitCodes, ApifyEnvVars, WebhookEventType
1313
from apify_shared.utils import ignore_docs, maybe_extract_enum_member_value
1414

1515
from ._crypto import _decrypt_input_secrets, _load_private_key
@@ -748,7 +748,7 @@ def _get_env_internal(self) -> Dict:
748748
self._raise_if_not_initialized()
749749

750750
return {
751-
env_var.name.lower(): _fetch_and_parse_env_var(env_var) for env_var in ApifyEnvVars
751+
env_var.name.lower(): _fetch_and_parse_env_var(env_var) for env_var in [*ActorEnvVars, *ApifyEnvVars]
752752
}
753753

754754
@classmethod

‎src/apify/config.py

Copy file name to clipboardExpand all lines: src/apify/config.py
+16-16Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Optional
22

3-
from apify_shared.consts import ApifyEnvVars
3+
from apify_shared.consts import ActorEnvVars, ApifyEnvVars
44

55
from ._utils import _fetch_and_parse_env_var
66

@@ -67,30 +67,30 @@ def __init__(
6767
system_info_interval_millis (str, optional): How often should the actor emit the SYSTEM_INFO event when running locally.
6868
"""
6969
# TODO: Document all these members
70-
self.actor_build_id = _fetch_and_parse_env_var(ApifyEnvVars.ACTOR_BUILD_ID)
71-
self.actor_build_number = _fetch_and_parse_env_var(ApifyEnvVars.ACTOR_BUILD_NUMBER)
72-
self.actor_events_ws_url = _fetch_and_parse_env_var(ApifyEnvVars.ACTOR_EVENTS_WS_URL)
73-
self.actor_id = _fetch_and_parse_env_var(ApifyEnvVars.ACTOR_ID)
74-
self.actor_run_id = _fetch_and_parse_env_var(ApifyEnvVars.ACTOR_RUN_ID)
75-
self.actor_task_id = _fetch_and_parse_env_var(ApifyEnvVars.ACTOR_TASK_ID)
70+
self.actor_build_id = _fetch_and_parse_env_var(ActorEnvVars.BUILD_ID)
71+
self.actor_build_number = _fetch_and_parse_env_var(ActorEnvVars.BUILD_NUMBER)
72+
self.actor_events_ws_url = _fetch_and_parse_env_var(ActorEnvVars.EVENTS_WEBSOCKET_URL)
73+
self.actor_id = _fetch_and_parse_env_var(ActorEnvVars.ID)
74+
self.actor_run_id = _fetch_and_parse_env_var(ActorEnvVars.RUN_ID)
75+
self.actor_task_id = _fetch_and_parse_env_var(ActorEnvVars.TASK_ID)
7676
self.api_base_url = api_base_url or _fetch_and_parse_env_var(ApifyEnvVars.API_BASE_URL, 'https://api.apify.com')
7777
self.api_public_base_url = api_public_base_url or _fetch_and_parse_env_var(ApifyEnvVars.API_PUBLIC_BASE_URL, 'https://api.apify.com')
7878
self.chrome_executable_path = _fetch_and_parse_env_var(ApifyEnvVars.CHROME_EXECUTABLE_PATH)
79-
self.container_port = container_port or _fetch_and_parse_env_var(ApifyEnvVars.CONTAINER_PORT, 4321)
80-
self.container_url = container_url or _fetch_and_parse_env_var(ApifyEnvVars.CONTAINER_URL, 'http://localhost:4321')
79+
self.container_port = container_port or _fetch_and_parse_env_var(ActorEnvVars.WEB_SERVER_PORT, 4321)
80+
self.container_url = container_url or _fetch_and_parse_env_var(ActorEnvVars.WEB_SERVER_URL, 'http://localhost:4321')
8181
self.dedicated_cpus = _fetch_and_parse_env_var(ApifyEnvVars.DEDICATED_CPUS)
8282
self.default_browser_path = _fetch_and_parse_env_var(ApifyEnvVars.DEFAULT_BROWSER_PATH)
83-
self.default_dataset_id = default_dataset_id or _fetch_and_parse_env_var(ApifyEnvVars.DEFAULT_DATASET_ID, 'default')
84-
self.default_key_value_store_id = default_key_value_store_id or _fetch_and_parse_env_var(ApifyEnvVars.DEFAULT_KEY_VALUE_STORE_ID, 'default')
85-
self.default_request_queue_id = default_request_queue_id or _fetch_and_parse_env_var(ApifyEnvVars.DEFAULT_REQUEST_QUEUE_ID, 'default')
83+
self.default_dataset_id = default_dataset_id or _fetch_and_parse_env_var(ActorEnvVars.DEFAULT_DATASET_ID, 'default')
84+
self.default_key_value_store_id = default_key_value_store_id or _fetch_and_parse_env_var(ActorEnvVars.DEFAULT_KEY_VALUE_STORE_ID, 'default')
85+
self.default_request_queue_id = default_request_queue_id or _fetch_and_parse_env_var(ActorEnvVars.DEFAULT_REQUEST_QUEUE_ID, 'default')
8686
self.disable_browser_sandbox = _fetch_and_parse_env_var(ApifyEnvVars.DISABLE_BROWSER_SANDBOX, False)
8787
self.headless = _fetch_and_parse_env_var(ApifyEnvVars.HEADLESS, True)
88-
self.input_key = input_key or _fetch_and_parse_env_var(ApifyEnvVars.INPUT_KEY, 'INPUT')
88+
self.input_key = input_key or _fetch_and_parse_env_var(ActorEnvVars.INPUT_KEY, 'INPUT')
8989
self.input_secrets_private_key_file = _fetch_and_parse_env_var(ApifyEnvVars.INPUT_SECRETS_PRIVATE_KEY_FILE)
9090
self.input_secrets_private_key_passphrase = _fetch_and_parse_env_var(ApifyEnvVars.INPUT_SECRETS_PRIVATE_KEY_PASSPHRASE)
9191
self.is_at_home = _fetch_and_parse_env_var(ApifyEnvVars.IS_AT_HOME, False)
9292
self.max_used_cpu_ratio = max_used_cpu_ratio or _fetch_and_parse_env_var(ApifyEnvVars.MAX_USED_CPU_RATIO, 0.95)
93-
self.memory_mbytes = _fetch_and_parse_env_var(ApifyEnvVars.MEMORY_MBYTES)
93+
self.memory_mbytes = _fetch_and_parse_env_var(ActorEnvVars.MEMORY_MBYTES)
9494
self.meta_origin = _fetch_and_parse_env_var(ApifyEnvVars.META_ORIGIN)
9595
self.metamorph_after_sleep_millis = metamorph_after_sleep_millis or _fetch_and_parse_env_var(ApifyEnvVars.METAMORPH_AFTER_SLEEP_MILLIS, 300000) # noqa: E501
9696
self.persist_state_interval_millis = persist_state_interval_millis or _fetch_and_parse_env_var(ApifyEnvVars.PERSIST_STATE_INTERVAL_MILLIS, 60000) # noqa: E501
@@ -100,8 +100,8 @@ def __init__(
100100
self.proxy_port = proxy_port or _fetch_and_parse_env_var(ApifyEnvVars.PROXY_PORT, 8000)
101101
self.proxy_status_url = proxy_status_url or _fetch_and_parse_env_var(ApifyEnvVars.PROXY_STATUS_URL, 'http://proxy.apify.com')
102102
self.purge_on_start = purge_on_start or _fetch_and_parse_env_var(ApifyEnvVars.PURGE_ON_START, False)
103-
self.started_at = _fetch_and_parse_env_var(ApifyEnvVars.STARTED_AT)
104-
self.timeout_at = _fetch_and_parse_env_var(ApifyEnvVars.TIMEOUT_AT)
103+
self.started_at = _fetch_and_parse_env_var(ActorEnvVars.STARTED_AT)
104+
self.timeout_at = _fetch_and_parse_env_var(ActorEnvVars.TIMEOUT_AT)
105105
self.token = token or _fetch_and_parse_env_var(ApifyEnvVars.TOKEN)
106106
self.user_id = _fetch_and_parse_env_var(ApifyEnvVars.USER_ID)
107107
self.xvfb = _fetch_and_parse_env_var(ApifyEnvVars.XVFB, False)

‎tests/integration/README.md

Copy file name to clipboardExpand all lines: tests/integration/README.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ You can also pass extra imports directly to the main function:
6363
async def test_something(self, make_actor: ActorFactory) -> None:
6464
async def main():
6565
import os
66-
from apify_shared.consts import ActorEventTypes, ApifyEnvVars
66+
from apify_shared.consts import ActorEventTypes, ActorEnvVars
6767
async with Actor:
68-
print('The actor is running with ' + os.getenv(ApifyEnvVars.MEMORY_MBYTES) + 'MB of memory')
68+
print('The actor is running with ' + os.getenv(ActorEnvVars.MEMORY_MBYTES) + 'MB of memory')
6969
await Actor.on(ActorEventTypes.SYSTEM_INFO, lambda event_data: print(event_data))
7070

7171
actor = await make_actor('something', main_func=main)

‎tests/integration/test_actor_api_helpers.py

Copy file name to clipboardExpand all lines: tests/integration/test_actor_api_helpers.py
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ async def test_actor_new_client(self, make_actor: ActorFactory) -> None:
5454
async def main() -> None:
5555
import os
5656

57-
from apify_shared.consts import ApifyEnvVars
57+
from apify_shared.consts import ActorEnvVars
5858

5959
async with Actor:
6060
new_client = Actor.new_client()
6161
assert new_client is not Actor.apify_client
6262

63-
default_key_value_store_id = os.getenv(ApifyEnvVars.DEFAULT_KEY_VALUE_STORE_ID)
63+
default_key_value_store_id = os.getenv(ActorEnvVars.DEFAULT_KEY_VALUE_STORE_ID)
6464
assert default_key_value_store_id is not None
6565
kv_store_client = new_client.key_value_store(default_key_value_store_id)
6666
await kv_store_client.set_record('OUTPUT', 'TESTING-OUTPUT')
@@ -272,11 +272,11 @@ async def test_actor_metamorph(self, make_actor: ActorFactory) -> None:
272272
async def main_inner() -> None:
273273
import os
274274

275-
from apify_shared.consts import ApifyEnvVars
275+
from apify_shared.consts import ActorEnvVars
276276

277277
async with Actor:
278-
assert os.getenv(ApifyEnvVars.INPUT_KEY) is not None
279-
assert os.getenv(ApifyEnvVars.INPUT_KEY) != 'INPUT'
278+
assert os.getenv(ActorEnvVars.INPUT_KEY) is not None
279+
assert os.getenv(ActorEnvVars.INPUT_KEY) != 'INPUT'
280280
input = await Actor.get_input() or {}
281281

282282
test_value = input.get('test_value', '')
@@ -329,7 +329,7 @@ async def main_server() -> None:
329329
import os
330330
from http.server import BaseHTTPRequestHandler, HTTPServer
331331

332-
from apify_shared.consts import ApifyEnvVars
332+
from apify_shared.consts import ActorEnvVars
333333

334334
webhook_body = ''
335335

@@ -351,7 +351,7 @@ def do_POST(self) -> None: # noqa: N802
351351
self.end_headers()
352352
self.wfile.write(bytes('Hello, world!', encoding='utf-8'))
353353

354-
container_port = int(os.getenv(ApifyEnvVars.CONTAINER_PORT, ''))
354+
container_port = int(os.getenv(ActorEnvVars.WEB_SERVER_PORT, ''))
355355
with HTTPServer(('', container_port), WebhookHandler) as server:
356356
await Actor.set_value('INITIALIZED', True)
357357
while not webhook_body:

‎tests/integration/test_fixtures.py

Copy file name to clipboardExpand all lines: tests/integration/test_fixtures.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ async def test_main_func(self, make_actor: ActorFactory) -> None:
1212
async def main() -> None:
1313
import os
1414

15-
from apify_shared.consts import ApifyEnvVars
15+
from apify_shared.consts import ActorEnvVars
1616

1717
async with Actor:
18-
await Actor.set_value('OUTPUT', os.getenv(ApifyEnvVars.ACTOR_ID))
18+
await Actor.set_value('OUTPUT', os.getenv(ActorEnvVars.ID))
1919

2020
actor = await make_actor('make-actor-main-func', main_func=main)
2121

‎tests/unit/actor/test_actor_dataset.py

Copy file name to clipboardExpand all lines: tests/unit/actor/test_actor_dataset.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from apify import Actor
55
from apify._memory_storage import MemoryStorageClient
6-
from apify_shared.consts import ApifyEnvVars
6+
from apify_shared.consts import ActorEnvVars
77

88
# NOTE: We only test the dataset methond available on Actor class/instance. Actual tests for the implementations are in storages/.
99

@@ -36,7 +36,7 @@ async def test_open_datatset_based_env_var(
3636
memory_storage_client: MemoryStorageClient,
3737
) -> None:
3838
default_dataset_id = 'my-new-default-id'
39-
monkeypatch.setenv(ApifyEnvVars.DEFAULT_DATASET_ID, default_dataset_id)
39+
monkeypatch.setenv(ActorEnvVars.DEFAULT_DATASET_ID, default_dataset_id)
4040

4141
async with Actor:
4242
ddt = await Actor.open_dataset()

‎tests/unit/actor/test_actor_env_helpers.py

Copy file name to clipboardExpand all lines: tests/unit/actor/test_actor_env_helpers.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import pytest
77

88
from apify import Actor
9-
from apify_shared.consts import BOOL_ENV_VARS, DATETIME_ENV_VARS, FLOAT_ENV_VARS, INTEGER_ENV_VARS, STRING_ENV_VARS, ApifyEnvVars
9+
from apify_shared.consts import BOOL_ENV_VARS, DATETIME_ENV_VARS, FLOAT_ENV_VARS, INTEGER_ENV_VARS, STRING_ENV_VARS, ActorEnvVars, ApifyEnvVars
1010

1111

1212
class TestIsAtHome:
@@ -52,8 +52,8 @@ async def test_get_env_use_env_vars(self, monkeypatch: pytest.MonkeyPatch) -> No
5252
monkeypatch.setenv(string_env_var, expected_get_env[string_get_env_var])
5353

5454
# We need this override so that the actor doesn't fail when connecting to the platform events websocket
55-
monkeypatch.delenv(ApifyEnvVars.ACTOR_EVENTS_WS_URL)
56-
expected_get_env[ApifyEnvVars.ACTOR_EVENTS_WS_URL.name.lower()] = None
55+
monkeypatch.delenv(ActorEnvVars.EVENTS_WEBSOCKET_URL)
56+
expected_get_env[ActorEnvVars.EVENTS_WEBSOCKET_URL.name.lower()] = None
5757

5858
await Actor.init()
5959
assert expected_get_env == Actor.get_env()

‎tests/unit/test_config.py

Copy file name to clipboardExpand all lines: tests/unit/test_config.py
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import pytest
44

55
from apify.config import Configuration
6-
from apify_shared.consts import ApifyEnvVars
6+
from apify_shared.consts import ActorEnvVars, ApifyEnvVars
77

88

99
class TestConfiguration:
@@ -28,13 +28,13 @@ def test_configuration_from_env_vars(self, monkeypatch: pytest.MonkeyPatch) -> N
2828
monkeypatch.setenv(ApifyEnvVars.PROXY_PASSWORD, 'DUMMY_PROXY_PASSWORD')
2929
monkeypatch.setenv(ApifyEnvVars.API_BASE_URL, 'DUMMY_API_BASE_URL')
3030
monkeypatch.setenv(ApifyEnvVars.PROXY_HOSTNAME, 'DUMMY_PROXY_HOSTNAME')
31-
monkeypatch.setenv(ApifyEnvVars.DEFAULT_KEY_VALUE_STORE_ID, 'DUMMY_DEFAULT_KEY_VALUE_STORE_ID')
32-
monkeypatch.setenv(ApifyEnvVars.DEFAULT_REQUEST_QUEUE_ID, 'DUMMY_DEFAULT_REQUEST_QUEUE_ID')
33-
monkeypatch.setenv(ApifyEnvVars.DEFAULT_DATASET_ID, 'DUMMY_DEFAULT_DATASET_ID')
31+
monkeypatch.setenv(ActorEnvVars.DEFAULT_KEY_VALUE_STORE_ID, 'DUMMY_DEFAULT_KEY_VALUE_STORE_ID')
32+
monkeypatch.setenv(ActorEnvVars.DEFAULT_REQUEST_QUEUE_ID, 'DUMMY_DEFAULT_REQUEST_QUEUE_ID')
33+
monkeypatch.setenv(ActorEnvVars.DEFAULT_DATASET_ID, 'DUMMY_DEFAULT_DATASET_ID')
3434
monkeypatch.setenv(ApifyEnvVars.IS_AT_HOME, '1')
3535
monkeypatch.setenv(ApifyEnvVars.PROXY_PORT, '1234')
36-
monkeypatch.setenv(ApifyEnvVars.MEMORY_MBYTES, '1024')
37-
monkeypatch.setenv(ApifyEnvVars.STARTED_AT, '2023-01-01T12:34:56.789Z')
36+
monkeypatch.setenv(ActorEnvVars.MEMORY_MBYTES, '1024')
37+
monkeypatch.setenv(ActorEnvVars.STARTED_AT, '2023-01-01T12:34:56.789Z')
3838

3939
config = Configuration()
4040
assert config.token == 'DUMMY_TOKEN'
@@ -55,9 +55,9 @@ def test_configuration_from_constructor_arguments(self, monkeypatch: pytest.Monk
5555
monkeypatch.setenv(ApifyEnvVars.PROXY_PASSWORD, 'DUMMY_PROXY_PASSWORD')
5656
monkeypatch.setenv(ApifyEnvVars.API_BASE_URL, 'DUMMY_API_BASE_URL')
5757
monkeypatch.setenv(ApifyEnvVars.PROXY_HOSTNAME, 'DUMMY_PROXY_HOSTNAME')
58-
monkeypatch.setenv(ApifyEnvVars.DEFAULT_DATASET_ID, 'DUMMY_DEFAULT_DATASET_ID')
59-
monkeypatch.setenv(ApifyEnvVars.DEFAULT_KEY_VALUE_STORE_ID, 'DUMMY_DEFAULT_KEY_VALUE_STORE_ID')
60-
monkeypatch.setenv(ApifyEnvVars.DEFAULT_REQUEST_QUEUE_ID, 'DUMMY_DEFAULT_REQUEST_QUEUE_ID')
58+
monkeypatch.setenv(ActorEnvVars.DEFAULT_DATASET_ID, 'DUMMY_DEFAULT_DATASET_ID')
59+
monkeypatch.setenv(ActorEnvVars.DEFAULT_KEY_VALUE_STORE_ID, 'DUMMY_DEFAULT_KEY_VALUE_STORE_ID')
60+
monkeypatch.setenv(ActorEnvVars.DEFAULT_REQUEST_QUEUE_ID, 'DUMMY_DEFAULT_REQUEST_QUEUE_ID')
6161
monkeypatch.setenv(ApifyEnvVars.PROXY_PORT, '1234')
6262

6363
config = Configuration(

‎tests/unit/test_event_manager.py

Copy file name to clipboardExpand all lines: tests/unit/test_event_manager.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from apify.config import Configuration
1414
from apify.event_manager import EventManager
15-
from apify_shared.consts import ActorEventTypes, ApifyEnvVars
15+
from apify_shared.consts import ActorEnvVars, ActorEventTypes
1616

1717

1818
class TestEventManagerLocal:
@@ -269,7 +269,7 @@ async def event_handler(data: Any) -> None:
269269

270270
class TestEventManagerOnPlatform:
271271
async def test_lifecycle_on_platform_without_websocket(self, monkeypatch: pytest.MonkeyPatch) -> None:
272-
monkeypatch.setenv(ApifyEnvVars.ACTOR_EVENTS_WS_URL, 'ws://localhost:56565')
272+
monkeypatch.setenv(ActorEnvVars.EVENTS_WEBSOCKET_URL, 'ws://localhost:56565')
273273

274274
config = Configuration()
275275
event_manager = EventManager(config)
@@ -293,7 +293,7 @@ async def handler(websocket: websockets.server.WebSocketServerProtocol) -> None:
293293
# When you don't specify a port explicitly, the websocket connection is opened on a random free port.
294294
# We need to find out which port is that.
295295
port: int = ws_server.sockets[0].getsockname()[1] # type: ignore[index]
296-
monkeypatch.setenv(ApifyEnvVars.ACTOR_EVENTS_WS_URL, f'ws://localhost:{port}')
296+
monkeypatch.setenv(ActorEnvVars.EVENTS_WEBSOCKET_URL, f'ws://localhost:{port}')
297297

298298
config = Configuration()
299299
event_manager = EventManager(config)
@@ -328,7 +328,7 @@ async def send_platform_event(event_name: ActorEventTypes, data: Any = None) ->
328328
# When you don't specify a port explicitly, the websocket connection is opened on a random free port.
329329
# We need to find out which port is that.
330330
port: int = ws_server.sockets[0].getsockname()[1] # type: ignore[index]
331-
monkeypatch.setenv(ApifyEnvVars.ACTOR_EVENTS_WS_URL, f'ws://localhost:{port}')
331+
monkeypatch.setenv(ActorEnvVars.EVENTS_WEBSOCKET_URL, f'ws://localhost:{port}')
332332

333333
config = Configuration()
334334
event_manager = EventManager(config)

‎tests/unit/test_utils.py

Copy file name to clipboardExpand all lines: tests/unit/test_utils.py
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,23 @@
2626
_unique_key_to_request_id,
2727
)
2828
from apify.consts import _StorageTypes
29-
from apify_shared.consts import ApifyEnvVars
29+
from apify_shared.consts import ActorEnvVars, ApifyEnvVars
3030

3131

3232
def test__fetch_and_parse_env_var(monkeypatch: pytest.MonkeyPatch) -> None:
3333
monkeypatch.setenv(ApifyEnvVars.IS_AT_HOME, 'True')
34-
monkeypatch.setenv(ApifyEnvVars.MEMORY_MBYTES, '1024')
34+
monkeypatch.setenv(ActorEnvVars.MEMORY_MBYTES, '1024')
3535
monkeypatch.setenv(ApifyEnvVars.META_ORIGIN, 'API')
36-
monkeypatch.setenv(ApifyEnvVars.STARTED_AT, '2022-12-02T15:19:34.907Z')
36+
monkeypatch.setenv(ActorEnvVars.STARTED_AT, '2022-12-02T15:19:34.907Z')
3737
monkeypatch.setenv('DUMMY_BOOL', '1')
3838
monkeypatch.setenv('DUMMY_DATETIME', '2022-12-02T15:19:34.907Z')
3939
monkeypatch.setenv('DUMMY_INT', '1')
4040
monkeypatch.setenv('DUMMY_STRING', 'DUMMY')
4141

4242
assert _fetch_and_parse_env_var(ApifyEnvVars.IS_AT_HOME) is True
43-
assert _fetch_and_parse_env_var(ApifyEnvVars.MEMORY_MBYTES) == 1024
43+
assert _fetch_and_parse_env_var(ActorEnvVars.MEMORY_MBYTES) == 1024
4444
assert _fetch_and_parse_env_var(ApifyEnvVars.META_ORIGIN) == 'API'
45-
assert _fetch_and_parse_env_var(ApifyEnvVars.STARTED_AT) == \
45+
assert _fetch_and_parse_env_var(ActorEnvVars.STARTED_AT) == \
4646
datetime(2022, 12, 2, 15, 19, 34, 907000, tzinfo=timezone.utc)
4747

4848
assert _fetch_and_parse_env_var('DUMMY_BOOL') == '1' # type: ignore

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.