Skip to content
Snippets Groups Projects

Handle concurrency while initializing activity

Merged Valentin Rigal requested to merge activities-concurrency into master
All threads resolved!
1 file
+ 6
10
Compare changes
  • Side-by-side
  • Inline
@@ -71,7 +71,8 @@ def test_readonly(responses, mock_elements_worker):
out = mock_elements_worker.update_activity("1234-deadbeef", ActivityState.Processed)
assert out is None
# update_activity returns False in very specific cases
assert out is True
assert len(responses.calls) == len(BASE_API_CALLS)
assert [
(call.request.method, call.request.url) for call in responses.calls
@@ -265,7 +266,7 @@ def test_start_activity_conflict(
)
from arkindex_worker.worker import logger
logger.warning = mocker.MagicMock()
logger.info = mocker.MagicMock()
mock_elements_worker_with_list.run()
@@ -279,14 +280,9 @@ def test_start_activity_conflict(
"http://testserver/api/v1/workers/versions/12341234-1234-1234-1234-123412341234/activity/",
),
]
assert logger.warning.call_args_list == [
mocker.call(
"Failed to update activity of element 1234-deadbeef to started due to an API error: Either this activity does not exists or this state is not allowed."
),
mocker.call(
"Cannot start processing element 1234-deadbeef due to a conflict. "
"Another process could have processed it with the same version already."
),
assert logger.info.call_args_list[:2] == [
mocker.call("Processing page Test Page n°1 (1234-deadbeef) (1/1)"),
mocker.call("Skipping element 1234-deadbeef as it was already processed"),
]
Loading