-
Notifications
You must be signed in to change notification settings - Fork 19
tests: Add integration and acceptance tests for NI-DCPower driver specific session management APIs #490
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
Merged
Merged
tests: Add integration and acceptance tests for NI-DCPower driver specific session management APIs #490
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
724a7ae
tests: add nidcpower specific test measurement
jayaseelan-james 7a82994
tests: add proto file and stubs
jayaseelan-james f65225c
tests: add sample nidcpower integration test
jayaseelan-james f2399a3
tests: add sample nidcpower acceptance test
jayaseelan-james 68d39e8
refactor: remove parameterization
jayaseelan-james 7b4fd7e
rename test files
jayaseelan-james ab94562
tests: simplify nidcpower integration test
jayaseelan-james c350285
fix: lint errors
jayaseelan-james 4fe566a
Merge branch 'main' into users/jay/tests-for-nidcpower
jayaseelan-james da45daf
tests: add more acceptance tests
jayaseelan-james fa9421d
tests: add more integration tests
jayaseelan-james 8ac26ca
tests: return connected channels from nidcpower measurment.
jayaseelan-james eb32a12
tests: update acceptance tests to verify connected channels
jayaseelan-james 27350d3
fix: lint errors
jayaseelan-james 11dcbd3
fix: add actual measurement to nidcpower measurement
jayaseelan-james 0f43cb0
fix: refactor nidcpower session apis integration tests
jayaseelan-james 7d9de37
fix: refactor nidcpower session apis acceptance tests
jayaseelan-james 04db9b5
chore: add a new line before return
jayaseelan-james e887bf8
refactor: move utils to utility folder
jayaseelan-james b484b46
fix: lint errors
jayaseelan-james 43e4e98
fix: mypy error
jayaseelan-james 8b9c2ec
fix: typo
jayaseelan-james 702d3b2
chore: update acceptance & integration tests folder structure
jayaseelan-james 77fa3bc
chore: move nidcpower test meas stubs to sub dir
jayaseelan-james cda1d31
refactor: update test names to present tense
jayaseelan-james 9d1d374
fix: PR comments
jayaseelan-james 7adb457
fix: typo and lint errors
jayaseelan-james a6d7e3f
fix: update proto package name
jayaseelan-james ec1d674
tests: proto and stub changes
jayaseelan-james c0ac0ab
Merge branch 'main' into users/jay/tests-for-nidcpower
jayaseelan-james 57f472b
fix: update to pin_names for consistency
jayaseelan-james 0fd1300
refactor: acceptance tests
jayaseelan-james File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| """Pytest configuration file for acceptance tests.""" | ||
| import pathlib | ||
|
|
||
| import pytest | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def pin_map_directory(test_assets_directory: pathlib.Path) -> pathlib.Path: | ||
| """Test fixture that returns the pin map directory.""" | ||
| return test_assets_directory / "acceptance" / "session_management" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| import pathlib | ||
| from typing import Generator, Iterable, NamedTuple | ||
|
|
||
| import pytest | ||
|
|
||
| from ni_measurementlink_service._internal.stubs.ni.measurementlink.measurement.v2.measurement_service_pb2 import ( | ||
| MeasureRequest, | ||
| ) | ||
| from ni_measurementlink_service._internal.stubs.ni.measurementlink.measurement.v2.measurement_service_pb2_grpc import ( | ||
| MeasurementServiceStub, | ||
| ) | ||
| from ni_measurementlink_service._internal.stubs.ni.measurementlink.pin_map_context_pb2 import ( | ||
| PinMapContext, | ||
| ) | ||
| from ni_measurementlink_service.measurement.service import MeasurementService | ||
| from tests.assets.stubs.nidcpower_measurement.types_pb2 import ( | ||
| Configurations, | ||
| Outputs, | ||
| ) | ||
| from tests.utilities import nidcpower_measurement | ||
| from tests.utilities.pin_map_client import PinMapClient | ||
|
|
||
| _SITE = 0 | ||
|
|
||
|
|
||
| def test___single_session___measure___returns_measured_values( | ||
| pin_map_context: PinMapContext, | ||
| stub_v2: MeasurementServiceStub, | ||
| ) -> None: | ||
| configurations = Configurations(pin_names=["Pin1"], multi_session=False) | ||
|
|
||
| outputs = _measure(stub_v2, pin_map_context, configurations) | ||
|
|
||
| assert outputs.voltage_measurements == [5] | ||
| assert outputs.current_measurements == [0.0001] | ||
|
|
||
|
|
||
| def test___single_session___measure___creates_single_session( | ||
| pin_map_context: PinMapContext, | ||
| stub_v2: MeasurementServiceStub, | ||
| ) -> None: | ||
| configurations = Configurations(pin_names=["Pin1"], multi_session=False) | ||
|
|
||
| outputs = _measure(stub_v2, pin_map_context, configurations) | ||
|
|
||
| assert _get_output(outputs) == [ | ||
| _MeasurementOutput("DCPower1/0", "DCPower1/0", "DCPower1/0", "DCPower1/0") | ||
| ] | ||
|
|
||
|
|
||
| def test___multiple_sessions___measure___creates_multiple_sessions( | ||
| pin_map_context: PinMapContext, | ||
| stub_v2: MeasurementServiceStub, | ||
| ) -> None: | ||
| configurations = Configurations(pin_names=["Pin1", "Pin2"], multi_session=True) | ||
|
|
||
| outputs = _measure(stub_v2, pin_map_context, configurations) | ||
|
|
||
| assert _get_output(outputs) == [ | ||
| _MeasurementOutput("DCPower1/0", "DCPower1/0", "DCPower1/0", "DCPower1/0"), | ||
| _MeasurementOutput("DCPower1/2", "DCPower1/2", "DCPower1/2", "DCPower1/2"), | ||
| ] | ||
|
|
||
|
|
||
| def _measure( | ||
| stub_v2: MeasurementServiceStub, | ||
| pin_map_context: PinMapContext, | ||
| configurations: Configurations, | ||
| ) -> Outputs: | ||
| request = MeasureRequest(pin_map_context=pin_map_context) | ||
| request.configuration_parameters.Pack(configurations) | ||
| response_iterator = stub_v2.Measure(request) | ||
| responses = list(response_iterator) | ||
| assert len(responses) == 1 | ||
| outputs = Outputs.FromString(responses[0].outputs.value) | ||
| return outputs | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def measurement_service() -> Generator[MeasurementService, None, None]: | ||
| """Test fixture that creates and hosts a measurement service.""" | ||
| with nidcpower_measurement.measurement_service.host_service() as service: | ||
| yield service | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def pin_map_context(pin_map_client: PinMapClient, pin_map_directory: pathlib.Path) -> PinMapContext: | ||
| pin_map_name = "1Smu2ChannelGroup2Pin1Site.pinmap" | ||
| pin_map_id = pin_map_client.update_pin_map(pin_map_directory / pin_map_name) | ||
|
|
||
| return PinMapContext(pin_map_id=pin_map_id, sites=[_SITE]) | ||
|
|
||
|
|
||
| class _MeasurementOutput(NamedTuple): | ||
| session_name: str | ||
| resource_name: str | ||
| channel_list: str | ||
| connected_channels: str | ||
|
|
||
|
|
||
| def _get_output(outputs: Outputs) -> Iterable[_MeasurementOutput]: | ||
| return [ | ||
| _MeasurementOutput(session_name, resource_name, channel_list, connected_channels) | ||
| for session_name, resource_name, channel_list, connected_channels in zip( | ||
| outputs.session_names, | ||
| outputs.resource_names, | ||
| outputs.channel_lists, | ||
| outputs.connected_channels, | ||
| ) | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
tests/assets/acceptance/session_management/1Smu2ChannelGroup2Pin1Site.pinmap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <PinMap xmlns="http://www.ni.com/TestStand/SemiconductorModule/PinMap.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" schemaVersion="1.6"> | ||
| <Instruments> | ||
| <NIDCPowerInstrument name="DCPower1" numberOfChannels="4"> | ||
| <ChannelGroup name="DCPowerChannelGroup0" channels="0,1" /> | ||
| <ChannelGroup name="DCPowerChannelGroup1" channels="2,3" /> | ||
| </NIDCPowerInstrument> | ||
| </Instruments> | ||
| <Pins> | ||
| <DUTPin name="Pin1" /> | ||
| <DUTPin name="Pin2" /> | ||
| </Pins> | ||
| <PinGroups></PinGroups> | ||
| <Sites> | ||
| <Site siteNumber="0" /> | ||
| </Sites> | ||
| <Connections> | ||
| <Connection pin="Pin1" siteNumber="0" instrument="DCPower1" channel="0" /> | ||
| <Connection pin="Pin2" siteNumber="0" instrument="DCPower1" channel="2" /> | ||
| </Connections> | ||
| </PinMap> |
21 changes: 21 additions & 0 deletions
21
tests/assets/integration/session_management/1Smu2ChannelGroup2Pin1Site.pinmap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <PinMap xmlns="http://www.ni.com/TestStand/SemiconductorModule/PinMap.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" schemaVersion="1.6"> | ||
| <Instruments> | ||
| <NIDCPowerInstrument name="DCPower1" numberOfChannels="4"> | ||
| <ChannelGroup name="DCPowerChannelGroup0" channels="0,1" /> | ||
| <ChannelGroup name="DCPowerChannelGroup1" channels="2,3" /> | ||
| </NIDCPowerInstrument> | ||
| </Instruments> | ||
| <Pins> | ||
| <DUTPin name="Pin1" /> | ||
| <DUTPin name="Pin2" /> | ||
| </Pins> | ||
| <PinGroups></PinGroups> | ||
| <Sites> | ||
| <Site siteNumber="0" /> | ||
| </Sites> | ||
| <Connections> | ||
| <Connection pin="Pin1" siteNumber="0" instrument="DCPower1" channel="0" /> | ||
| <Connection pin="Pin2" siteNumber="0" instrument="DCPower1" channel="2" /> | ||
| </Connections> | ||
| </PinMap> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| """Auto generated gRPC files.""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| """Auto generated gRPC files for nidcpower test measurement.""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| syntax = "proto3"; | ||
| package ni.measurementlink.measurement.tests.nidcpower_measurement; | ||
|
|
||
| message Configurations { | ||
| repeated string pin_names = 1; | ||
| bool multi_session = 2; | ||
| } | ||
|
|
||
| message Outputs { | ||
| repeated string session_names = 1; | ||
| repeated string resource_names = 2; | ||
| repeated string channel_lists = 3; | ||
| repeated string connected_channels = 4; | ||
| repeated double voltage_measurements = 5; | ||
| repeated double current_measurements = 6; | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| """ | ||
| @generated by mypy-protobuf. Do not edit manually! | ||
| isort:skip_file | ||
| """ | ||
| import builtins | ||
| import collections.abc | ||
| import google.protobuf.descriptor | ||
| import google.protobuf.internal.containers | ||
| import google.protobuf.message | ||
| import sys | ||
|
|
||
| if sys.version_info >= (3, 8): | ||
| import typing as typing_extensions | ||
| else: | ||
| import typing_extensions | ||
|
|
||
| DESCRIPTOR: google.protobuf.descriptor.FileDescriptor | ||
|
|
||
| @typing_extensions.final | ||
| class Configurations(google.protobuf.message.Message): | ||
| DESCRIPTOR: google.protobuf.descriptor.Descriptor | ||
|
|
||
| PIN_NAMES_FIELD_NUMBER: builtins.int | ||
| MULTI_SESSION_FIELD_NUMBER: builtins.int | ||
| @property | ||
| def pin_names(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: ... | ||
| multi_session: builtins.bool | ||
| def __init__( | ||
| self, | ||
| *, | ||
| pin_names: collections.abc.Iterable[builtins.str] | None = ..., | ||
| multi_session: builtins.bool = ..., | ||
| ) -> None: ... | ||
| def ClearField(self, field_name: typing_extensions.Literal["multi_session", b"multi_session", "pin_names", b"pin_names"]) -> None: ... | ||
|
|
||
| global___Configurations = Configurations | ||
|
|
||
| @typing_extensions.final | ||
| class Outputs(google.protobuf.message.Message): | ||
| DESCRIPTOR: google.protobuf.descriptor.Descriptor | ||
|
|
||
| SESSION_NAMES_FIELD_NUMBER: builtins.int | ||
| RESOURCE_NAMES_FIELD_NUMBER: builtins.int | ||
| CHANNEL_LISTS_FIELD_NUMBER: builtins.int | ||
| CONNECTED_CHANNELS_FIELD_NUMBER: builtins.int | ||
| VOLTAGE_MEASUREMENTS_FIELD_NUMBER: builtins.int | ||
| CURRENT_MEASUREMENTS_FIELD_NUMBER: builtins.int | ||
| @property | ||
| def session_names(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: ... | ||
| @property | ||
| def resource_names(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: ... | ||
| @property | ||
| def channel_lists(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: ... | ||
| @property | ||
| def connected_channels(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: ... | ||
| @property | ||
| def voltage_measurements(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.float]: ... | ||
| @property | ||
| def current_measurements(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.float]: ... | ||
| def __init__( | ||
| self, | ||
| *, | ||
| session_names: collections.abc.Iterable[builtins.str] | None = ..., | ||
| resource_names: collections.abc.Iterable[builtins.str] | None = ..., | ||
| channel_lists: collections.abc.Iterable[builtins.str] | None = ..., | ||
| connected_channels: collections.abc.Iterable[builtins.str] | None = ..., | ||
| voltage_measurements: collections.abc.Iterable[builtins.float] | None = ..., | ||
| current_measurements: collections.abc.Iterable[builtins.float] | None = ..., | ||
| ) -> None: ... | ||
| def ClearField(self, field_name: typing_extensions.Literal["channel_lists", b"channel_lists", "connected_channels", b"connected_channels", "current_measurements", b"current_measurements", "resource_names", b"resource_names", "session_names", b"session_names", "voltage_measurements", b"voltage_measurements"]) -> None: ... | ||
|
|
||
| global___Outputs = Outputs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! | ||
| """Client and server classes corresponding to protobuf-defined services.""" | ||
| import grpc | ||
|
|
17 changes: 17 additions & 0 deletions
17
tests/assets/stubs/nidcpower_measurement/types_pb2_grpc.pyi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| """ | ||
| @generated by mypy-protobuf. Do not edit manually! | ||
| isort:skip_file | ||
| """ | ||
| import abc | ||
| import collections.abc | ||
| import grpc | ||
| import grpc.aio | ||
| import typing | ||
|
|
||
| _T = typing.TypeVar('_T') | ||
|
|
||
| class _MaybeAsyncIterator(collections.abc.AsyncIterator[_T], collections.abc.Iterator[_T], metaclass=abc.ABCMeta): | ||
| ... | ||
|
|
||
| class _ServicerContext(grpc.ServicerContext, grpc.aio.ServicerContext): # type: ignore | ||
| ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| """Integration tests for driver-specific session management APIs.""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| """Pytest configuration file for integration tests.""" | ||
| import pathlib | ||
|
|
||
| import pytest | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def pin_map_directory(test_assets_directory: pathlib.Path) -> pathlib.Path: | ||
| """Test fixture that returns the pin map directory.""" | ||
| return test_assets_directory / "integration" / "session_management" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.