Beispiel #1
0
    def test_init(self):
        make_waveform_patch = mock.patch(
            'qupulse.hardware.awgs.tektronix.TektronixAWG.make_idle_waveform')
        clear_patch = mock.patch(
            'qupulse.hardware.awgs.tektronix.TektronixAWG.clear')
        init_idle_patch = mock.patch(
            'qupulse.hardware.awgs.tektronix.TektronixAWG.initialize_idle_program'
        )
        synchronize_patch = mock.patch(
            'qupulse.hardware.awgs.tektronix.TektronixAWG.synchronize')

        with mock.patch('qupulse.hardware.awgs.tektronix.tek_awg', new=None):
            with self.assertRaisesRegex(RuntimeError, 'tek_awg'):
                TektronixAWG(self.make_dummy_tek_awg(), 'clear')

        with self.patch_method('make_idle_waveform') as make_idle_waveform:
            with self.assertRaisesRegex(ValueError, 'synchronize'):
                TektronixAWG(self.make_dummy_tek_awg(),
                             'foo',
                             idle_waveform_length=300)

            make_idle_waveform.assert_called_once_with(300)

        with make_waveform_patch as make_idle_waveform, clear_patch as clear, init_idle_patch as init_idle:
            TektronixAWG(self.make_dummy_tek_awg(),
                         'clear',
                         idle_waveform_length=300)
            make_idle_waveform.assert_called_once_with(300)
            clear.assert_called_once_with()
            init_idle.assert_called_once_with()

        with make_waveform_patch as make_idle_waveform, synchronize_patch as synchronize, init_idle_patch as init_idle:
            dummy = self.make_dummy_tek_awg()
            tek_awg = TektronixAWG(dummy,
                                   'read',
                                   idle_waveform_length=300,
                                   default_program_repetition_mode='infinite')
            make_idle_waveform.assert_called_once_with(300)
            synchronize.assert_called_once_with()
            init_idle.assert_called_once_with()
            self.assertEqual(tek_awg.default_program_repetition_mode,
                             'infinite')
            self.assertIs(tek_awg.device, dummy)
Beispiel #2
0
    def make_awg(self, **kwargs):
        make_waveform_patch = mock.patch(
            'qupulse.hardware.awgs.tektronix.TektronixAWG.make_idle_waveform')
        clear_patch = mock.patch(
            'qupulse.hardware.awgs.tektronix.TektronixAWG.clear')
        init_idle_patch = mock.patch(
            'qupulse.hardware.awgs.tektronix.TektronixAWG.initialize_idle_program'
        )
        synchronize_patch = mock.patch(
            'qupulse.hardware.awgs.tektronix.TektronixAWG.synchronize')

        kwargs.setdefault('device', self.make_mock_tek_awg())
        kwargs.setdefault('synchronize', 'read')

        with make_waveform_patch, clear_patch, init_idle_patch, synchronize_patch:
            return TektronixAWG(**kwargs)