Exemplo n.º 1
0
 def test_set_vi_session_with_int(self):
     session = nitclk.SessionReference(SESSION_NUM_FOR_TEST)
     self.patched_library.niTClk_SetAttributeViSession.side_effect = self.side_effects_helper.niTClk_SetAttributeViSession
     attribute_id = 3
     other_session_number = 43
     session.start_trigger_master_session = other_session_number
     self.patched_library.niTClk_SetAttributeViSession.assert_called_once_with(
         _matchers.ViSessionMatcher(SESSION_NUM_FOR_TEST),
         _matchers.ViStringMatcher(''),
         _matchers.ViAttrMatcher(attribute_id),
         _matchers.ViSessionMatcher(other_session_number))
Exemplo n.º 2
0
 def test_set_vi_string(self):
     session = nitclk.SessionReference(SESSION_NUM_FOR_TEST)
     self.patched_library.niTClk_SetAttributeViString.side_effect = self.side_effects_helper.niTClk_SetAttributeViString
     attribute_id = 13
     test_string = "The answer to the ultimate question is 42"
     session.sync_pulse_sender_sync_pulse_source = test_string
     self.patched_library.niTClk_SetAttributeViString.assert_called_once_with(_matchers.ViSessionMatcher(SESSION_NUM_FOR_TEST), _matchers.ViStringMatcher(''), _matchers.ViAttrMatcher(attribute_id), _matchers.ViStringMatcher(test_string))
Exemplo n.º 3
0
 def test_set_timedelta_as_timedelta(self):
     session = nitclk.SessionReference(SESSION_NUM_FOR_TEST)
     self.patched_library.niTClk_SetAttributeViReal64.side_effect = self.side_effects_helper.niTClk_SetAttributeViReal64
     attribute_id = 11
     test_number = 4.2
     session.sample_clock_delay = hightime.timedelta(seconds=test_number)
     self.patched_library.niTClk_SetAttributeViReal64.assert_called_once_with(_matchers.ViSessionMatcher(SESSION_NUM_FOR_TEST), _matchers.ViStringMatcher(''), _matchers.ViAttrMatcher(attribute_id), _matchers.ViReal64Matcher(test_number))
Exemplo n.º 4
0
 def test_set_vi_real64(self):
     session = nitclk.SessionReference(SESSION_NUM_FOR_TEST)
     self.patched_library.niTClk_SetAttributeViReal64.side_effect = self.side_effects_helper.niTClk_SetAttributeViReal64
     attribute_id = 8
     test_number = 4.2
     session.tclk_actual_period = test_number
     self.patched_library.niTClk_SetAttributeViReal64.assert_called_once_with(_matchers.ViSessionMatcher(SESSION_NUM_FOR_TEST), _matchers.ViStringMatcher(''), _matchers.ViAttrMatcher(attribute_id), _matchers.ViReal64Matcher(test_number))
Exemplo n.º 5
0
 def test_open_and_close(self):
     session = nimodinst.Session('')
     self.patched_library.niModInst_OpenInstalledDevicesSession.assert_called_once_with(
         _matchers.ViStringMatcher(''), _matchers.ViSessionPointerMatcher(),
         _matchers.ViInt32PointerMatcher())
     session.close()
     self.patched_library.niModInst_CloseInstalledDevicesSession.assert_called_once_with(
         _matchers.ViSessionMatcher(SESSION_NUM_FOR_TEST))
Exemplo n.º 6
0
 def test_context_manager(self):
     with nimodinst.Session('') as session:
         assert type(session) == nimodinst.Session
         self.patched_library.niModInst_OpenInstalledDevicesSession.assert_called_once_with(
             _matchers.ViStringMatcher(''),
             _matchers.ViSessionPointerMatcher(),
             _matchers.ViInt32PointerMatcher())
     self.patched_library.niModInst_CloseInstalledDevicesSession.assert_called_once_with(
         _matchers.ViSessionMatcher(SESSION_NUM_FOR_TEST))
Exemplo n.º 7
0
 def test_get_timedelta(self):
     session = nitclk.SessionReference(SESSION_NUM_FOR_TEST)
     self.patched_library.niTClk_GetAttributeViReal64.side_effect = self.side_effects_helper.niTClk_GetAttributeViReal64
     attribute_id = 11
     test_number = 4.2
     self.side_effects_helper['GetAttributeViReal64']['value'] = test_number
     attr_timedelta = session.sample_clock_delay
     assert(attr_timedelta.total_seconds() == test_number)
     self.patched_library.niTClk_GetAttributeViReal64.assert_called_once_with(_matchers.ViSessionMatcher(SESSION_NUM_FOR_TEST), _matchers.ViStringMatcher(''), _matchers.ViAttrMatcher(attribute_id), _matchers.ViReal64PointerMatcher())
Exemplo n.º 8
0
 def test_get_vi_real64(self):
     session = nitclk.SessionReference(SESSION_NUM_FOR_TEST)
     self.patched_library.niTClk_GetAttributeViReal64.side_effect = self.side_effects_helper.niTClk_GetAttributeViReal64
     attribute_id = 8
     test_number = 4.2
     self.side_effects_helper['GetAttributeViReal64']['value'] = test_number
     attr_val = session.tclk_actual_period
     assert(attr_val == test_number)
     self.patched_library.niTClk_GetAttributeViReal64.assert_called_once_with(_matchers.ViSessionMatcher(SESSION_NUM_FOR_TEST), _matchers.ViStringMatcher(''), _matchers.ViAttrMatcher(attribute_id), _matchers.ViReal64PointerMatcher())
Exemplo n.º 9
0
 def test_get_tclk_session_reference(self):
     session = nitclk.SessionReference(SESSION_NUM_FOR_TEST)
     self.patched_library.niTClk_GetAttributeViSession.side_effect = self.side_effects_helper.niTClk_GetAttributeViSession
     attribute_id = 3
     other_session_number = 43
     self.side_effects_helper['GetAttributeViSession']['value'] = other_session_number
     attr_session_reference = session.start_trigger_master_session
     assert type(attr_session_reference) is nitclk.SessionReference
     assert(attr_session_reference._get_tclk_session_reference() == other_session_number)
     self.patched_library.niTClk_GetAttributeViSession.assert_called_once_with(_matchers.ViSessionMatcher(SESSION_NUM_FOR_TEST), _matchers.ViStringMatcher(''), _matchers.ViAttrMatcher(attribute_id), _matchers.ViSessionPointerMatcher())
Exemplo n.º 10
0
    def test_get_vi_string(self):
        session = nitclk.SessionReference(SESSION_NUM_FOR_TEST)
        self.patched_library.niTClk_GetAttributeViString.side_effect = self.side_effects_helper.niTClk_GetAttributeViString
        attribute_id = 13
        test_string = "The answer to the ultimate question is 42"
        self.side_effects_helper['GetAttributeViString']['value'] = test_string
        attr_string = session.sync_pulse_sender_sync_pulse_source
        assert(attr_string == test_string)

        from unittest.mock import call
        calls = [call(_matchers.ViSessionMatcher(SESSION_NUM_FOR_TEST), _matchers.ViStringMatcher(''), _matchers.ViAttrMatcher(attribute_id), _matchers.ViInt32Matcher(0), None), call(_matchers.ViSessionMatcher(SESSION_NUM_FOR_TEST), _matchers.ViStringMatcher(''), _matchers.ViAttrMatcher(attribute_id), _matchers.ViInt32Matcher(len(test_string)), _matchers.ViCharBufferMatcher(len(test_string)))]
        self.patched_library.niTClk_GetAttributeViString.assert_has_calls(calls)
        assert self.patched_library.niTClk_GetAttributeViString.call_count == 2
Exemplo n.º 11
0
 def test_close(self):
     session = nimodinst.Session('')
     session.close()
     self.patched_library.niModInst_CloseInstalledDevicesSession.assert_called_once_with(_matchers.ViSessionMatcher(SESSION_NUM_FOR_TEST))