Skip to content

Commit

Permalink
fix pipeline failures and handle measurement data extra fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Suganth Sadaiyappan committed Mar 6, 2025
1 parent bf437e6 commit 8f19b55
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
8 changes: 4 additions & 4 deletions nisystemlink/clients/testmonitor/_test_monitor_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def delete_results(
def create_steps(
self,
steps: List[models.CreateStepRequest],
update_result_total_time: Optional[bool] = False,
update_result_total_time: bool = False,
) -> models.CreateStepsPartialSuccess:
"""Creates one or more steps.
Expand Down Expand Up @@ -297,9 +297,9 @@ def query_steps(self, query: models.QueryStepsRequest) -> models.PagedSteps:
def update_steps(
self,
steps: List[models.UpdateStepRequest],
update_result_total_time: Optional[bool] = False,
replace_keywords: Optional[bool] = False,
replace_properties: Optional[bool] = False,
update_result_total_time: bool = False,
replace_keywords: bool = False,
replace_properties: bool = False,
) -> models.UpdateStepsPartialSuccess:
"""Updates one or more steps.
Expand Down
12 changes: 9 additions & 3 deletions nisystemlink/clients/testmonitor/models/_step_data.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from typing import List, Optional
from typing import Any, List, Optional

from nisystemlink.clients.core._uplink._json_model import JsonModel
from nisystemlink.clients.testmonitor.models._status import Status
from pydantic import Extra


class Measurement(JsonModel):
name: Optional[str] = None
status: Optional[Status] = None
status: Optional[str] = None
measurement: Optional[str] = None
lowLimit: Optional[str] = None
highLimit: Optional[str] = None
Expand All @@ -17,6 +16,13 @@ class Measurement(JsonModel):
class Config:
extra = Extra.allow

def __init__(self, **data: Any) -> None:
# Convert all extra fields to str while keeping known fields unchanged
processed_data = {
k: str(v) if k not in self.__annotations__ else v for k, v in data.items()
}
super().__init__(**processed_data)


class StepData(JsonModel):
text: Optional[str] = None
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/testmonitor/test_testmonitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ def test__update_step_data_and_inputs__data_and_inputs_updated(
parameters=[
Measurement(
name="Current",
status=Status.PASSED(),
status="Passed",
measurement="3.725",
lowLimit="3.65",
highLimit="3.8",
Expand Down Expand Up @@ -738,13 +738,14 @@ def test__update_step_data_and_inputs__data_and_inputs_updated(
parameters=[
Measurement(
name="Voltage",
status=Status.PASSED(),
status="Passed",
measurement="3.725",
lowLimit="3.65",
highLimit="3.8",
units="V",
comparisonType="GELE",
specId="spec_01",
specInfo={"specKey": "specValue"},
)
],
)
Expand All @@ -753,7 +754,6 @@ def test__update_step_data_and_inputs__data_and_inputs_updated(
NamedValue(name="Voltage", value="10"),
]
updated_outputs = [NamedValue(name="Current", value="4.725")]

update_response: UpdateStepsPartialSuccess = client.update_steps(
steps=[
UpdateStepRequest(
Expand Down

0 comments on commit 8f19b55

Please sign in to comment.