Skip to content
Snippets Groups Projects
Commit 4f5286be authored by Janet Goldstein's avatar Janet Goldstein
Browse files

WS-693: leave broken execution manager tests as TODOs

parent 3f44f5d4
No related branches found
No related tags found
1 merge request!556WS-693: leave broken execution manager tests as TODOs
Pipeline #3172 passed
""" Tests for the execution manager """
""" Tests for the execution manager. Only one is feasible; due to massive refactoring,
tests other than test_advance_execution are broken need to be fixed Some Fine Day.
"""
import logging
import sys
from typing import Dict, List
from unittest.mock import patch
# pylint: disable=E0401, W0212, W0621
# pylint: disable=E0401, W0212, W0511, W0621
import pytest
from _pytest.logging import LogCaptureFixture
from messaging.router import Router
from messaging.messenger import SenderIF
from testing.utils.conftest import MockMessageSender
from workspaces.capability.enums import CapabilityRequestState, ExecutionState
from workspaces.capability.helpers import CapabilitySequence
from workspaces.capability.schema import CapabilityExecution, CapabilityRequest
......@@ -105,7 +110,7 @@ def step_complete_message(mock_capability_execution: CapabilityExecution) -> Dic
"type": "step-complete",
}
# TODO: rewrite test so it works
@pytest.mark.skip("Broken due to queue/messenger rework")
def test_run_capability(
mock_capability_info: CapabilityInfo,
......@@ -135,7 +140,7 @@ def test_run_capability(
assert len(dummy_execution_manager.execution_pool) == 1
assert test_execution.state == ExecutionState.Waiting.name
# TODO: rewrite test so it works
@pytest.mark.skip("Broken due to queue/messenger rework")
def test_send_step_complete_workflow_executing(
dummy_execution_manager: ExecutionManager,
......@@ -153,7 +158,7 @@ def test_send_step_complete_workflow_executing(
# Reset state of mock execution
mock_capability_execution.current_step_idx = 0
# TODO: rewrite test so it works
@pytest.mark.skip("Broken due to queue/messenger rework")
def test_send_step_complete_workflow_complete(
dummy_execution_manager: ExecutionManager,
......@@ -171,7 +176,7 @@ def test_send_step_complete_workflow_complete(
# Reset state of mock execution
mock_capability_execution.current_step_idx = 0
# TODO: rewrite test so it works
@pytest.mark.skip("Broken due to queue/messenger rework")
def test_on_step_complete(
dummy_execution_manager: ExecutionManager,
......@@ -223,17 +228,19 @@ def test_on_step_complete_unrecognized(
assert "Unrecognized message type: Unrecognizable." in messages
# TODO: rewrite test so it works
@pytest.mark.skip("Broken due to queue/messenger rework")
def test_advance_execution(
dummy_execution_manager: ExecutionManager,
mock_capability_execution: CapabilityExecution,
test_message_sender: MockMessageSender,
):
"""
Tests that an execution is properly advanced to its next step
"""
step_sequence = CapabilitySequence.from_str(mock_capability_execution.steps)
assert mock_capability_execution.current_step_idx == 0
dummy_execution_manager._advance_execution(mock_capability_execution, step_sequence)
dummy_execution_manager.messenger = test_message_sender
dummy_execution_manager._advance_execution(mock_capability_execution)
assert mock_capability_execution.current_step_idx == 1
assert mock_capability_execution.on_last_step()
......@@ -257,6 +264,7 @@ def test_advance_execution(
mock_capability_execution.current_step_idx = 0
# TODO: rewrite test so it works
@pytest.mark.skip("Broken due to queue/messenger rework")
def test_complete_execution(dummy_execution_manager: ExecutionManager, mock_capability_execution: CapabilityExecution):
"""
......@@ -282,6 +290,7 @@ def test_complete_execution(dummy_execution_manager: ExecutionManager, mock_capa
mock_capability_execution.current_step_idx = 0
# TODO: rewrite test so it works
@pytest.mark.skip("Broken due to queue/messenger rework")
def test_enqueue_execution(dummy_execution_manager: ExecutionManager, mock_capability_execution: CapabilityExecution):
"""
......
......@@ -17,6 +17,8 @@ from typing import Any, List, Union
from unittest import mock
from unittest.mock import MagicMock, patch
# pylint: disable=C0103, E0401, R0903, W0621
import pytest
from messaging.router import Router
from mock_alchemy.mocking import UnifiedAlchemyMagicMock
......@@ -214,6 +216,13 @@ def mock_capability_requests(
def mock_workflow_requests(
mock_workflow_service: WorkflowService, mock_workflow_info: WorkflowInfoIF
) -> List[WorkflowRequestIF]:
"""
Make us some mock workflow requests for testing.
:param mock_workflow_service:
:param mock_workflow_info:
:return:
"""
requests = []
r1 = WorkflowRequest(
......@@ -270,9 +279,17 @@ def mock_capability_execution(mock_capability_info: CapabilityInfo, mock_capabil
class MockMessageSender:
"""Pretends to send a message"""
destination = None
def send_message(self, **message):
"""
Don't send this message, but play it on TV
:param message: message to send as Dict
:return:
"""
print(f"sending message: {message}")
self.destination.receive_message(json.dumps(message))
......
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