Commit be7c998e authored by auke.klazema's avatar auke.klazema

Rename of PrologixGpiUsb Class

parent 28c322a9
......@@ -4,7 +4,7 @@ import re
import platform
class PROLOGIX_GPIB_USB():
class PrologixGpibUsb():
def __init__(self, port="", timeout=1, portFormat="%d", maxDeviceNum=9, verbose=False,
findDevices=False):
if port == "":
......
......@@ -7,7 +7,7 @@ import time
##import kapteyn
p=hpib.PROLOGIX_GPIB_USB()
p=hpib.PrologixGpibUsb()
sml=hpib.hpib_device(28,p)
smx=hpib.hpib_device(14,p)
esmc=hpib.hpib_device(1,p)
......
......@@ -17,19 +17,19 @@ class PrologixGpibUsbTest(unittest.TestCase):
self.platform_mock.system.return_value = "Linux"
def test_when_platform_linux_port_gets_set_to_ttyusb0(self):
hpib.PROLOGIX_GPIB_USB()
hpib.PrologixGpibUsb()
self.serial_mock.assert_called_with('/dev/ttyUSB0', timeout=1)
def test_when_platform_darwin_port_gets_set_to_ttys000(self):
self.platform_mock.system.return_value = "Darwin"
hpib.PROLOGIX_GPIB_USB()
hpib.PrologixGpibUsb()
self.serial_mock.assert_called_with('/dev/ttys000', timeout=1)
def test_getDevices_returns_not_scanned_when_find_devices_is_false(self):
usb = hpib.PROLOGIX_GPIB_USB(findDevices=False)
usb = hpib.PrologixGpibUsb(findDevices=False)
self.assertEqual(usb.getDevices(), 'Not scanned.')
......@@ -37,13 +37,13 @@ class PrologixGpibUsbTest(unittest.TestCase):
self.serial_mock.side_effect = SerialException
with self.assertRaises(SerialException):
hpib.PROLOGIX_GPIB_USB()
hpib.PrologixGpibUsb()
def test_when_platform_linux_last_port_tried_is_ttyusb98(self):
self.serial_mock.side_effect = SerialException
with self.assertRaises(SerialException):
hpib.PROLOGIX_GPIB_USB()
hpib.PrologixGpibUsb()
self.serial_mock.assert_called_with('/dev/ttyUSB98', timeout=1)
......@@ -52,14 +52,14 @@ class PrologixGpibUsbTest(unittest.TestCase):
self.serial_mock.side_effect = SerialException
with self.assertRaises(SerialException):
hpib.PROLOGIX_GPIB_USB()
hpib.PrologixGpibUsb()
self.serial_mock.assert_called_with('/dev/ttys998', timeout=1)
def test_setup_device_when_port_found(self):
write_mock = self.serial_mock.return_value.write
hpib.PROLOGIX_GPIB_USB()
hpib.PrologixGpibUsb()
self.assertEqual(write_mock.call_args_list[0], call("++savecfg 0" + chr(10)))
self.assertEqual(write_mock.call_args_list[1], call("++auto 0" + chr(10)))
......@@ -73,14 +73,14 @@ class PrologixGpibUsbTest(unittest.TestCase):
self.serial_mock.return_value.readline.return_value = ""
write_mock = self.serial_mock.return_value.write
hpib.PROLOGIX_GPIB_USB(findDevices=True)
hpib.PrologixGpibUsb(findDevices=True)
self.assertEqual(write_mock.call_args_list[7],
call("++addr " + str(0) + chr(10) + "*idn?" + chr(10) + "++read" + chr(10)))
def test_if_find_devices_getDevices_will_return_a_list_of_devices(self):
self.serial_mock.return_value.readline.return_value = "Device 1"
usb = hpib.PROLOGIX_GPIB_USB(findDevices=True)
usb = hpib.PrologixGpibUsb(findDevices=True)
devices = usb.getDevices()
......@@ -92,11 +92,11 @@ class PrologixGpibUsbTest(unittest.TestCase):
self.platform_mock.system.return_value = "Windows"
with self.assertRaises(NotImplementedError):
hpib.PROLOGIX_GPIB_USB()
hpib.PrologixGpibUsb()
def test_if_given_port_does_not_start_with_dev_tty_an_exception_is_raised(self):
with self.assertRaises(ValueError):
hpib.PROLOGIX_GPIB_USB(port="device")
hpib.PrologixGpibUsb(port="device")
if __name__ == '__main__':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment