Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/apify/_charging.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ async def __aenter__(self) -> None:
if self._configuration.test_pay_per_event:
self._pricing_model = 'PAY_PER_EVENT'
else:
self._pricing_model = pricing_info.pricing_model if pricing_info else None
self._pricing_model = pricing_info.pricing_model if pricing_info is not None else None

# Load per-event pricing information
if pricing_info and pricing_info.pricing_model == 'PAY_PER_EVENT':
for event_name, event_pricing in pricing_info.pricing_per_event.actor_charge_events.items(): # ty:ignore[possibly-missing-attribute]
if pricing_info is not None and isinstance(pricing_info, PayPerEventActorPricingInfo):
for event_name, event_pricing in pricing_info.pricing_per_event.actor_charge_events.items():
self._pricing_info[event_name] = PricingInfoItem(
price=event_pricing.event_price_usd,
title=event_pricing.event_title,
Expand Down
17 changes: 13 additions & 4 deletions tests/integration/test_request_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from ._utils import generate_unique_resource_name
from apify import Actor, Request
from apify.storage_clients import ApifyStorageClient
from apify.storage_clients._apify import ApifyRequestQueueClient
from apify.storage_clients._apify._utils import unique_key_to_request_id
from apify.storages import RequestQueue

Expand Down Expand Up @@ -683,7 +684,7 @@ async def test_request_deduplication_edge_cases(
"""Test edge cases in request deduplication."""
rq_access_mode = request.node.callspec.params.get('request_queue_apify')
if rq_access_mode == 'shared':
pytest.skip('Test is flaky, see https://github.com/apify/apify-sdk-python/issues/786')
pytest.skip(reason='Test is flaky, see https://github.com/apify/apify-sdk-python/issues/786') # ty: ignore[invalid-argument-type, parameter-already-assigned]

rq = request_queue_apify
Actor.log.info('Request queue opened')
Expand Down Expand Up @@ -1218,17 +1219,25 @@ async def test_request_queue_api_fail_when_marking_as_handled(
# Fetch request
await rq.add_request(request)
assert request == await rq.fetch_next_request()
assert isinstance(rq._client, ApifyRequestQueueClient)

# Mark as handled, but simulate API failure.
with mock.patch.object(
rq._client._api_client, 'update_request', side_effect=Exception('Simulated API failure')
rq._client._api_client,
'update_request',
side_effect=Exception('Simulated API failure'),
):
await rq.mark_request_as_handled(request)
assert not (await rq.get_request(request.unique_key)).was_already_handled

request = await rq.get_request(request.unique_key)
assert request is not None
assert not request.was_already_handled

# RQ with `request_queue_access="single"` knows, that the local information is reliable, so it knows it
# handled this request already despite the platform not being aware of it.
assert not await rq.fetch_next_request()
next_request = await rq.fetch_next_request()
assert next_request is None

assert await rq.is_finished()
assert await rq.is_empty()

Expand Down
Loading
Loading