示例#1
0
    def setup_method(self, method):
        self.patched_library_patcher = patch('nimodinst._library.Library',
                                             autospec=True)
        self.patched_library = self.patched_library_patcher.start()
        self.patched_library_singleton_get = patch(
            'nimodinst.session._library_singleton.get',
            return_value=self.patched_library)
        self.patched_library_singleton_get.start()

        self.side_effects_helper = _mock_helper.SideEffectsHelper()
        self.side_effects_helper.set_side_effects_and_return_values(
            self.patched_library)
        self.patched_library.niModInst_OpenInstalledDevicesSession.side_effect = self.side_effects_helper.niModInst_OpenInstalledDevicesSession
        self.disallow_close = self.patched_library.niModInst_CloseInstalledDevicesSession.side_effect
        self.patched_library.niModInst_CloseInstalledDevicesSession.side_effect = self.side_effects_helper.niModInst_CloseInstalledDevicesSession

        self.side_effects_helper['OpenInstalledDevicesSession'][
            'handle'] = SESSION_NUM_FOR_TEST
        self.side_effects_helper['OpenInstalledDevicesSession'][
            'deviceCount'] = 1

        self.iteration_device_looping = 0
        self.num_int_devices_looping = 3
        self.int_vals_device_looping = [123, 456, 789]
        self.num_string_devices_looping = 4
        self.string_vals_device_looping = [
            "Life", "liberty", "and", "happiness"
        ]
示例#2
0
    def setup_method(self, method):
        self.patched_library_patcher = patch('nitclk._library.Library', autospec=True)
        self.patched_library = self.patched_library_patcher.start()
        self.patched_library_singleton_get = patch('nitclk.session._library_singleton.get', return_value=self.patched_library)
        self.patched_library_singleton_get.start()

        self.side_effects_helper = _mock_helper.SideEffectsHelper()
        self.side_effects_helper.set_side_effects_and_return_values(self.patched_library)
示例#3
0
    def setup_method(self, method):
        self.patched_library_patcher = patch('nidigital._library.Library',
                                             autospec=True)
        self.patched_library = self.patched_library_patcher.start()
        self.patched_library_singleton_get = patch(
            'nidigital.session._library_singleton.get',
            return_value=self.patched_library)
        self.patched_library_singleton_get.start()

        self.side_effects_helper = _mock_helper.SideEffectsHelper()
        self.side_effects_helper.set_side_effects_and_return_values(
            self.patched_library)

        self.patched_library.niDigital_InitWithOptions.side_effect = self.side_effects_helper.niDigital_InitWithOptions
        self.side_effects_helper['InitWithOptions'][
            'newVi'] = session_id_for_test

        self.patched_library.niDigital_close.side_effect = self.side_effects_helper.niDigital_close

        self.patched_library.niDigital_LockSession.side_effect = self.side_effects_helper.niDigital_LockSession
        self.side_effects_helper['LockSession']['callerHasLock'] = True

        self.patched_library.niDigital_UnlockSession.side_effect = self.side_effects_helper.niDigital_UnlockSession
        self.side_effects_helper['UnlockSession']['callerHasLock'] = True
示例#4
0
    def setup_method(self, method):
        self.patched_library_patcher = patch('nidigital._library.Library',
                                             autospec=True)
        self.patched_library = self.patched_library_patcher.start()
        self.patched_library_singleton_get = patch(
            'nidigital.session._library_singleton.get',
            return_value=self.patched_library)
        self.patched_library_singleton_get.start()

        self.side_effects_helper = _mock_helper.SideEffectsHelper()
        self.side_effects_helper.set_side_effects_and_return_values(
            self.patched_library)

        self.patched_library.niDigital_InitWithOptions.side_effect = self.side_effects_helper.niDigital_InitWithOptions
        self.side_effects_helper['InitWithOptions'][
            'newVi'] = session_id_for_test

        self.patched_library.niDigital_close.side_effect = self.side_effects_helper.niDigital_close

        self.patched_library.niDigital_LockSession.side_effect = self.side_effects_helper.niDigital_LockSession
        self.side_effects_helper['LockSession']['callerHasLock'] = True

        self.patched_library.niDigital_UnlockSession.side_effect = self.side_effects_helper.niDigital_UnlockSession
        self.side_effects_helper['UnlockSession']['callerHasLock'] = True

        # For trying to set `_all_channels_in_session` in the Session constructor
        self.patched_library.niDigital_GetAttributeViInt32.side_effect = self.side_effects_helper.niDigital_GetAttributeViInt32
        self.side_effects_helper['GetAttributeViInt32'][
            'value'] = 1  # channel_count
        self.patched_library.niDigital_GetChannelNameFromString.side_effect = self.side_effects_helper.niDigital_GetChannelNameFromString
        self.side_effects_helper['GetChannelNameFromString'][
            'names'] = '0'  # get_channel_names()

        # for niDigital_FetchHistoryRAMCycleInformation_looping
        self.pattern_indices_looping = [0, 0, 0, 0, 0, 0, 0]
        self.time_set_indices_looping = [0, 1, 1, 2, 2, 2, 0]
        self.vector_numbers_looping = [5, 6, 6, 7, 7, 8, 9]
        self.cycle_numbers_looping = [5, 6, 7, 8, 9, 10, 11]
        self.num_duty_cycles_looping = [1, 1, 1, 2, 2, 2, 1]

        # for niDigital_GetTimeSetName_looping
        self.time_set_name_looping = ['t0', 'tScan', 't2X']

        # for niDigital_FetchHistoryRAMScanCycleNumber_looping
        self.scan_cycle_number_looping = [-1, 0, 1, -1, -1, -1, -1]

        # for niDigital_FetchHistoryRAMCyclePinData_looping
        self.expected_pin_states_looping = [
            [[
                nidigital.PinState.ZERO, nidigital.PinState.H,
                nidigital.PinState.X, nidigital.PinState.X,
                nidigital.PinState.H, nidigital.PinState.ZERO,
                nidigital.PinState.X, nidigital.PinState.X
            ]],
            [[
                nidigital.PinState.X, nidigital.PinState.X,
                nidigital.PinState.ZERO, nidigital.PinState.ONE,
                nidigital.PinState.X, nidigital.PinState.X,
                nidigital.PinState.L, nidigital.PinState.H
            ]],
            [[
                nidigital.PinState.X, nidigital.PinState.X,
                nidigital.PinState.ONE, nidigital.PinState.ZERO,
                nidigital.PinState.X, nidigital.PinState.X,
                nidigital.PinState.H, nidigital.PinState.L
            ]],
            [[
                nidigital.PinState.ONE, nidigital.PinState.ONE,
                nidigital.PinState.X, nidigital.PinState.X,
                nidigital.PinState.H, nidigital.PinState.H,
                nidigital.PinState.X, nidigital.PinState.X
            ],
             [
                 nidigital.PinState.ZERO, nidigital.PinState.ZERO,
                 nidigital.PinState.X, nidigital.PinState.X,
                 nidigital.PinState.L, nidigital.PinState.L,
                 nidigital.PinState.X, nidigital.PinState.X
             ]],
            [[
                nidigital.PinState.ONE, nidigital.PinState.ONE,
                nidigital.PinState.X, nidigital.PinState.X,
                nidigital.PinState.H, nidigital.PinState.H,
                nidigital.PinState.X, nidigital.PinState.X
            ],
             [
                 nidigital.PinState.ZERO, nidigital.PinState.ZERO,
                 nidigital.PinState.X, nidigital.PinState.X,
                 nidigital.PinState.L, nidigital.PinState.L,
                 nidigital.PinState.X, nidigital.PinState.X
             ]],
            [[
                nidigital.PinState.ZERO, nidigital.PinState.ONE,
                nidigital.PinState.X, nidigital.PinState.X,
                nidigital.PinState.L, nidigital.PinState.H,
                nidigital.PinState.X, nidigital.PinState.X
            ],
             [
                 nidigital.PinState.ONE, nidigital.PinState.ZERO,
                 nidigital.PinState.X, nidigital.PinState.X,
                 nidigital.PinState.H, nidigital.PinState.L,
                 nidigital.PinState.X, nidigital.PinState.X
             ]],
            [[
                nidigital.PinState.X, nidigital.PinState.X,
                nidigital.PinState.X, nidigital.PinState.X,
                nidigital.PinState.X, nidigital.PinState.X,
                nidigital.PinState.X, nidigital.PinState.X
            ]]
        ]
        self.actual_pin_states_looping = [
            [[
                nidigital.PinState.L, nidigital.PinState.L,
                nidigital.PinState.X, nidigital.PinState.X,
                nidigital.PinState.L, nidigital.PinState.L,
                nidigital.PinState.X, nidigital.PinState.X
            ]],
            [[
                nidigital.PinState.X, nidigital.PinState.X,
                nidigital.PinState.L, nidigital.PinState.H,
                nidigital.PinState.X, nidigital.PinState.X,
                nidigital.PinState.L, nidigital.PinState.H
            ]],
            [[
                nidigital.PinState.X, nidigital.PinState.X,
                nidigital.PinState.H, nidigital.PinState.L,
                nidigital.PinState.X, nidigital.PinState.X,
                nidigital.PinState.H, nidigital.PinState.L
            ]],
            [[
                nidigital.PinState.H, nidigital.PinState.H,
                nidigital.PinState.X, nidigital.PinState.X,
                nidigital.PinState.H, nidigital.PinState.H,
                nidigital.PinState.X, nidigital.PinState.X
            ],
             [
                 nidigital.PinState.L, nidigital.PinState.L,
                 nidigital.PinState.X, nidigital.PinState.X,
                 nidigital.PinState.L, nidigital.PinState.L,
                 nidigital.PinState.X, nidigital.PinState.X
             ]],
            [[
                nidigital.PinState.H, nidigital.PinState.H,
                nidigital.PinState.X, nidigital.PinState.X,
                nidigital.PinState.H, nidigital.PinState.H,
                nidigital.PinState.X, nidigital.PinState.X
            ],
             [
                 nidigital.PinState.L, nidigital.PinState.L,
                 nidigital.PinState.X, nidigital.PinState.X,
                 nidigital.PinState.L, nidigital.PinState.L,
                 nidigital.PinState.X, nidigital.PinState.X
             ]],
            [[
                nidigital.PinState.L, nidigital.PinState.H,
                nidigital.PinState.X, nidigital.PinState.X,
                nidigital.PinState.L, nidigital.PinState.H,
                nidigital.PinState.X, nidigital.PinState.X
            ],
             [
                 nidigital.PinState.H, nidigital.PinState.L,
                 nidigital.PinState.X, nidigital.PinState.X,
                 nidigital.PinState.H, nidigital.PinState.L,
                 nidigital.PinState.X, nidigital.PinState.X
             ]],
            [[
                nidigital.PinState.X, nidigital.PinState.X,
                nidigital.PinState.X, nidigital.PinState.X,
                nidigital.PinState.X, nidigital.PinState.X,
                nidigital.PinState.X, nidigital.PinState.X
            ]]
        ]
        self.per_pin_pass_fail_looping = [
            [[True, False, True, True, False, True, True, True]],
            [[True, True, True, True, True, True, True, True]],
            [[True, True, True, True, True, True, True, True]],
            [[True, True, True, True, True, True, True, True],
             [True, True, True, True, True, True, True, True]],
            [[True, True, True, True, True, True, True, True],
             [True, True, True, True, True, True, True, True]],
            [[True, True, True, True, True, True, True, True],
             [True, True, True, True, True, True, True, True]],
            [[True, True, True, True, True, True, True, True]],
        ]

        # for niDigital_FetchHistoryRAMCyclePinData_check_pins_looping
        self.expected_pin_list_check_pins_looping = None
        self.expected_pin_states_check_pins_looping = [[[
            nidigital.PinState.ZERO, nidigital.PinState.H
        ]]]
        self.actual_pin_states_check_pins_looping = [[[
            nidigital.PinState.L, nidigital.PinState.L
        ]]]
        self.per_pin_pass_fail_check_pins_looping = [[[True, False]]]

        # for niDigital_GetHistoryRAMSampleCount_check_site_looping
        self.iteration_check_site_looping = 0
        self.site_numbers_looping = [0, 1, 2]