diff --git a/tests/acceptance/test_internationalization.py b/tests/acceptance/test_internationalization.py index 08838d29..c62c52b4 100644 --- a/tests/acceptance/test_internationalization.py +++ b/tests/acceptance/test_internationalization.py @@ -69,3 +69,52 @@ def test___supported_encoding___logging_file_path___returns_assigned_value( ai_task.in_stream.logging_file_path = file_path # type: ignore[assignment] # https://github.com/ni/nidaqmx-python/issues/613 assert ai_task.in_stream.logging_file_path == pathlib.Path(file_path) + + +@pytest.mark.grpc_xfail( + reason="AB#2393811: DAQmxGetLoggingFilePath returns kErrorNULLPtr (-200604) when called from grpc-device.", + raises=DaqError, +) +@pytest.mark.parametrize( + "file_path, supported_encodings", + [ + ("Zu prüfende Daten.tdms", ["1252", "iso-8859-1", "utf-8"]), + ("Données de test.tdms", ["1252", "iso-8859-1", "utf-8"]), + ("テストデータ.tdms", ["932", "shift-jis", "utf-8"]), + ("테스트 데이터.tdms", ["utf-8", "euc-kr"]), + ("测试数据.tdms", ["utf-8", "gbk"]), + ], +) +def test___supported_encoding___configure_logging___returns_assigned_values( + ai_task: Task, file_path: str, supported_encodings: List[str] +): + if _get_encoding(ai_task) not in supported_encodings: + pytest.skip("requires compatible encoding") + + ai_task.in_stream.configure_logging(file_path) + + assert ai_task.in_stream.logging_file_path == pathlib.Path(file_path) + + +@pytest.mark.grpc_xfail( + reason="AB#2393811: DAQmxGetLoggingFilePath returns kErrorNULLPtr (-200604) when called from grpc-device.", + raises=DaqError, +) +@pytest.mark.parametrize( + "file_path, supported_encodings", + [ + ("Zu prüfende Daten.tdms", ["1252", "iso-8859-1", "utf-8"]), + ("Données de test.tdms", ["1252", "iso-8859-1", "utf-8"]), + ("テストデータ.tdms", ["932", "shift-jis", "utf-8"]), + ("테스트 데이터.tdms", ["utf-8", "euc-kr"]), + ("测试数据.tdms", ["utf-8", "gbk"]), + ], +) +def test___supported_encoding___start_new_file___returns_assigned_value( + ai_task: Task, file_path: str, supported_encodings: List[str] +): + if _get_encoding(ai_task) not in supported_encodings: + pytest.skip("requires compatible encoding") + ai_task.in_stream.start_new_file(file_path) + + assert ai_task.in_stream.logging_file_path == pathlib.Path(file_path) diff --git a/tests/component/task/test_in_stream.py b/tests/component/task/test_in_stream.py index 9d3ae210..9d4bcaf7 100644 --- a/tests/component/task/test_in_stream.py +++ b/tests/component/task/test_in_stream.py @@ -1,3 +1,4 @@ +import pathlib import time import numpy @@ -5,7 +6,8 @@ import nidaqmx import nidaqmx.system -from nidaqmx.constants import AcquisitionType +from nidaqmx.constants import AcquisitionType, LoggingMode, LoggingOperation +from nidaqmx.errors import DaqError # With a simulated X Series, setting ai_max/min to +/-2.5 V coerces the hardware range # to +/-5 V and generates a noisy sine wave with range +/-2.5 V (raw: about +/-16383). @@ -18,6 +20,12 @@ FULLSCALE_RAW_MIN = -36768 +@pytest.fixture() +def ai_task(task, sim_6363_device): + task.ai_channels.add_ai_voltage_chan(sim_6363_device.ai_physical_chans[0].name) + return task + + @pytest.fixture(params=[1, 2, 3]) def ai_sine_task( task: nidaqmx.Task, sim_6363_device: nidaqmx.system.Device, request: pytest.FixtureRequest @@ -186,3 +194,37 @@ def test___odd_sized_array___read_into___returns_whole_samples_and_clears_paddin assert samples_read == 9 assert (SINE_RAW_MIN <= data[:-1]).all() and (data[:-1] <= SINE_RAW_MAX).all() assert data[-1] == 0 # not FULLSCALE_RAW_MIN + + +@pytest.mark.grpc_xfail( + reason="AB#2393811: DAQmxGetLoggingFilePath returns kErrorNULLPtr (-200604) when called from grpc-device.", + raises=DaqError, +) +def test___valid_path___configure_logging___returns_assigned_values(ai_task: nidaqmx.Task): + expected_file_path = "Testing File.tdms" + expected_group_name = "Task" + expected_logging_mode = LoggingMode.LOG_AND_READ + expected_logging_operation = LoggingOperation.CREATE_OR_REPLACE + + ai_task.in_stream.configure_logging( + expected_file_path, + logging_mode=expected_logging_mode, + group_name=expected_group_name, + operation=expected_logging_operation, + ) + + assert ai_task.in_stream.logging_file_path == pathlib.Path(expected_file_path) + assert ai_task.in_stream.logging_mode == expected_logging_mode + assert ai_task.in_stream.logging_tdms_group_name == expected_group_name + assert ai_task.in_stream.logging_tdms_operation == expected_logging_operation + + +@pytest.mark.grpc_xfail( + reason="AB#2393811: DAQmxGetLoggingFilePath returns kErrorNULLPtr (-200604) when called from grpc-device.", + raises=DaqError, +) +def test___valid_path___start_new_file___returns_assigned_value(ai_task: nidaqmx.Task): + expected_file_path = "Testing File.tdms" + ai_task.in_stream.start_new_file(expected_file_path) + + assert ai_task.in_stream.logging_file_path == pathlib.Path(expected_file_path)