Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of tests for Buffer Property #235

Merged
merged 10 commits into from
Apr 4, 2023
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions tests/test_buffer_property.py
Sakthi-SM marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"Contains a collection of pytest tests that validates the buffer property."
Sakthi-SM marked this conversation as resolved.
Show resolved Hide resolved
import nidaqmx
from nidaqmx.constants import SampleTimingType
from nidaqmx.errors import DaqError


def test__buffer__set_int32_property__value_is_set(any_x_series_device):
Sakthi-SM marked this conversation as resolved.
Show resolved Hide resolved
"""Test for validating int32 attributes in buffer."""
with nidaqmx.Task() as task:
task.ai_channels.add_ai_voltage_chan(any_x_series_device.ai_physical_chans[0].name)
task.timing.samp_timing_type = SampleTimingType.SAMPLE_CLOCK

# Setting a valid input buffer size of type int32
task.in_stream.input_buf_size = 2000000000
assert task.in_stream.input_buf_size == 2000000000
Sakthi-SM marked this conversation as resolved.
Show resolved Hide resolved


def test__buffer__set_invalid_int32_value__default_value_is_retained(any_x_series_device):
"""Test for validating int32 attributes in buffer."""
with nidaqmx.Task() as task:
task.ai_channels.add_ai_voltage_chan(any_x_series_device.ai_physical_chans[0].name)
task.timing.samp_timing_type = SampleTimingType.SAMPLE_CLOCK

# Setting a invalid input buffer size greater than int32
try:
task.in_stream.input_buf_size = 4000000000
except DaqError:
assert task.in_stream.input_buf_size == 2000000000
Sakthi-SM marked this conversation as resolved.
Show resolved Hide resolved


def test__buffer__reset_int32_property__value_is_set_to_default(any_x_series_device):
"""Test for validating int32 attributes in buffer."""
with nidaqmx.Task() as task:
task.ai_channels.add_ai_voltage_chan(any_x_series_device.ai_physical_chans[0].name)
task.timing.samp_timing_type = SampleTimingType.SAMPLE_CLOCK
default_buffer_size = task.in_stream.input_buf_size
task.in_stream.input_buf_size = 2000000000

# Resetting input buffer size
del task.in_stream.input_buf_size
assert task.in_stream.input_buf_size == default_buffer_size
Sakthi-SM marked this conversation as resolved.
Show resolved Hide resolved