Skip to content

Commit

Permalink
addressed reviewer's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
WayneDroid committed Feb 5, 2024
1 parent c559719 commit 00a51b4
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 48 deletions.
4 changes: 2 additions & 2 deletions generated/nidaqmx/system/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def do_ports(self):
@property
def ext_cal_last_date_and_time(self):
"""
Indicates the last date and time that the device underwent an
datetime: Indicates the last date and time that the device underwent an
external calibration.
"""

Expand All @@ -153,7 +153,7 @@ def ext_cal_last_date_and_time(self):
@property
def self_cal_last_date_and_time(self):
"""
Indicates the last date and time that the device underwent a
datetime: Indicates the last date and time that the device underwent a
self-calibration.
"""

Expand Down
40 changes: 40 additions & 0 deletions src/codegen/metadata/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12964,6 +12964,11 @@
'GetCalInfoAttributeBool': {
'calling_convention': 'Cdecl',
'cname': 'DAQmxGetCalInfoAttribute',
'handle_parameter': {
'ctypes_data_type': 'ctypes.c_char_p',
'cvi_name': 'deviceName',
'python_accessor': 'self._name'
},
'parameters': [
{
'ctypes_data_type': 'ctypes.c_char_p',
Expand Down Expand Up @@ -12995,6 +13000,11 @@
'GetCalInfoAttributeDouble': {
'calling_convention': 'Cdecl',
'cname': 'DAQmxGetCalInfoAttribute',
'handle_parameter': {
'ctypes_data_type': 'ctypes.c_char_p',
'cvi_name': 'deviceName',
'python_accessor': 'self._name'
},
'parameters': [
{
'ctypes_data_type': 'ctypes.c_char_p',
Expand Down Expand Up @@ -13026,6 +13036,11 @@
'GetCalInfoAttributeString': {
'calling_convention': 'Cdecl',
'cname': 'DAQmxGetCalInfoAttribute',
'handle_parameter': {
'ctypes_data_type': 'ctypes.c_char_p',
'cvi_name': 'deviceName',
'python_accessor': 'self._name'
},
'parameters': [
{
'ctypes_data_type': 'ctypes.c_char_p',
Expand Down Expand Up @@ -13068,6 +13083,11 @@
'GetCalInfoAttributeUInt32': {
'calling_convention': 'Cdecl',
'cname': 'DAQmxGetCalInfoAttribute',
'handle_parameter': {
'ctypes_data_type': 'ctypes.c_char_p',
'cvi_name': 'deviceName',
'python_accessor': 'self._name'
},
'parameters': [
{
'ctypes_data_type': 'ctypes.c_char_p',
Expand Down Expand Up @@ -20795,6 +20815,11 @@
'SetCalInfoAttributeBool': {
'calling_convention': 'Cdecl',
'cname': 'DAQmxSetCalInfoAttribute',
'handle_parameter': {
'ctypes_data_type': 'ctypes.c_char_p',
'cvi_name': 'deviceName',
'python_accessor': 'self._name'
},
'parameters': [
{
'ctypes_data_type': 'ctypes.c_char_p',
Expand Down Expand Up @@ -20826,6 +20851,11 @@
'SetCalInfoAttributeDouble': {
'calling_convention': 'Cdecl',
'cname': 'DAQmxSetCalInfoAttribute',
'handle_parameter': {
'ctypes_data_type': 'ctypes.c_char_p',
'cvi_name': 'deviceName',
'python_accessor': 'self._name'
},
'parameters': [
{
'ctypes_data_type': 'ctypes.c_char_p',
Expand Down Expand Up @@ -20857,6 +20887,11 @@
'SetCalInfoAttributeString': {
'calling_convention': 'Cdecl',
'cname': 'DAQmxSetCalInfoAttribute',
'handle_parameter': {
'ctypes_data_type': 'ctypes.c_char_p',
'cvi_name': 'deviceName',
'python_accessor': 'self._name'
},
'parameters': [
{
'ctypes_data_type': 'ctypes.c_char_p',
Expand Down Expand Up @@ -20888,6 +20923,11 @@
'SetCalInfoAttributeUInt32': {
'calling_convention': 'Cdecl',
'cname': 'DAQmxSetCalInfoAttribute',
'handle_parameter': {
'ctypes_data_type': 'ctypes.c_char_p',
'cvi_name': 'deviceName',
'python_accessor': 'self._name'
},
'parameters': [
{
'ctypes_data_type': 'ctypes.c_char_p',
Expand Down
4 changes: 2 additions & 2 deletions src/codegen/templates/system/device.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class Device:
@property
def ext_cal_last_date_and_time(self):
"""
Indicates the last date and time that the device underwent an
datetime: Indicates the last date and time that the device underwent an
external calibration.
"""

Expand All @@ -162,7 +162,7 @@ class Device:
@property
def self_cal_last_date_and_time(self):
"""
Indicates the last date and time that the device underwent a
datetime: Indicates the last date and time that the device underwent a
self-calibration.
"""

Expand Down
8 changes: 4 additions & 4 deletions tests/component/system/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ def test___self_test_device___no_errors(any_x_series_device: Device) -> None:
any_x_series_device.self_test_device()


def test___self_cal___no_errors(any_x_series_device: Device) -> None:
any_x_series_device.self_cal()
def test___restore_last_ext_cal_const___no_errors(sim_x_series_device: Device) -> None:
sim_x_series_device.restore_last_ext_cal_const()


def test___restore_last_ext_cal_const___no_errors(any_x_series_device: Device) -> None:
any_x_series_device.restore_last_ext_cal_const()
def test___self_cal___no_errors(sim_x_series_device: Device) -> None:
sim_x_series_device.self_cal()
106 changes: 66 additions & 40 deletions tests/component/system/test_device_properties.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest

from datetime import datetime
from nidaqmx import DaqError
from nidaqmx.constants import BusType, TriggerUsage
from nidaqmx.error_codes import DAQmxErrors
Expand Down Expand Up @@ -114,68 +115,93 @@ def test___module___get_chassis___shared_interpreter(device: Device):
assert chassis._interpreter is device._interpreter


def test___ext_cal_last_date_and_time___no_errors(any_x_series_device: Device) -> None:
last_date_and_time = any_x_series_device.ext_cal_last_date_and_time
def test___ext_cal_last_date_and_time___no_errors(real_x_series_device: Device) -> None:
last_date_and_time = real_x_series_device.ext_cal_last_date_and_time

assert last_date_and_time is not None
assert type(last_date_and_time) == datetime
assert last_date_and_time.year > 2009
assert last_date_and_time.month >= 1
assert last_date_and_time.day > 0
assert last_date_and_time.hour >= 0
assert last_date_and_time.minute >= 0


def test___self_cal_last_date_and_time___no_errors(any_x_series_device: Device) -> None:
last_date_and_time = any_x_series_device.self_cal_last_date_and_time
def test___self_cal_last_date_and_time___no_errors(real_x_series_device: Device) -> None:
last_date_and_time = real_x_series_device.self_cal_last_date_and_time

assert last_date_and_time is not None
assert type(last_date_and_time) == datetime
assert last_date_and_time.year > 2009
assert last_date_and_time.month >= 1
assert last_date_and_time.day > 0
assert last_date_and_time.hour >= 0
assert last_date_and_time.minute >= 0


def test___device_supports_cal___no_errors(any_x_series_device: Device) -> None:
is_cal_supported = any_x_series_device.device_supports_cal
def test___device_supports_cal___no_errors(real_x_series_device: Device) -> None:
is_cal_supported = real_x_series_device.device_supports_cal

assert is_cal_supported is True


def test___cal_acc_connection_count___no_errors(any_x_series_device: Device) -> None:
test_value = 99
def test___cal_acc_connection_count__raises_attr_not_supported(any_x_series_device: Device) -> None:
with pytest.raises(DaqError) as exc_info:
_ = any_x_series_device.cal_acc_connection_count

try:
current_acc_connection_count = any_x_series_device.cal_acc_connection_count
assert exc_info.value.error_code == DAQmxErrors.ATTR_NOT_SUPPORTED

any_x_series_device.cal_acc_connection_count = test_value
assert test_value == any_x_series_device.cal_acc_connection_count

any_x_series_device.cal_acc_connection_count = current_acc_connection_count
def test___cal_recommended_acc_connection_count_limit___raises_attr_not_supported(
any_x_series_device: Device,
) -> None:
with pytest.raises(DaqError) as exc_info:
_ = any_x_series_device.cal_recommended_acc_connection_count_limit

except DaqError as e:
if e.error_code != DAQmxErrors.ATTR_NOT_SUPPORTED:
raise
assert exc_info.value.error_code == DAQmxErrors.ATTR_NOT_SUPPORTED


def test___cal_dev_temp___no_errors(any_x_series_device: Device) -> None:
temperature = any_x_series_device.cal_dev_temp
@pytest.fixture()
def get_cal_user_defined_info(real_x_series_device: Device):
user_defined_info = real_x_series_device.cal_user_defined_info

assert 0.0 != temperature
def test___set_cal_user_defined_info___no_errors(real_x_series_device: Device) -> None:
user_defined_info = real_x_series_device.cal_user_defined_info
info_max_size = real_x_series_device.cal_user_defined_info_max_size

test_value = "my test value"[:info_max_size]
real_x_series_device.cal_user_defined_info = test_value
value = real_x_series_device.cal_user_defined_info

def test___cal_recommended_acc_connection_count_limit___no_errors(
any_x_series_device: Device,
) -> None:
try:
acc_connection_count_limit = any_x_series_device.cal_recommended_acc_connection_count_limit
print(f"current_acc_connection_count_limit: {acc_connection_count_limit}")
assert info_max_size == len(value)
assert value in test_value

assert 0.0 != acc_connection_count_limit
real_x_series_device.cal_user_defined_info = user_defined_info

except DaqError as e:
if e.error_code != DAQmxErrors.ATTR_NOT_SUPPORTED:
raise

def test___cal_dev_temp___no_errors(sim_x_series_device: Device) -> None:
temperature = sim_x_series_device.cal_dev_temp

def test___cal_user_defined_info___no_errors(any_x_series_device: Device) -> None:
test_value = "my test value"
user_defined_info = any_x_series_device.cal_user_defined_info
info_max_size = any_x_series_device.cal_user_defined_info_max_size
assert 0.0 == temperature

any_x_series_device.cal_user_defined_info = test_value
value = any_x_series_device.cal_user_defined_info
assert info_max_size == len(value)
assert value in test_value

any_x_series_device.cal_user_defined_info = user_defined_info
def test___ext_cal_last_temp___no_errors(sim_x_series_device: Device) -> None:
temperature = sim_x_series_device.ext_cal_last_temp

assert 0.0 == temperature


def test___ext_cal_recommended_interval___no_errors(sim_x_series_device: Device) -> None:
interval = sim_x_series_device.ext_cal_recommended_interval

assert 24 == interval


def test___self_cal_last_temp___no_errors(sim_x_series_device: Device) -> None:
temperature = sim_x_series_device.self_cal_last_temp

assert 0.0 == temperature


def test___self_cal_supported___no_errors(any_x_series_device: Device) -> None:
is_cal_supported = any_x_series_device.self_cal_supported

assert is_cal_supported is True

0 comments on commit 00a51b4

Please sign in to comment.