def test_register_operations(self): card = AlazarCard(None) operations = 'this is no operatoin but a string' card.register_operations('test', operations) self.assertEqual(len(card._registered_programs), 1) self.assertIs(card._registered_programs['test'].operations, operations)
def test_arm_operation(self): raw_card = dummy_modules.dummy_atsaverage.core.AlazarCard() card = AlazarCard(raw_card) card.register_mask_for_channel('A', 3, 'auto') card.register_mask_for_channel('B', 1, 'auto') card.register_operations('otto', []) card.default_config = dummy_modules.dummy_atsaverage.config.ScanlineConfiguration( ) with self.assertRaisesRegex(RuntimeError, 'No operations'): card.arm_program('otto') card.register_operations('otto', ['asd']) with self.assertRaisesRegex(RuntimeError, "No masks"): card.arm_program('otto') begins = np.arange(100) * 176.5 lengths = np.ones(100) * 10 * np.pi card.register_measurement_windows('otto', dict(A=(begins, lengths))) card.default_config.totalRecordSize = 17 with self.assertRaisesRegex( ValueError, "total record size is smaller than needed"): card.arm_program('otto') card.default_config.totalRecordSize = 0 with mock.patch.object( card.card, 'applyConfiguration') as mock_applyConfiguration: with mock.patch.object( card.card, 'startAcquisition') as mock_startAcquisition: card.arm_program('otto') mock_applyConfiguration.assert_called_once_with( card.current_config, True) mock_startAcquisition.assert_called_once_with(1) mock_applyConfiguration.reset_mock() mock_startAcquisition.reset_mock() card.arm_program('otto') mock_applyConfiguration.assert_not_called() mock_startAcquisition.assert_called_once_with(1)
def test_arm_operation(self): raw_card = dummy_modules.dummy_atsaverage.core.AlazarCard() card = AlazarCard(raw_card) card.register_mask_for_channel('A', 3, 'auto') card.register_mask_for_channel('B', 1, 'auto') card.register_operations('otto', []) card.config = dummy_modules.dummy_atsaverage.config.ScanlineConfiguration( ) with self.assertRaises(RuntimeError): card.arm_program('otto') card.register_operations('otto', ['asd']) with self.assertRaises(RuntimeError): card.arm_program('otto') begins = np.arange(100) * 176.5 lengths = np.ones(100) * 10 * np.pi card.register_measurement_windows('otto', dict(A=(begins, lengths))) card.config.totalRecordSize = 17 with self.assertRaises(ValueError): card.arm_program('otto') card.config.totalRecordSize = 0 card.arm_program('otto') self.assertEqual(card.config._apply_calls, [(raw_card, True)]) self.assertEqual(card.card._startAcquisition_calls, [1]) card.arm_program('otto') self.assertEqual(card.config._apply_calls, [(raw_card, True)]) self.assertEqual(card.card._startAcquisition_calls, [1, 1])