summaryrefslogtreecommitdiffstats
path: root/lab_control/test
diff options
context:
space:
mode:
Diffstat (limited to 'lab_control/test')
-rw-r--r--lab_control/test/mocksocket.py11
-rw-r--r--lab_control/test/sds1000xe_test.py34
2 files changed, 45 insertions, 0 deletions
diff --git a/lab_control/test/mocksocket.py b/lab_control/test/mocksocket.py
new file mode 100644
index 0000000..7352846
--- /dev/null
+++ b/lab_control/test/mocksocket.py
@@ -0,0 +1,11 @@
+class MockSocket:
+ def __init__(self):
+ self.connected = False
+ self.ip = None
+ self.port = None
+
+ def connect(self, address: tuple[str, int]) -> None:
+ self.connected = True
+ self.ip = address[0]
+ self.port = address[1]
+
diff --git a/lab_control/test/sds1000xe_test.py b/lab_control/test/sds1000xe_test.py
new file mode 100644
index 0000000..1bc1888
--- /dev/null
+++ b/lab_control/test/sds1000xe_test.py
@@ -0,0 +1,34 @@
+import pytest
+
+from lab_control.sds1000xe import SDS1000XE
+from lab_control.test.mocksocket import MockSocket
+
+testIP = "127.0.0.1"
+testPort = 4000
+defaultPort = 5025
+
+@pytest.fixture
+def mockSocket():
+ return MockSocket()
+
+@pytest.fixture
+def uut(mockSocket):
+ return SDS1000XE(testIP, port=testPort, socket=mockSocket)
+
+def test_defaults():
+ mockSocket = MockSocket()
+ assert not mockSocket.connected
+ assert mockSocket.ip == None
+ assert mockSocket.port == None
+
+ uut = SDS1000XE(testIP, socket=mockSocket)
+ assert mockSocket.connected
+ assert mockSocket.ip == testIP
+ assert mockSocket.port == defaultPort
+
+def test_differentPort(uut, mockSocket):
+ assert mockSocket.connected
+ assert mockSocket.ip == testIP
+ assert mockSocket.port == testPort
+
+