Fix some tests not cleaning up correctly after themselves

The PrintInformation test wasn't cleaning up after itself correclty. This
left some stuff behind that the other tests were using. Since this is bad (as at that point
tests can influence other tests), i've fixed that
This commit is contained in:
Jaime van Kessel 2019-12-24 16:20:09 +01:00
parent 04125d4608
commit 0862fd493e
No known key found for this signature in database
GPG key ID: 3710727397403C91
6 changed files with 37 additions and 26 deletions

View file

@ -1,5 +1,5 @@
import time
from unittest.mock import MagicMock
from unittest.mock import MagicMock, patch
from PyQt5.QtNetwork import QNetworkAccessManager
from PyQt5.QtCore import QUrl
@ -9,8 +9,8 @@ from cura.PrinterOutput.PrinterOutputDevice import ConnectionState
def test_properties():
properties = { b"firmware_version": b"12", b"printer_type": b"BHDHAHHADAD", b"address": b"ZOMG", b"name": b":(", b"testProp": b"zomg"}
output_device = NetworkedPrinterOutputDevice(device_id = "test", address = "127.0.0.1", properties = properties)
with patch("UM.Qt.QtApplication.QtApplication.getInstance"):
output_device = NetworkedPrinterOutputDevice(device_id = "test", address = "127.0.0.1", properties = properties)
assert output_device.address == "ZOMG"
assert output_device.firmwareVersion == "12"
assert output_device.printerType == "BHDHAHHADAD"
@ -24,7 +24,8 @@ def test_properties():
def test_authenticationState():
output_device = NetworkedPrinterOutputDevice(device_id="test", address="127.0.0.1", properties={})
with patch("UM.Qt.QtApplication.QtApplication.getInstance"):
output_device = NetworkedPrinterOutputDevice(device_id="test", address="127.0.0.1", properties={})
output_device.setAuthenticationState(AuthState.Authenticated)
@ -32,7 +33,8 @@ def test_authenticationState():
def test_post():
output_device = NetworkedPrinterOutputDevice(device_id="test", address="127.0.0.1", properties={})
with patch("UM.Qt.QtApplication.QtApplication.getInstance"):
output_device = NetworkedPrinterOutputDevice(device_id="test", address="127.0.0.1", properties={})
mocked_network_manager = MagicMock()
output_device._manager = mocked_network_manager
@ -53,7 +55,8 @@ def test_post():
def test_get():
output_device = NetworkedPrinterOutputDevice(device_id="test", address="127.0.0.1", properties={})
with patch("UM.Qt.QtApplication.QtApplication.getInstance"):
output_device = NetworkedPrinterOutputDevice(device_id="test", address="127.0.0.1", properties={})
mocked_network_manager = MagicMock()
output_device._manager = mocked_network_manager
@ -74,7 +77,8 @@ def test_get():
def test_delete():
output_device = NetworkedPrinterOutputDevice(device_id="test", address="127.0.0.1", properties={})
with patch("UM.Qt.QtApplication.QtApplication.getInstance"):
output_device = NetworkedPrinterOutputDevice(device_id="test", address="127.0.0.1", properties={})
mocked_network_manager = MagicMock()
output_device._manager = mocked_network_manager
@ -95,7 +99,8 @@ def test_delete():
def test_put():
output_device = NetworkedPrinterOutputDevice(device_id="test", address="127.0.0.1", properties={})
with patch("UM.Qt.QtApplication.QtApplication.getInstance"):
output_device = NetworkedPrinterOutputDevice(device_id="test", address="127.0.0.1", properties={})
mocked_network_manager = MagicMock()
output_device._manager = mocked_network_manager
@ -116,7 +121,8 @@ def test_put():
def test_timeout():
output_device = NetworkedPrinterOutputDevice(device_id="test", address="127.0.0.1", properties={})
with patch("UM.Qt.QtApplication.QtApplication.getInstance"):
output_device = NetworkedPrinterOutputDevice(device_id="test", address="127.0.0.1", properties={})
output_device.setConnectionState(ConnectionState.Connected)
assert output_device.connectionState == ConnectionState.Connected