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

Add tests for DAQmxConfigureLogging and DAQmxStartNewFile #616

Merged
merged 5 commits into from
Jul 17, 2024
Merged
Changes from 2 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
61 changes: 61 additions & 0 deletions tests/acceptance/test_internationalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest

from nidaqmx._lib import lib_importer
from nidaqmx.constants import LoggingMode, LoggingOperation
from nidaqmx.error_codes import DAQmxErrors
from nidaqmx.errors import DaqError
from nidaqmx.system import Device
Expand Down Expand Up @@ -69,3 +70,63 @@ 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.",
texasaggie97 marked this conversation as resolved.
Show resolved Hide resolved
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")
expected_group_name = "Task"
expected_logging_mode = LoggingMode.LOG_AND_READ
expected_logging_operation = LoggingOperation.CREATE_OR_REPLACE

ai_task.in_stream.configure_logging(
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(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
texasaggie97 marked this conversation as resolved.
Show resolved Hide resolved


@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)
Loading