How to use generatemouseevent method in pyatom

Best Python code snippet using pyatom_python

TestCameraTool.py

Source:TestCameraTool.py Github

copy

Full Screen

1from unittest.mock import patch, MagicMock2import sys3import os4from UM.Event import MouseEvent5sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))6from UM.Math.Vector import Vector7import CameraTool8import pytest9mocked_scene = MagicMock()10def generateMouseEvent(left: bool, middle: bool, right: bool):11 event = MagicMock()12 event.buttons = []13 if left:14 event.buttons.append(MouseEvent.LeftButton)15 if middle:16 event.buttons.append(MouseEvent.MiddleButton)17 if right:18 event.buttons.append(MouseEvent.RightButton)19 return event20@pytest.fixture()21def camera_tool():22 application = MagicMock()23 controller = MagicMock()24 application.getController = MagicMock(return_value = controller)25 controller.getScene = MagicMock(return_value = mocked_scene)26 mocked_scene.reset_mock()27 with patch("UM.Application.Application.getInstance", MagicMock(return_value = application)):28 return CameraTool.CameraTool()29def test_setOrigin(camera_tool):30 # Isolation, we just want to know it gets called with the right data.31 camera_tool._rotateCamera = MagicMock()32 camera_tool.setOrigin(Vector(1, 2, 3))33 assert camera_tool.getOrigin() == Vector(1, 2, 3)34 camera_tool._rotateCamera.assert_called_with(0, 0)35@pytest.mark.parametrize("event, result", [(generateMouseEvent(True, False, False), False),36 (generateMouseEvent(False, True, False), True),37 (generateMouseEvent(False, False, True), False),38 (generateMouseEvent(True, False, True), False),39 (generateMouseEvent(False, False, False), False),40 ])41def test_moveEvent(camera_tool, event, result):42 assert camera_tool.moveEvent(event) == result43@pytest.mark.parametrize("event, result", [(generateMouseEvent(True, False, False), True),44 (generateMouseEvent(False, True, False), True),45 (generateMouseEvent(False, False, True), True),46 (generateMouseEvent(True, False, True), True),47 (generateMouseEvent(False, False, False), False), # Only the no button pressed case should be false48 ])49def test_moveEventShiftActive(camera_tool, event, result):50 camera_tool._shift_is_active = True...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pyatom automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful