def test_is_enabled(): mainframe = MagicMock() # Use concrete subclass because B1500Module does not assign channels smu = B1517A(parent=mainframe, name='B1517A', slot_nr=1) mainframe.ask.return_value = 'CN 1,2,4,8' assert smu.is_enabled() mainframe.ask.assert_called_once_with('*LRN? 0') mainframe.reset_mock(return_value=True) mainframe.ask.return_value = 'CN 2,4,8' assert not smu.is_enabled() mainframe.ask.assert_called_once_with('*LRN? 0') mainframe.reset_mock(return_value=True) mainframe.ask.return_value = 'CN' assert not smu.is_enabled() mainframe.ask.assert_called_once_with('*LRN? 0')
def test_snapshot(): from qcodes.instrument.base import InstrumentBase # We need to use `InstrumentBase` (not a bare mock) in order for # `snapshot` methods call resolution to work out mainframe = InstrumentBase(name='mainframe') mainframe.write = MagicMock() slot_nr = 1 smu = B1517A(parent=mainframe, name='B1517A', slot_nr=slot_nr) smu.use_high_speed_adc() smu.source_config(output_range=VOutputRange.AUTO) smu.measure_config(measure_range=IMeasRange.AUTO) s = smu.snapshot() assert '_source_config' in s assert 'output_range' in s['_source_config'] assert isinstance(s['_source_config']['output_range'], VOutputRange) assert '_measure_config' in s assert 'measure_range' in s['_measure_config'] assert isinstance(s['_measure_config']['measure_range'], IMeasRange)
def smu(mainframe): slot_nr = 1 smu = B1517A(parent=mainframe, name='B1517A', slot_nr=slot_nr) yield smu