Skip to content

Commit 18f4f51

Browse files
committed
Update client names in tests to match their type
1 parent a3a629e commit 18f4f51

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

tests/unit/test_logging.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ async def test_redirected_logs_async(
208208

209209
with caplog.at_level(logging.DEBUG, logger=logger_name):
210210
async with streamed_log:
211-
# Do stuff while the log from the other actor is being redirected to the logs.
211+
# Do stuff while the log from the other Actor is being redirected to the logs.
212212
await asyncio.sleep(2)
213213

214214
assert len(caplog.records) == expected_log_count
@@ -246,7 +246,7 @@ def test_redirected_logs_sync(
246246
logger_name = f'apify.{_MOCKED_ACTOR_NAME}-{_MOCKED_RUN_ID}'
247247

248248
with caplog.at_level(logging.DEBUG, logger=logger_name), streamed_log:
249-
# Do stuff while the log from the other actor is being redirected to the logs.
249+
# Do stuff while the log from the other Actor is being redirected to the logs.
250250
time.sleep(2)
251251

252252
assert len(caplog.records) == expected_log_count
@@ -267,10 +267,10 @@ async def test_actor_call_redirect_logs_to_default_logger_async(
267267
Caplog contains logs before formatting, so formatting is not included in the test expectations."""
268268
logger_name = f'apify.{_MOCKED_ACTOR_NAME}-{_MOCKED_RUN_ID}'
269269
logger = logging.getLogger(logger_name)
270-
run_client = ApifyClientAsync(token='mocked_token', api_url=_MOCKED_API_URL).actor(actor_id=_MOCKED_ACTOR_ID)
270+
actor_client = ApifyClientAsync(token='mocked_token', api_url=_MOCKED_API_URL).actor(actor_id=_MOCKED_ACTOR_ID)
271271

272272
with caplog.at_level(logging.DEBUG, logger=logger_name):
273-
await run_client.call()
273+
await actor_client.call()
274274

275275
# Ensure expected handler and formater
276276
assert isinstance(logger.handlers[0].formatter, RedirectLogFormatter)
@@ -295,10 +295,10 @@ def test_actor_call_redirect_logs_to_default_logger_sync(
295295
Caplog contains logs before formatting, so formatting is not included in the test expectations."""
296296
logger_name = f'apify.{_MOCKED_ACTOR_NAME}-{_MOCKED_RUN_ID}'
297297
logger = logging.getLogger(logger_name)
298-
run_client = ApifyClient(token='mocked_token', api_url=_MOCKED_API_URL).actor(actor_id=_MOCKED_ACTOR_ID)
298+
actor_client = ApifyClient(token='mocked_token', api_url=_MOCKED_API_URL).actor(actor_id=_MOCKED_ACTOR_ID)
299299

300300
with caplog.at_level(logging.DEBUG, logger=logger_name):
301-
run_client.call()
301+
actor_client.call()
302302

303303
# Ensure expected handler and formater
304304
assert isinstance(logger.handlers[0].formatter, RedirectLogFormatter)
@@ -318,10 +318,10 @@ async def test_actor_call_no_redirect_logs_async(
318318
propagate_stream_logs: None, # noqa: ARG001, fixture
319319
) -> None:
320320
logger_name = f'apify.{_MOCKED_ACTOR_NAME}-{_MOCKED_RUN_ID}'
321-
run_client = ApifyClientAsync(token='mocked_token', api_url=_MOCKED_API_URL).actor(actor_id=_MOCKED_ACTOR_ID)
321+
actor_client = ApifyClientAsync(token='mocked_token', api_url=_MOCKED_API_URL).actor(actor_id=_MOCKED_ACTOR_ID)
322322

323323
with caplog.at_level(logging.DEBUG, logger=logger_name):
324-
await run_client.call(logger=None)
324+
await actor_client.call(logger=None)
325325

326326
assert len(caplog.records) == 0
327327

@@ -333,10 +333,10 @@ def test_actor_call_no_redirect_logs_sync(
333333
propagate_stream_logs: None, # noqa: ARG001, fixture
334334
) -> None:
335335
logger_name = f'apify.{_MOCKED_ACTOR_NAME}-{_MOCKED_RUN_ID}'
336-
run_client = ApifyClient(token='mocked_token', api_url=_MOCKED_API_URL).actor(actor_id=_MOCKED_ACTOR_ID)
336+
actor_client = ApifyClient(token='mocked_token', api_url=_MOCKED_API_URL).actor(actor_id=_MOCKED_ACTOR_ID)
337337

338338
with caplog.at_level(logging.DEBUG, logger=logger_name):
339-
run_client.call(logger=None)
339+
actor_client.call(logger=None)
340340

341341
assert len(caplog.records) == 0
342342

@@ -351,10 +351,10 @@ async def test_actor_call_redirect_logs_to_custom_logger_async(
351351
"""Test that logs are redirected correctly to the custom logger."""
352352
logger_name = 'custom_logger'
353353
logger = logging.getLogger(logger_name)
354-
run_client = ApifyClientAsync(token='mocked_token', api_url=_MOCKED_API_URL).actor(actor_id=_MOCKED_ACTOR_ID)
354+
actor_client = ApifyClientAsync(token='mocked_token', api_url=_MOCKED_API_URL).actor(actor_id=_MOCKED_ACTOR_ID)
355355

356356
with caplog.at_level(logging.DEBUG, logger=logger_name):
357-
await run_client.call(logger=logger)
357+
await actor_client.call(logger=logger)
358358

359359
assert len(caplog.records) == len(_EXPECTED_MESSAGES_AND_LEVELS_WITH_STATUS_MESSAGES)
360360
for expected_message_and_level, record in zip(_EXPECTED_MESSAGES_AND_LEVELS_WITH_STATUS_MESSAGES, caplog.records):
@@ -372,10 +372,10 @@ def test_actor_call_redirect_logs_to_custom_logger_sync(
372372
"""Test that logs are redirected correctly to the custom logger."""
373373
logger_name = 'custom_logger'
374374
logger = logging.getLogger(logger_name)
375-
run_client = ApifyClient(token='mocked_token', api_url=_MOCKED_API_URL).actor(actor_id=_MOCKED_ACTOR_ID)
375+
actor_client = ApifyClient(token='mocked_token', api_url=_MOCKED_API_URL).actor(actor_id=_MOCKED_ACTOR_ID)
376376

377377
with caplog.at_level(logging.DEBUG, logger=logger_name):
378-
run_client.call(logger=logger)
378+
actor_client.call(logger=logger)
379379

380380
assert len(caplog.records) == len(_EXPECTED_MESSAGES_AND_LEVELS_WITH_STATUS_MESSAGES)
381381
for expected_message_and_level, record in zip(_EXPECTED_MESSAGES_AND_LEVELS_WITH_STATUS_MESSAGES, caplog.records):
@@ -400,7 +400,7 @@ async def test_redirect_status_message_async(
400400
status_message_redirector = await run_client.get_status_message_redirector(check_period=timedelta(seconds=0))
401401
with caplog.at_level(logging.DEBUG, logger=logger_name):
402402
async with status_message_redirector:
403-
# Do stuff while the status from the other actor is being redirected to the logs.
403+
# Do stuff while the status from the other Actor is being redirected to the logs.
404404
await asyncio.sleep(3)
405405

406406
assert caplog.records[0].message == 'Status: RUNNING, Message: Initial message'
@@ -424,7 +424,7 @@ def test_redirect_status_message_sync(
424424

425425
status_message_redirector = run_client.get_status_message_redirector(check_period=timedelta(seconds=0))
426426
with caplog.at_level(logging.DEBUG, logger=logger_name), status_message_redirector:
427-
# Do stuff while the status from the other actor is being redirected to the logs.
427+
# Do stuff while the status from the other Actor is being redirected to the logs.
428428
time.sleep(3)
429429

430430
assert caplog.records[0].message == 'Status: RUNNING, Message: Initial message'

0 commit comments

Comments
 (0)