-
Notifications
You must be signed in to change notification settings - Fork 0
Fill out the rest of the metadata test functionality and add publish batch/condition tests #49
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
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f58b24a
Add first few acceptance tests that run against the actual datastore …
mjohanse-emr 6fc83ec
Add tests for batch publishing
mjohanse-emr f19ba64
Merge branch 'main' into users/mjohanse/acceptance_tests2
mjohanse-emr 27f6e1f
More work on metadata tests. Add batch publish tests.
mjohanse-emr 242e9ad
Add to the metadata test.
mjohanse-emr d7993af
Update metadata test to use all greenboxes and extensions.
mjohanse-emr af3878b
Add tests for Publish Condition
mjohanse-emr 549a8c3
Rename test file for consistency
mjohanse-emr b465efc
Address review feedback.
mjohanse-emr 8ed5098
Merge branch 'main' into users/mjohanse/acceptance_tests2
mjohanse-emr 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,41 @@ | ||
| id = "https://acceptancetests.com/custommetadata.schema.toml" | ||
|
|
||
| [uut] | ||
| u1 = "*" | ||
| u2 = "*" | ||
|
|
||
| [uut_instance] | ||
| ui1 = "*" | ||
| ui2 = "*" | ||
|
|
||
| [operator] | ||
| o1 = "*" | ||
| o2 = "*" | ||
|
|
||
| [test_station] | ||
| ts1 = "*" | ||
| ts2 = "*" | ||
|
|
||
| [test_description] | ||
| td1 = "*" | ||
| td2 = "*" | ||
|
|
||
| [software_item] | ||
| sw1 = "*" | ||
| sw2 = "*" | ||
|
|
||
| [hardware_item] | ||
| hw1 = "*" | ||
| hw2 = "*" | ||
|
|
||
| [test_result] | ||
| tr1 = "*" | ||
| tr2 = "*" | ||
|
|
||
| [step] | ||
| s1 = "*" | ||
| s2 = "*" | ||
|
|
||
| [test] | ||
| t1 = "*" | ||
| t2 = "*" | ||
105 changes: 105 additions & 0 deletions
105
tests/acceptance/test_publish_condition_and_read_data.py
dixonjoel marked this conversation as resolved.
Show resolved
Hide resolved
|
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,105 @@ | ||
| """Acceptance tests that publish various condition values then read the data back.""" | ||
|
|
||
| from ni.datastore.data import ( | ||
| DataStoreClient, | ||
| Step, | ||
| TestResult, | ||
| ) | ||
| from nitypes.scalar import Scalar | ||
| from nitypes.vector import Vector | ||
|
|
||
|
|
||
| def test___publish_float_condition___read_data_returns_vector() -> None: | ||
| with DataStoreClient() as data_store_client: | ||
| step_id = _create_step(data_store_client, "float condition") | ||
| published_condition = data_store_client.publish_condition( | ||
| condition_name="python float condition", | ||
| type="Upper Limit", | ||
| value=123.45, | ||
| step_id=step_id, | ||
| ) | ||
|
|
||
| # A published float will be read back as a Vector. | ||
| vector = data_store_client.read_data(published_condition, expected_type=Vector) | ||
| assert len(vector) == 1 | ||
| assert vector[0] == 123.45 | ||
mjohanse-emr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| assert vector.units == "" | ||
|
|
||
|
|
||
| def test___publish_integer_condition___read_data_returns_vector() -> None: | ||
| with DataStoreClient() as data_store_client: | ||
| step_id = _create_step(data_store_client, "integer condition") | ||
| published_condition = data_store_client.publish_condition( | ||
| condition_name="python integer condition", | ||
| type="Lower Limit", | ||
| value=123, | ||
| step_id=step_id, | ||
| ) | ||
|
|
||
| # A published integer will be read back as a Vector. | ||
| vector = data_store_client.read_data(published_condition, expected_type=Vector) | ||
| assert len(vector) == 1 | ||
| assert vector[0] == 123 | ||
| assert vector.units == "" | ||
|
|
||
|
|
||
| def test___publish_bool_condition___read_data_returns_vector() -> None: | ||
| with DataStoreClient() as data_store_client: | ||
| step_id = _create_step(data_store_client, "bool condition") | ||
| published_condition = data_store_client.publish_condition( | ||
| condition_name="python bool condition", | ||
| type="Flag", | ||
| value=True, | ||
| step_id=step_id, | ||
| ) | ||
|
|
||
| # A published bool will be read back as a Vector. | ||
| vector = data_store_client.read_data(published_condition, expected_type=Vector) | ||
| assert len(vector) == 1 | ||
| assert vector[0] is True | ||
| assert vector.units == "" | ||
|
|
||
|
|
||
| def test___publish_str_condition___read_data_returns_vector() -> None: | ||
| with DataStoreClient() as data_store_client: | ||
| step_id = _create_step(data_store_client, "str condition") | ||
| published_condition = data_store_client.publish_condition( | ||
| condition_name="python str condition", | ||
| type="Environment", | ||
| value="condition value", | ||
| step_id=step_id, | ||
| ) | ||
|
|
||
| # A published str will be read back as a Vector. | ||
| vector = data_store_client.read_data(published_condition, expected_type=Vector) | ||
| assert len(vector) == 1 | ||
| assert vector[0] == "condition value" | ||
| assert vector.units == "" | ||
|
|
||
|
|
||
| def test___publish_scalar_condition___read_data_returns_vector() -> None: | ||
| with DataStoreClient() as data_store_client: | ||
| step_id = _create_step(data_store_client, "scalar condition") | ||
| expected_scalar = Scalar(value=25, units="Volts") | ||
| published_condition = data_store_client.publish_condition( | ||
| condition_name="python scalar condition", | ||
| type="Lower Limit", | ||
| value=expected_scalar, | ||
| step_id=step_id, | ||
| ) | ||
|
|
||
| # A published Scalar will be read back as a Vector. | ||
| vector = data_store_client.read_data(published_condition, expected_type=Vector) | ||
| assert vector[0] == expected_scalar.value | ||
| assert vector.units == expected_scalar.units | ||
|
|
||
|
|
||
| def _create_step(data_store_client: DataStoreClient, datatype_string: str) -> str: | ||
| test_result_name = f"python publish {datatype_string} acceptance test" | ||
| test_result = TestResult(test_result_name=test_result_name) | ||
| test_result_id = data_store_client.create_test_result(test_result) | ||
|
|
||
| # Publish the waveform data | ||
| step = Step(step_name=f"Initial step: {datatype_string}", test_result_id=test_result_id) | ||
| step_id = data_store_client.create_step(step) | ||
| return step_id | ||
103 changes: 103 additions & 0 deletions
103
tests/acceptance/test_publish_condition_batch_and_read_data.py
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,103 @@ | ||
| """Acceptance tests that publish various batch condition values then read the data back.""" | ||
|
|
||
| from ni.datastore.data import ( | ||
| DataStoreClient, | ||
| Step, | ||
| TestResult, | ||
| ) | ||
| from nitypes.vector import Vector | ||
|
|
||
mjohanse-emr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| def test___publish_batch_float_condition___read_data_returns_vector() -> None: | ||
| expected_value = [1.0, 2.0, 3.0] | ||
| with DataStoreClient() as data_store_client: | ||
| step_id = _create_step(data_store_client, "float condition batch") | ||
| published_condition = data_store_client.publish_condition_batch( | ||
| condition_name="python float condition batch", | ||
| type="Upper Limits", | ||
| values=expected_value, | ||
| step_id=step_id, | ||
| ) | ||
|
|
||
| # A batch published float will be read back as a Vector. | ||
| vector = data_store_client.read_data(published_condition, expected_type=Vector) | ||
| assert vector._values == expected_value | ||
| assert vector.units == "" | ||
|
|
||
|
|
||
| def test___publish_batch_integer_condition___read_data_returns_vector() -> None: | ||
| expected_value = [5, 6, 7, 8] | ||
| with DataStoreClient() as data_store_client: | ||
| step_id = _create_step(data_store_client, "integer condition batch") | ||
| published_condition = data_store_client.publish_condition_batch( | ||
| condition_name="python integer condition batch", | ||
| type="Lower Limits", | ||
| values=expected_value, | ||
| step_id=step_id, | ||
| ) | ||
|
|
||
| # A batch published integer will be read back as a Vector. | ||
| vector = data_store_client.read_data(published_condition, expected_type=Vector) | ||
| assert vector._values == expected_value | ||
| assert vector.units == "" | ||
|
|
||
|
|
||
| def test___publish_batch_bool_condition___read_data_returns_vector() -> None: | ||
| expected_value = [True, False, True] | ||
| with DataStoreClient() as data_store_client: | ||
| step_id = _create_step(data_store_client, "bool condition batch") | ||
| published_condition = data_store_client.publish_condition_batch( | ||
| condition_name="python bool condition batch", | ||
| type="Flags", | ||
| values=expected_value, | ||
| step_id=step_id, | ||
| ) | ||
|
|
||
| # A batch published bool will be read back as a Vector. | ||
| vector = data_store_client.read_data(published_condition, expected_type=Vector) | ||
| assert vector._values == expected_value | ||
| assert vector.units == "" | ||
|
|
||
|
|
||
| def test___publish_batch_str_condition___read_data_returns_vector() -> None: | ||
| expected_value = ["one", "two", "three"] | ||
| with DataStoreClient() as data_store_client: | ||
| step_id = _create_step(data_store_client, "str condition batch") | ||
| published_condition = data_store_client.publish_condition_batch( | ||
| condition_name="python str condition batch", | ||
| type="Environments", | ||
| values=expected_value, | ||
| step_id=step_id, | ||
| ) | ||
|
|
||
| # A published str will be read back as a Vector. | ||
| vector = data_store_client.read_data(published_condition, expected_type=Vector) | ||
| assert vector._values == expected_value | ||
| assert vector.units == "" | ||
|
|
||
|
|
||
| def test___publish_batch_vector_condition___read_data_returns_vector() -> None: | ||
| with DataStoreClient() as data_store_client: | ||
| step_id = _create_step(data_store_client, "scalar condition batch") | ||
| expected_vector = Vector(values=[25, 50, 75], units="Amps") | ||
| published_condition = data_store_client.publish_condition_batch( | ||
| condition_name="python vector condition batch", | ||
| type="Upper Limit", | ||
| values=expected_vector, | ||
| step_id=step_id, | ||
| ) | ||
|
|
||
| # A batch published Vector will be read back as a Vector. | ||
| vector = data_store_client.read_data(published_condition, expected_type=Vector) | ||
| assert vector == expected_vector | ||
mjohanse-emr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| def _create_step(data_store_client: DataStoreClient, datatype_string: str) -> str: | ||
| test_result_name = f"python publish {datatype_string} acceptance test" | ||
| test_result = TestResult(test_result_name=test_result_name) | ||
| test_result_id = data_store_client.create_test_result(test_result) | ||
|
|
||
| # Publish the waveform data | ||
| step = Step(step_name=f"Initial step: {datatype_string}", test_result_id=test_result_id) | ||
| step_id = data_store_client.create_step(step) | ||
| return step_id | ||
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
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.