Skip to content
Snippets Groups Projects
Commit bd5d15ae authored by Valentin Rigal's avatar Valentin Rigal
Browse files

Update existing tests

parent 00e45a11
No related branches found
No related tags found
No related merge requests found
...@@ -202,6 +202,18 @@ def mock_user_api(responses): ...@@ -202,6 +202,18 @@ def mock_user_api(responses):
) )
@pytest.fixture
def mock_activity_calls(responses):
"""
Mock responses when updating the activity state for multiple element of the same version
"""
responses.add(
responses.PUT,
"http://testserver/api/v1/workers/versions/12341234-1234-1234-1234-123412341234/activity/",
status=200,
)
@pytest.fixture @pytest.fixture
def mock_elements_worker(monkeypatch, mock_config_api): def mock_elements_worker(monkeypatch, mock_config_api):
"""Build and configure an ElementsWorker with fixed CLI parameters to avoid issues with pytest""" """Build and configure an ElementsWorker with fixed CLI parameters to avoid issues with pytest"""
......
...@@ -169,7 +169,12 @@ def test_update_call(responses, mock_elements_worker, mock_process_api): ...@@ -169,7 +169,12 @@ def test_update_call(responses, mock_elements_worker, mock_process_api):
], ],
) )
def test_run( def test_run(
monkeypatch, mock_elements_worker, responses, process_exception, final_state monkeypatch,
mock_elements_worker,
responses,
process_exception,
final_state,
mock_activity_calls,
): ):
"""Check the normal runtime sends 2 API calls to update activity""" """Check the normal runtime sends 2 API calls to update activity"""
# Disable second configure call from run() # Disable second configure call from run()
...@@ -193,29 +198,6 @@ def test_run( ...@@ -193,29 +198,6 @@ def test_run(
"name": "Test Page n°1", "name": "Test Page n°1",
}, },
) )
# Mock Update activity
responses.add(
responses.PUT,
"http://testserver/api/v1/workers/versions/12341234-1234-1234-1234-123412341234/activity/",
status=200,
json={
"element_id": "1234-deadbeef",
"process_id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeffff",
"state": "started",
},
)
responses.add(
responses.PUT,
"http://testserver/api/v1/workers/versions/12341234-1234-1234-1234-123412341234/activity/",
status=200,
json={
"element_id": "1234-deadbeef",
"process_id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeffff",
"state": final_state,
},
)
assert mock_elements_worker.is_read_only is False assert mock_elements_worker.is_read_only is False
# Mock exception in process_element # Mock exception in process_element
...@@ -262,7 +244,7 @@ def test_run( ...@@ -262,7 +244,7 @@ def test_run(
def test_run_cache( def test_run_cache(
monkeypatch, mocker, mock_elements_worker_with_cache, mock_cached_elements monkeypatch, mocker, mock_elements_worker_with_cache, mock_cached_elements, mock_activity_calls,
): ):
# Disable second configure call from run() # Disable second configure call from run()
monkeypatch.setattr(mock_elements_worker_with_cache, "configure", lambda: None) monkeypatch.setattr(mock_elements_worker_with_cache, "configure", lambda: None)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment