Skip to content

Commit 6c04330

Browse files
committed
fix: Expose missing platform env vars via Actor.get_env()
1 parent 0daca28 commit 6c04330

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

src/apify/_consts.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ class ActorEnvVars(StrEnum):
4949
STANDBY_PORT = 'ACTOR_STANDBY_PORT'
5050
STANDBY_URL = 'ACTOR_STANDBY_URL'
5151
STARTED_AT = 'ACTOR_STARTED_AT'
52+
STORAGES_JSON = 'ACTOR_STORAGES_JSON'
5253
TASK_ID = 'ACTOR_TASK_ID'
54+
TEST_PAY_PER_EVENT = 'ACTOR_TEST_PAY_PER_EVENT'
5355
TIMEOUT_AT = 'ACTOR_TIMEOUT_AT'
5456
WEB_SERVER_PORT = 'ACTOR_WEB_SERVER_PORT'
5557
WEB_SERVER_URL = 'ACTOR_WEB_SERVER_URL'
@@ -58,8 +60,10 @@ class ActorEnvVars(StrEnum):
5860
class ApifyEnvVars(StrEnum):
5961
"""Environment variables with APIFY_ prefix set by the Apify platform."""
6062

63+
ACTOR_PRICING_INFO = 'APIFY_ACTOR_PRICING_INFO'
6164
API_BASE_URL = 'APIFY_API_BASE_URL'
6265
API_PUBLIC_BASE_URL = 'APIFY_API_PUBLIC_BASE_URL'
66+
CHARGED_ACTOR_EVENT_COUNTS = 'APIFY_CHARGED_ACTOR_EVENT_COUNTS'
6367
DEDICATED_CPUS = 'APIFY_DEDICATED_CPUS'
6468
DEFAULT_BROWSER_PATH = 'APIFY_DEFAULT_BROWSER_PATH'
6569
DISABLE_BROWSER_SANDBOX = 'APIFY_DISABLE_BROWSER_SANDBOX'

tests/unit/actor/test_actor_env_helpers.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@ async def test_get_env_with_randomized_env_vars(monkeypatch: pytest.MonkeyPatch,
194194
# Its value is set by the _isolate_test_environment fixture to tmp_path.
195195
expected_get_env[ApifyEnvVars.LOCAL_STORAGE_DIR.name.lower()] = str(tmp_path)
196196

197+
# These env vars are not randomized above, so they fall back to their Configuration defaults.
198+
expected_get_env[ActorEnvVars.STORAGES_JSON.name.lower()] = None
199+
expected_get_env[ActorEnvVars.TEST_PAY_PER_EVENT.name.lower()] = False
200+
expected_get_env[ApifyEnvVars.ACTOR_PRICING_INFO.name.lower()] = None
201+
expected_get_env[ApifyEnvVars.CHARGED_ACTOR_EVENT_COUNTS.name.lower()] = None
202+
197203
await Actor.init()
198204
assert Actor.get_env() == expected_get_env
199205

0 commit comments

Comments
 (0)