Beispiel #1
0
def test_matches_callable():
    target_action = Mock(spec=ExecuteProcess)
    handler = OnProcessStart(target_action=target_action, on_start=Mock())
    assert handler.matches(
        ProcessStarted(action=target_action,
                       name='foo',
                       cmd=['ls'],
                       cwd=None,
                       env=None,
                       pid=3))
    assert handler.matches(phony_process_started)
    assert not handler.matches(phony_process_exited)
# See the License for the specific language governing permissions and
# limitations under the License.
"""Tests for the OnIncludeLaunchDescription event handler."""

from unittest.mock import Mock

from launch import LaunchContext
from launch import LaunchDescription
from launch.action import Action
from launch.event_handlers.on_include_launch_description import OnIncludeLaunchDescription
from launch.events import IncludeLaunchDescription
from launch.events.process import ProcessStarted

phony_process_started = ProcessStarted(action=Mock(spec=Action),
                                       name='PhonyProcessStarted',
                                       cmd=['ls'],
                                       cwd=None,
                                       env=None,
                                       pid=1)
phony_include_launch_description = IncludeLaunchDescription(
    launch_description=Mock(spec=LaunchDescription))
phony_context = Mock(spec=LaunchContext)


def test_matches_include_launch_description():
    handler = OnIncludeLaunchDescription()
    assert handler.matches(phony_include_launch_description)
    assert not handler.matches(phony_process_started)


def test_event_added_to_context():
    context = Mock(spec=LaunchContext)