summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lab_control/connection/direct_connection.py6
-rw-r--r--lab_control/connection/serial_connection.py8
-rw-r--r--lab_control/connection/tcp_connection.py5
-rw-r--r--lab_control/test/jds6600_unittest.py11
4 files changed, 11 insertions, 19 deletions
diff --git a/lab_control/connection/direct_connection.py b/lab_control/connection/direct_connection.py
index 8df1e42..0ea2ea3 100644
--- a/lab_control/connection/direct_connection.py
+++ b/lab_control/connection/direct_connection.py
@@ -12,9 +12,3 @@ class DirectConnection:
def send(self, request: str, responseExpected=True) -> str:
return self.requestHandler(request)
-
- def checkConfiguration(self) -> None:
- assert self.config.get("baudrate") == 115200
- assert self.config.get("bytesize") == 8
- assert self.config.get("stopbits") == 1
- assert self.config.get("parity") == "N"
diff --git a/lab_control/connection/serial_connection.py b/lab_control/connection/serial_connection.py
index 282494b..2e48d56 100644
--- a/lab_control/connection/serial_connection.py
+++ b/lab_control/connection/serial_connection.py
@@ -6,10 +6,10 @@ class SerialConnection:
self._port = serial.Serial(portName)
def configure(self, config: dict) -> None:
- self._port.baudrate = parameters["baudrate"]
- self._port.bytesize = parameters["bytesize"]
- self._port.stopbits = parameters["stopbits"]
- self._port.parity = parameters["parity"]
+ self._port.baudrate = config["baudrate"]
+ self._port.bytesize = config["bytesize"]
+ self._port.stopbits = config["stopbits"]
+ self._port.parity = config["parity"]
def send(self, request):
self._port.write(request.encode())
diff --git a/lab_control/connection/tcp_connection.py b/lab_control/connection/tcp_connection.py
index 6af710c..bdbf811 100644
--- a/lab_control/connection/tcp_connection.py
+++ b/lab_control/connection/tcp_connection.py
@@ -6,7 +6,7 @@ class TCPConnection:
self._socket.connect((address, port))
def configure(self, config: dict) -> None:
- self._socket.settimeout(parameters["timeout"])
+ self._socket.settimeout(config["timeout"])
def send(self, request, responseExpected=True):
self._socket.sendall(request.encode())
@@ -17,6 +17,3 @@ class TCPConnection:
except TimeoutError:
response = None
return response
-
- def checkConfiguration(self) -> None:
- pass
diff --git a/lab_control/test/jds6600_unittest.py b/lab_control/test/jds6600_unittest.py
index 476514b..5b34fce 100644
--- a/lab_control/test/jds6600_unittest.py
+++ b/lab_control/test/jds6600_unittest.py
@@ -31,13 +31,14 @@ def checkInvalidNumericalParameter(testValues, writeValue, valueInMock):
writeValue(ch, value)
def test_serialPortConfiguration(mockConnection):
- with pytest.raises(AssertionError):
- mockConnection.checkConfiguration()
+ assert mockConnection.config == {}
uut = JDS6600("", mockConnection)
- mockConnection.checkConfiguration()
-
- uut.closePort()
+
+ assert mockConnection.config.get("baudrate") == 115200
+ assert mockConnection.config.get("bytesize") == 8
+ assert mockConnection.config.get("stopbits") == 1
+ assert mockConnection.config.get("parity") == "N"
def test_channelOnAndOff(uut, mockDevice):
for ch in JDS6600.AVAILABLE_CHANNELS: