summaryrefslogtreecommitdiffstats
path: root/lab_control/test
diff options
context:
space:
mode:
Diffstat (limited to 'lab_control/test')
-rw-r--r--lab_control/test/mock_jds6600_device.py2
-rw-r--r--lab_control/test/sds1000xe_test.py35
2 files changed, 20 insertions, 17 deletions
diff --git a/lab_control/test/mock_jds6600_device.py b/lab_control/test/mock_jds6600_device.py
index a37d8a8..426b8ac 100644
--- a/lab_control/test/mock_jds6600_device.py
+++ b/lab_control/test/mock_jds6600_device.py
@@ -51,8 +51,8 @@ class MockJDS6600Device():
self._channels[1].on = args[1] == "1"
# channel frequency
- # TODO implement correct behaviour
elif function == 23 or function == 24:
+ # TODO implement correct behaviour
ch = function - 23
frequency = float(args[0])
self._channels[ch].frequency = frequency
diff --git a/lab_control/test/sds1000xe_test.py b/lab_control/test/sds1000xe_test.py
index bf9c6c4..6f3de80 100644
--- a/lab_control/test/sds1000xe_test.py
+++ b/lab_control/test/sds1000xe_test.py
@@ -15,33 +15,36 @@ def mockDevice():
def uut(mockDevice):
return SDS1000XE(MOCK_DEVICE_IP)
-def checkFloatMeasurement(testCases, setValue, measureValue):
- for channel, expectedValue in testCases:
- setValue(channel, expectedValue)
- measuredValue = measureValue(channel)
- assert measuredValue == expectedValue
+def checkFloatMeasurement(testValues, setValue, measureValue):
+ for channel in SDS1000XE.AVAILABLE_CHANNELS:
+ for value in testValues:
+ setValue(channel, value)
+ measuredValue = measureValue(channel)
+ assert measuredValue == value
def test_amplitudeMeasurement(uut, mockDevice):
- testCases = [(1, 16.23987), (2, 0.0), (3, -0.0164), (4, 10.1)]
- checkFloatMeasurement(testCases, mockDevice.setAmplitude, uut.measureAmplitude)
+ testValues = [16.23987, 0.0, -0.0164, 10.1]
+ checkFloatMeasurement(testValues, mockDevice.setAmplitude, uut.measureAmplitude)
def test_peakToPeakMeasurement(uut, mockDevice):
- testCases = [(1, 16.23987), (2, 0.0), (3, -0.0164), (4, 10.1)]
- checkFloatMeasurement(testCases, mockDevice.setPeakToPeak, uut.measurePeakToPeak)
+ testValues = [16.23987, 0.0, -0.0164, 10.1]
+ checkFloatMeasurement(testValues, mockDevice.setPeakToPeak, uut.measurePeakToPeak)
def test_RMSMeasurement(uut, mockDevice):
- testCases = [(1, 16.23987), (2, 0.0), (3, -0.0164), (4, 10.1)]
- checkFloatMeasurement(testCases, mockDevice.setRMS, uut.measureRMS)
+ testValues = [16.23987, 0.0, -0.0164, 10.1]
+ checkFloatMeasurement(testValues, mockDevice.setRMS, uut.measureRMS)
def test_frequencyMeasurement(uut, mockDevice):
- testCases = [(1, 16.23987), (2, 0.0), (3, -0.0164), (4, 93489.15)]
- checkFloatMeasurement(testCases, mockDevice.setFrequency, uut.measureFrequency)
+ testValues = [16.23987, 0.0, -0.0164, 93489.15]
+ checkFloatMeasurement(testValues, mockDevice.setFrequency, uut.measureFrequency)
def test_invalidChannel(uut, mockDevice):
# Channel is checked by the UUT before the request is sent
- testCases = [0, 5]
+ testCases = [-1, 0, 5, None]
+ testMethods = [uut.measureAmplitude, uut.measurePeakToPeak, uut.measureRMS, uut.measureFrequency]
for t in testCases:
- with pytest.raises(AssertionError):
- measuredAmplitude = uut.measureAmplitude(t)
+ for m in testMethods:
+ with pytest.raises(AssertionError):
+ m(t)