Skip to content

Commit f0a42bc

Browse files
vdusekclaude
andcommitted
test: revert unnecessary changes to test_actor_log.py
The original strict assertions (exact count, initialization log messages, index-based ordering) are valid and more thorough. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b906305 commit f0a42bc

File tree

4 files changed

+21
-132
lines changed

4 files changed

+21
-132
lines changed

tests/unit/actor/test_actor_log.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,15 @@ async def test_actor_logs_messages_correctly(caplog: pytest.LogCaptureFixture) -
3838

3939
records = caplog.records
4040

41+
# Expected number of log records
42+
assert len(records) == 13
43+
4144
expected_logs = [
45+
(logging.INFO, 'Initializing Actor'),
46+
(logging.DEBUG, 'Configuration initialized'),
47+
(logging.DEBUG, 'Storage client initialized'),
48+
(logging.DEBUG, 'Event manager initialized'),
49+
(logging.DEBUG, 'Charging manager initialized'),
4250
(logging.DEBUG, 'Debug message'),
4351
(logging.INFO, 'Info message'),
4452
(logging.WARNING, 'Warning message'),
@@ -50,10 +58,9 @@ async def test_actor_logs_messages_correctly(caplog: pytest.LogCaptureFixture) -
5058
]
5159

5260
for level, message, *exception in expected_logs:
53-
matching = [r for r in records if r.message == message]
54-
assert len(matching) == 1, f'Expected exactly one log record with message {message!r}, found {len(matching)}'
55-
record = matching[0]
61+
record = records.pop(0)
5662
assert record.levelno == level
63+
assert record.message == message
5764
if exception:
5865
assert record.exc_info is not None
5966
assert record.exc_info[0] is type(exception[0])

tests/unit/actor/test_configuration.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,19 @@ def test_apify_configuration_is_always_used(caplog: pytest.LogCaptureFixture) ->
243243
) in caplog.messages
244244

245245

246-
def test_token_from_env_var(monkeypatch: pytest.MonkeyPatch) -> None:
247-
"""Test that token is populated from APIFY_TOKEN env var."""
246+
def test_env_vars_populate_correctly(monkeypatch: pytest.MonkeyPatch) -> None:
247+
"""Test that configuration values are populated from environment variables."""
248248
monkeypatch.setenv('APIFY_TOKEN', 'my-test-token')
249+
monkeypatch.setenv('APIFY_ACTOR_ID', 'actor-123')
250+
monkeypatch.setenv('APIFY_ACT_RUN_ID', 'run-456')
251+
monkeypatch.setenv('APIFY_IS_AT_HOME', '1')
252+
monkeypatch.setenv('APIFY_API_BASE_URL', 'https://custom-api.apify.com')
249253
config = ApifyConfiguration()
250254
assert config.token == 'my-test-token'
255+
assert config.actor_id == 'actor-123'
256+
assert config.actor_run_id == 'run-456'
257+
assert config.is_at_home is True
258+
assert config.api_base_url == 'https://custom-api.apify.com'
251259

252260

253261
def test_default_values() -> None:
@@ -266,19 +274,6 @@ def test_default_values() -> None:
266274
assert config.test_pay_per_event is False
267275

268276

269-
def test_env_var_aliases_populate_correctly(monkeypatch: pytest.MonkeyPatch) -> None:
270-
"""Test that env var aliases are resolved correctly."""
271-
monkeypatch.setenv('APIFY_ACTOR_ID', 'actor-123')
272-
monkeypatch.setenv('APIFY_ACT_RUN_ID', 'run-456')
273-
monkeypatch.setenv('APIFY_IS_AT_HOME', '1')
274-
monkeypatch.setenv('APIFY_API_BASE_URL', 'https://custom-api.apify.com')
275-
config = ApifyConfiguration()
276-
assert config.actor_id == 'actor-123'
277-
assert config.actor_run_id == 'run-456'
278-
assert config.is_at_home is True
279-
assert config.api_base_url == 'https://custom-api.apify.com'
280-
281-
282277
def test_max_total_charge_usd_decimal_parsing(monkeypatch: pytest.MonkeyPatch) -> None:
283278
"""Test that max_total_charge_usd is parsed as Decimal from env var."""
284279
from decimal import Decimal

tests/unit/test_crypto.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def test_crypto_random_object_id_length_and_charset() -> None:
112112
assert len(crypto_random_object_id(5)) == 5
113113
long_random_object_id = crypto_random_object_id(1000)
114114
for char in long_random_object_id:
115-
assert char in '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
115+
assert char in 'abcdefghijklmnopqrstuvwxyzABCEDFGHIJKLMNOPQRSTUVWXYZ0123456789'
116116

117117

118118
@pytest.mark.parametrize(('test_input', 'expected'), [(0, '0'), (10, 'a'), (999999999, '15FTGf')])

tests/unit/test_models.py

Lines changed: 0 additions & 113 deletions
This file was deleted.

0 commit comments

Comments
 (0)