mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 15:07:28 -06:00
Patch CuraApplication away while running tests for output devices
It needs CuraApplication because it wants to set metadata on the printer. But this is not relevant for the tests. Contributes to issue CURA-8609.
This commit is contained in:
parent
24cd2046f8
commit
a399bacab3
2 changed files with 13 additions and 8 deletions
|
@ -1,3 +1,6 @@
|
|||
# Copyright (c) 2021 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
import time
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
|
@ -122,8 +125,9 @@ def test_put():
|
|||
|
||||
def test_timeout():
|
||||
with patch("UM.Qt.QtApplication.QtApplication.getInstance"):
|
||||
output_device = NetworkedPrinterOutputDevice(device_id="test", address="127.0.0.1", properties={})
|
||||
output_device.setConnectionState(ConnectionState.Connected)
|
||||
output_device = NetworkedPrinterOutputDevice(device_id = "test", address = "127.0.0.1", properties = {})
|
||||
with patch("cura.CuraApplication.CuraApplication.getInstance"):
|
||||
output_device.setConnectionState(ConnectionState.Connected)
|
||||
|
||||
assert output_device.connectionState == ConnectionState.Connected
|
||||
output_device._update()
|
||||
|
@ -131,9 +135,8 @@ def test_timeout():
|
|||
output_device._last_response_time = time.time() - 15
|
||||
# But we did recently ask for a response!
|
||||
output_device._last_request_time = time.time() - 5
|
||||
output_device._update()
|
||||
with patch("cura.CuraApplication.CuraApplication.getInstance"):
|
||||
output_device._update()
|
||||
|
||||
# The connection should now be closed, since it went into timeout.
|
||||
assert output_device.connectionState == ConnectionState.Closed
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue