1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
from unittest import TestCase
from unittest.mock import MagicMock, patch
from UM.Qt.Bindings.OutputDeviceManagerProxy import OutputDeviceManagerProxy
class TestOutputDeviceManagerProxy(TestCase):
proxy = None
mock_application = None
mocked_device_manager = None
def setUp(self):
# These objects only need to be set / created once.
if TestOutputDeviceManagerProxy.proxy is None:
TestOutputDeviceManagerProxy.mock_application = MagicMock()
TestOutputDeviceManagerProxy.mocked_device_manager = MagicMock()
self.mock_application.getOutputDeviceManager = MagicMock(return_value = self.mocked_device_manager)
with patch("UM.Application.Application.getInstance", MagicMock(return_value=self.mock_application)):
TestOutputDeviceManagerProxy.proxy = OutputDeviceManagerProxy()
def tearDown(self):
pass
def test_startAndRefreshDiscovery(self):
self.proxy.startDiscovery()
assert self.mocked_device_manager.startDiscovery.call_count == 1
self.proxy.refreshConnections()
assert self.mocked_device_manager.refreshConnections.call_count == 1
|