From 525c770b525bb16e5aa663c6653ab8613309e5e5 Mon Sep 17 00:00:00 2001 From: Ammar Husain Mian Fazulul Date: Fri, 16 May 2025 14:55:15 +0530 Subject: [PATCH 01/64] added boiler plate for test plan client --- nisystemlink/clients/test_plan/__init__.py | 0 .../clients/test_plan/model/__init__.py | 1 + .../test_plan/model/_execution_definition.py | 96 +++++++++++++++++++ .../test_plan/test_plan_templates/__init__.py | 0 .../test_plan_templates/model/__init__.py | 0 tests/test_plan/__init__.py | 0 .../test_plan/test_plan_templates/__init__.py | 0 7 files changed, 97 insertions(+) create mode 100644 nisystemlink/clients/test_plan/__init__.py create mode 100644 nisystemlink/clients/test_plan/model/__init__.py create mode 100644 nisystemlink/clients/test_plan/model/_execution_definition.py create mode 100644 nisystemlink/clients/test_plan/test_plan_templates/__init__.py create mode 100644 nisystemlink/clients/test_plan/test_plan_templates/model/__init__.py create mode 100644 tests/test_plan/__init__.py create mode 100644 tests/test_plan/test_plan_templates/__init__.py diff --git a/nisystemlink/clients/test_plan/__init__.py b/nisystemlink/clients/test_plan/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/nisystemlink/clients/test_plan/model/__init__.py b/nisystemlink/clients/test_plan/model/__init__.py new file mode 100644 index 00000000..a67830a7 --- /dev/null +++ b/nisystemlink/clients/test_plan/model/__init__.py @@ -0,0 +1 @@ +from ._execution_definition import ExecutionDefinition \ No newline at end of file diff --git a/nisystemlink/clients/test_plan/model/_execution_definition.py b/nisystemlink/clients/test_plan/model/_execution_definition.py new file mode 100644 index 00000000..853c453f --- /dev/null +++ b/nisystemlink/clients/test_plan/model/_execution_definition.py @@ -0,0 +1,96 @@ +from typing import Union + +from nisystemlink.clients.core._uplink._json_model import JsonModel +class Job(JsonModel): + """ + Represents a job to be executed, including its functions, arguments, and metadata. + """ + functions: list[str] + """List of function names to execute""" + + arguments: list[list[object]] + """List of argument lists for each function""" + + metadata: dict[str, object] + """Additional metadata for the job""" + +class NotebookExecutionDefinition(JsonModel): + """ + Defines the execution of a notebook. + """ + action: str + """User defined action to perform in workflow (user defined)""" + + type: str = 'NOTEBOOK' + """Type of execution, default is 'NOTEBOOK'""" + + notebookId: str + """ID of the notebook to execute""" + + +class ManualExecutionDefinition(JsonModel): + """ + Represents a manual execution definition. + """ + action: str + """User defined action to perform in workflow (user defined)""" + + type: str = 'MANUAL' + """Type of execution, default is 'MANUAL'""" + +class JobExecutionDefinition(JsonModel): + """ + Defines the execution of one or more jobs. + """ + action: str + """User defined action to perform in workflow (user defined)""" + + type: str = 'JOB' + """Type of execution, default is 'JOB'""" + + jobs: list[Job] + """List of jobs to execute""" + + systemId: str | None = None + """Optional system ID where jobs will run""" + + +class ScheduleExecutionDefinition(JsonModel): + """ + Represents a scheduled execution definition. + """ + action: str + """User defined action to perform in workflow (user defined)""" + + type: str = 'SCHEDULE' + """Type of execution, default is 'SCHEDULE'""" + + +class UnscheduleExecutionDefinition(JsonModel): + """ + Represents an unscheduled execution definition. + """ + action: str + """User defined action to perform in workflow (user defined)""" + + type: str = 'UNSCHEDULE' + """Type of execution, default is 'UNSCHEDULE'""" + +class NoneExecutionDefinition(JsonModel): + """ + Represents a definition where no execution is specified. + """ + action: str + """User defined action to perform in workflow (user defined)""" + + type: str = 'None' + """Type of execution, default is 'None'""" + +ExecutionDefinition = Union[ + NotebookExecutionDefinition, + ManualExecutionDefinition, + JobExecutionDefinition, + NoneExecutionDefinition, + ScheduleExecutionDefinition, + UnscheduleExecutionDefinition +] \ No newline at end of file diff --git a/nisystemlink/clients/test_plan/test_plan_templates/__init__.py b/nisystemlink/clients/test_plan/test_plan_templates/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/nisystemlink/clients/test_plan/test_plan_templates/model/__init__.py b/nisystemlink/clients/test_plan/test_plan_templates/model/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/test_plan/__init__.py b/tests/test_plan/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/test_plan/test_plan_templates/__init__.py b/tests/test_plan/test_plan_templates/__init__.py new file mode 100644 index 00000000..e69de29b From ebfc90f3d7a603d193113bddcf73c04544af4f42 Mon Sep 17 00:00:00 2001 From: Ammar Husain Mian Fazulul Date: Fri, 16 May 2025 15:18:42 +0530 Subject: [PATCH 02/64] users/ammar/feat/testplan --- nisystemlink/clients/test_plan/{model => models}/__init__.py | 0 .../clients/test_plan/{model => models}/_execution_definition.py | 0 .../test_plan/test_plan_templates/{model => models}/__init__.py | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename nisystemlink/clients/test_plan/{model => models}/__init__.py (100%) rename nisystemlink/clients/test_plan/{model => models}/_execution_definition.py (100%) rename nisystemlink/clients/test_plan/test_plan_templates/{model => models}/__init__.py (100%) diff --git a/nisystemlink/clients/test_plan/model/__init__.py b/nisystemlink/clients/test_plan/models/__init__.py similarity index 100% rename from nisystemlink/clients/test_plan/model/__init__.py rename to nisystemlink/clients/test_plan/models/__init__.py diff --git a/nisystemlink/clients/test_plan/model/_execution_definition.py b/nisystemlink/clients/test_plan/models/_execution_definition.py similarity index 100% rename from nisystemlink/clients/test_plan/model/_execution_definition.py rename to nisystemlink/clients/test_plan/models/_execution_definition.py diff --git a/nisystemlink/clients/test_plan/test_plan_templates/model/__init__.py b/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plan_templates/model/__init__.py rename to nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py From f09ab697ac1c898dc449e838ee900cd68c44fc30 Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Fri, 16 May 2025 15:45:46 +0530 Subject: [PATCH 03/64] add testplans api client and models --- .../clients/test_plan/test_plans/__init__.py | 3 + .../test_plans/_test_plans_client.py | 106 ++++++++++++++++++ .../test_plan/test_plans/models/__init__.py | 11 ++ .../test_plans/models/_create_test_plans.py | 96 ++++++++++++++++ .../test_plans/models/_delete_test_plans.py | 21 ++++ .../test_plans/models/_execution_event.py | 34 ++++++ .../test_plans/models/_query_test_plans.py | 43 +++++++ .../test_plans/models/_schedule_test_plans.py | 53 +++++++++ .../test_plan/test_plans/models/_state.py | 13 +++ .../test_plan/test_plans/models/_test_plan.py | 100 +++++++++++++++++ .../test_plans/models/_update_test_plans.py | 67 +++++++++++ .../test_plans/models/_workflow_definition.py | 66 +++++++++++ 12 files changed, 613 insertions(+) create mode 100644 nisystemlink/clients/test_plan/test_plans/__init__.py create mode 100644 nisystemlink/clients/test_plan/test_plans/_test_plans_client.py create mode 100644 nisystemlink/clients/test_plan/test_plans/models/__init__.py create mode 100644 nisystemlink/clients/test_plan/test_plans/models/_create_test_plans.py create mode 100644 nisystemlink/clients/test_plan/test_plans/models/_delete_test_plans.py create mode 100644 nisystemlink/clients/test_plan/test_plans/models/_execution_event.py create mode 100644 nisystemlink/clients/test_plan/test_plans/models/_query_test_plans.py create mode 100644 nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans.py create mode 100644 nisystemlink/clients/test_plan/test_plans/models/_state.py create mode 100644 nisystemlink/clients/test_plan/test_plans/models/_test_plan.py create mode 100644 nisystemlink/clients/test_plan/test_plans/models/_update_test_plans.py create mode 100644 nisystemlink/clients/test_plan/test_plans/models/_workflow_definition.py diff --git a/nisystemlink/clients/test_plan/test_plans/__init__.py b/nisystemlink/clients/test_plan/test_plans/__init__.py new file mode 100644 index 00000000..b1e7f049 --- /dev/null +++ b/nisystemlink/clients/test_plan/test_plans/__init__.py @@ -0,0 +1,3 @@ +from ._test_plans_client import TestPlansClient + +# flake8: noqa \ No newline at end of file diff --git a/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py b/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py new file mode 100644 index 00000000..843d4614 --- /dev/null +++ b/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py @@ -0,0 +1,106 @@ +from uplink import Field +from nisystemlink.clients.core._uplink._base_client import BaseClient +from nisystemlink.clients.core._uplink._methods import get, post +from nisystemlink.clients import core +from .models import ( + TestPlan, + CreateTestPlansRequestBody, + CreateTestPlansResponse, + ScheduleTestPlansRequestBody, + ScheduleTestPlansResponse, + QueryTestPlansRequestBody, + QueryTestPlansResponse, + UpdateTestPlansRequestBody, + UpdateTestPlansResponse, + DeleteTestPlansResponse, + DeleteTestPlansRequestBody +) + +class TestPlansClient(BaseClient): + def __init__(self, client): + """Initialize an instance. + + Args: + configuration: Defines the web server to connect to and information about + how to connect. If not provided, the + :class:`HttpConfigurationManager ` + is used to obtain the configuration. + + Raises: + ApiException: if unable to communicate with the WorkOrder Service. + """ + if configuration is None: + configuration = core.HttpConfigurationManager.get_configuration() + super().__init__(configuration, base_path="/niworkorder/v1/") + + @get("testplans/{test_plan_id}") + def get_test_plan(self, test_plan_id) -> TestPlan: + """Retrieve a test plan by its ID. + + Args: + test_plan_id: The ID of the test plan to retrieve. + + Returns: + The TestPlan object corresponding to the given ID. + """ + ... + + @post("testplans", args=[Field("test_plan")]) + def create_test_plan(self, test_plan: CreateTestPlansRequestBody) -> CreateTestPlansResponse: + """Create a new test plan. + + Args: + test_plan: The test plan to create. + + Returns: + The created test plan object. + """ + ... + + @post("delete-testplans", args=[Field("test_plan_ids")]) + def delete_test_plans(self, test_plan_ids: DeleteTestPlansRequestBody) -> DeleteTestPlansResponse: + """Delete test plans by IDs. + + Args: + test_plan_ids: A list of test plan IDs to delete. + + Returns: + None + """ + ... + + @post("query-testplans", args=[Field("query")]) + def query_test_plans(self, query: QueryTestPlansRequestBody) -> QueryTestPlansResponse: + """Query test plans. + + Args: + query: The query to execute. + + Returns: + A QueryTestPlansResponse object containing test plans that match the query. + """ + ... + + @post("schedule-testplans", args=[Field("schedule")]) + def schedule_test_plan(self, schedule: ScheduleTestPlansRequestBody) -> ScheduleTestPlansResponse: + """Schedule a test plan. + + Args: + schedule: The schedule to apply to the test plan. + + Returns: + A ScheduleTestPlansResponse object containing the scheduled test plan. + """ + ... + + @post("update-testplans", args=[Field("test_plans")]) + def update_test_plan(self, test_plans: UpdateTestPlansRequestBody) -> UpdateTestPlansResponse: + """Update a test plan. + + Args: + test_plan: The test plan to update. + + Returns: + The updated test plan object. + """ + ... diff --git a/nisystemlink/clients/test_plan/test_plans/models/__init__.py b/nisystemlink/clients/test_plan/test_plans/models/__init__.py new file mode 100644 index 00000000..ad1be873 --- /dev/null +++ b/nisystemlink/clients/test_plan/test_plans/models/__init__.py @@ -0,0 +1,11 @@ +from ._create_test_plans import CreateTestPlansRequestBody, CreateTestPlansResponse +from ._delete_test_plans import DeleteTestPlansRequestBody, DeleteTestPlansResponse +from ._execution_event import ExecutionEvent +from ._query_test_plans import QueryTestPlansRequestBody, QueryTestPlansResponse +from ._schedule_test_plans import ScheduleTestPlansRequestBody, ScheduleTestPlansResponse +from ._state import State +from ._test_plan import TestPlan +from ._update_test_plans import UpdateTestPlansRequestBody, UpdateTestPlansResponse +from ._workflow_definition import WorkflowDefinition + +# flake8: noqa \ No newline at end of file diff --git a/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans.py b/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans.py new file mode 100644 index 00000000..8488275a --- /dev/null +++ b/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans.py @@ -0,0 +1,96 @@ +from typing import Dict, List, Optional + +from nisystemlink.clients.core import ApiError +from nisystemlink.clients.core._uplink._json_model import JsonModel +from ...models._execution_definition import ExecutionDefinition +from ._test_plan import TestPlan + +class Dashboard(JsonModel): + """Represents a dashboard reference.""" + + id: str + """ID of the dashboard""" + + variables: Optional[Dict[str, str]] = None + """Variables for the dashboard""" + +class CreateTestPlanRequestBodyContent: + """Represents the request body content for creating a test plan.""" + + name: str + """The name of the test plan.""" + + templateId: Optional[str] + """The ID of the template to use for the test plan.""" + + state: str + """The state of the test plan.""" + + description: Optional[str] + """A description of the test plan.""" + + assignedTo: Optional[str] + """The user or group assigned to the test plan.""" + + workOrderId: Optional[str] + """The work order ID associated with the test plan.""" + + estimatedDurationInSeconds: Optional[int] + """The estimated duration of the test plan in seconds.""" + + properties: Optional[Dict[str, str]] = None + """Additional properties for the test plan.""" + + partNumber: str = "" + """The part number associated with the test plan.""" + + dutId: Optional[str] = None + """The Device Under Test (DUT) ID.""" + + testProgram: str = "" + """The test program associated with the test plan.""" + + systemFilter: Optional[str] = None + """The system filter to apply.""" + + workspace: Optional[str] = None + """The workspace associated with the test plan.""" + + fileIdsFromTemplate: Optional[List[str]] = None + """List of file IDs from the template.""" + + dashboardReference: Optional[Dashboard] = None + """Reference to a dashboard.""" + + dashboard: Optional[Dashboard] = None + """The dashboard associated with the test plan.""" + + executionActions: Optional[List[ExecutionDefinition]] = None + """List of execution actions for the test plan.""" + +class CreateTestPlansRequestBody: + """Represents the request body for creating multiple test plans.""" + + testPlans: List[CreateTestPlanRequestBodyContent] + """ + A list of test plan creation request bodies. Each item in the list contains + the content required to create an individual test plan. + """ + +class CreateTestPlansResponse: + """ + Represents the response from creating test plans, including successfully created, + failed test plans, and any associated errors. + """ + + testPlans: Optional[List[TestPlan]] = None + """List of all test plans involved in the operation.""" + + createdTestPlans: Optional[List[TestPlan]] = None + """List of test plans that were successfully created.""" + + failedTestPlans: Optional[List[CreateTestPlanRequestBodyContent]] = None + """List of test plans that failed to be created, with their request body content.""" + + error: Optional[ApiError] = None + """Error information if the operation encountered issues.""" diff --git a/nisystemlink/clients/test_plan/test_plans/models/_delete_test_plans.py b/nisystemlink/clients/test_plan/test_plans/models/_delete_test_plans.py new file mode 100644 index 00000000..70054227 --- /dev/null +++ b/nisystemlink/clients/test_plan/test_plans/models/_delete_test_plans.py @@ -0,0 +1,21 @@ +from typing import List, Optional + +from nisystemlink.clients.core import ApiError + +class DeleteTestPlansRequestBody: + """Represents a request to delete one or more test plans.""" + + ids: List[str] + """List of test plan IDS of test plans to be deleted""" + +class DeleteTestPlansResponse: + """Response fields for delete test plans operation.""" + + deletedTestPlanIds: Optional[List[str]] = None + """List of test plan IDs that were successfully deleted.""" + + failedTestPlanIds: Optional[List[str]] = None + """List of test plan IDs that failed to be deleted.""" + + error: Optional[ApiError] = None + """Error information if the delete operation encountered issues.""" diff --git a/nisystemlink/clients/test_plan/test_plans/models/_execution_event.py b/nisystemlink/clients/test_plan/test_plans/models/_execution_event.py new file mode 100644 index 00000000..db4e3355 --- /dev/null +++ b/nisystemlink/clients/test_plan/test_plans/models/_execution_event.py @@ -0,0 +1,34 @@ +from typing import List, Literal, Union + +class ExecutionEventBase: + action: str + """Base class for execution events, containing common attributes such as action.""" + + triggeredAt: str + """the time the event was triggered.""" + + triggeredBy: str = None + """and the user who triggered it.""" + + +class NotebookExecutionEvent(ExecutionEventBase): + type: Literal['NOTEBOOK'] + """Represents an execution event triggered by a notebook.""" + + executionId: str + """Includes the type identifier and the execution ID.""" + + +class JobExecutionEvent(ExecutionEventBase): + type: Literal['JOB'] + """Represents an execution event triggered by a job.""" + + jobIds: List[str] + """Includes the type identifier and a list of job IDs.""" + + +class ManualExecutionEvent(ExecutionEventBase): + type: Literal['MANUAL'] + """Represents an execution event triggered manually. Includes only the type identifier.""" + +ExecutionEvent = Union[NotebookExecutionEvent, ManualExecutionEvent, JobExecutionEvent] diff --git a/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans.py b/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans.py new file mode 100644 index 00000000..e2da414d --- /dev/null +++ b/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans.py @@ -0,0 +1,43 @@ +from typing import List, Optional + +from nisystemlink.clients.core._uplink._json_model import JsonModel +from ._test_plan import TestPlan + +class QueryTestPlansRequestBody(JsonModel): + """ + Represents the request body for querying test plans. + Allows filtering, sorting, and pagination of test plan results. + """ + + filter: Optional[str] = None + """A string expression to filter the test plans returned by the query.""" + + take: Optional[int] = None + """The maximum number of test plans to return in the response.""" + + order_by: Optional[str] = None + """The field name to use for sorting the test plans.""" + + descending: Optional[bool] = None + """Whether to sort the test plans in descending order.""" + + return_count: Optional[bool] = None + """Whether to include the total count of matching test plans in the response.""" + + continuation_token: Optional[str] = None + """A token to retrieve the next page of results for paginated queries.""" + +class QueryTestPlansResponse(JsonModel): + """ + Represents the response from querying test plans. + Contains a list of test plans, a continuation token for pagination, and the total count. + """ + + test_plans: List[TestPlan] + """A list of test plans returned by the query.""" + + continuation_token: Optional[str] = None + """A token to retrieve the next page of results for paginated queries.""" + + total_count: Optional[int] = None + """The total number of test plans matching the query filter.""" diff --git a/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans.py b/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans.py new file mode 100644 index 00000000..8279dae9 --- /dev/null +++ b/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans.py @@ -0,0 +1,53 @@ +from typing import List, Optional + +from nisystemlink.clients.core import ApiError +from nisystemlink.clients.core._uplink._json_model import JsonModel +from ._test_plan import TestPlan + +class ScheduleTestPlanRequestBodyContent(JsonModel): + """Represents the request body content for scheduling a test plan.""" + + id: str + """Unique identifier for the test plan to be scheduled.""" + + assigned_to: Optional[str] = None + """(Optional) User or entity to whom the test plan is assigned.""" + + dut_id: Optional[str] = None + """(Optional) Identifier for the Device Under Test (DUT).""" + + system_id: Optional[str] = None + """(Optional) Identifier for the system where the test plan will run.""" + + planned_start_date_time: Optional[str] = None + """(Optional) Planned start date and time for the test plan execution (ISO 8601 format).""" + + estimated_end_date_time: Optional[str] = None + """(Optional) Estimated end date and time for the test plan execution (ISO 8601 format).""" + + estimated_duration_in_seconds: Optional[int] = None + """(Optional) Estimated duration of the test plan execution in seconds.""" + + fixture_ids: Optional[List[str]] = None + """(Optional) List of fixture identifiers associated with the test plan.""" + +class ScheduleTestPlansRequestBody(JsonModel): + """Represents the request body for scheduling multiple test plans.""" + + test_plans: List['ScheduleTestPlanRequestBodyContent'] + """List of test plan scheduling content objects.""" + + replace: Optional[bool] = None + """(Optional) If true, replaces existing scheduled test plans.""" + +class ScheduleTestPlansResponse(JsonModel): + """Represents the response returned after attempting to schedule one or more test plans.""" + + scheduled_test_plans: Optional[List[TestPlan]] = None + """(Optional) List of successfully scheduled test plans.""" + + failed_test_plans: Optional[List[ScheduleTestPlanRequestBodyContent]] = None + """(Optional) List of test plan requests that failed to schedule.""" + + error: Optional[ApiError] = None + """(Optional) API error information if scheduling failed.""" diff --git a/nisystemlink/clients/test_plan/test_plans/models/_state.py b/nisystemlink/clients/test_plan/test_plans/models/_state.py new file mode 100644 index 00000000..63f7d2a6 --- /dev/null +++ b/nisystemlink/clients/test_plan/test_plans/models/_state.py @@ -0,0 +1,13 @@ +from enum import Enum + +class State(Enum): + """The state of the test plan.""" + + New = 'NEW' + Defined = 'DEFINED' + Reviewed = 'REVIEWED' + Scheduled = 'SCHEDULED' + InProgress = 'IN_PROGRESS' + PendingApproval = 'PENDING_APPROVAL' + Closed = 'CLOSED' + Canceled = 'CANCELED' diff --git a/nisystemlink/clients/test_plan/test_plans/models/_test_plan.py b/nisystemlink/clients/test_plan/test_plans/models/_test_plan.py new file mode 100644 index 00000000..bd61cc4e --- /dev/null +++ b/nisystemlink/clients/test_plan/test_plans/models/_test_plan.py @@ -0,0 +1,100 @@ +from typing import Optional, Dict, List + +from nisystemlink.clients.core._uplink._json_model import JsonModel +from ._state import State +from ._workflow_definition import WorkflowDefinition +from ._execution_event import ExecutionEvent +from ...models._execution_definition import ExecutionDefinition + +class TestPlan(JsonModel): + """Contains information about a test plan.""" + + id: str + """The unique identifier of the test plan.""" + + templateId: Optional[str] + """The identifier of the template used to create the test plan.""" + + name: str + """The name of the test plan.""" + + state: State + """The current state of the test plan.""" + + substate: Optional[str] + """The substate of the test plan, if any.""" + + description: Optional[str] + """The description of the test plan.""" + + assignedTo: Optional[str] + """The user or group assigned to the test plan.""" + + workOrderId: Optional[str] + """The identifier of the associated work order.""" + + workOrderName: Optional[str] + """The name of the associated work order.""" + + workspace: str + """The workspace to which the test plan belongs.""" + + createdBy: str + """The user who created the test plan.""" + + updatedBy: str + """The user who last updated the test plan.""" + + createdAt: str + """The date and time when the test plan was created.""" + + updatedAt: str + """The date and time when the test plan was last updated.""" + + properties: Dict[str, str] + """Additional properties associated with the test plan.""" + + partNumber: str + """The part number associated with the test plan.""" + + dutId: Optional[str] + """The identifier of the device under test (DUT).""" + + testProgram: Optional[str] + """The test program associated with the test plan.""" + + systemId: Optional[str] + """The identifier of the system used for the test plan.""" + + fixtureIds: List[str] + """The list of fixture identifiers associated with the test plan.""" + + systemFilter: Optional[str] + """The filter used to select systems for the test plan.""" + + plannedStartDateTime: Optional[str] + """The planned start date and time for the test plan.""" + + estimatedEndDateTime: Optional[str] + """The estimated end date and time for the test plan.""" + + estimatedDurationInSeconds: Optional[float] + """The estimated duration of the test plan in seconds.""" + + fileIdsFromTemplate: List[str] + """The list of file identifiers inherited from the template.""" + + executionActions: Optional[ExecutionDefinition] + """The execution actions defined for the test plan.""" + + executionHistory: Optional[ExecutionEvent] + """The execution history of the test plan.""" + + dashboardUrl: Optional[Dict[str, str]] + """The URLs for dashboards related to the test plan.""" + + dashboard: Optional[Dict[str, str]] + """The dashboard data related to the test plan.""" + + workflow: WorkflowDefinition + """The workflow definition associated with the test plan.""" diff --git a/nisystemlink/clients/test_plan/test_plans/models/_update_test_plans.py b/nisystemlink/clients/test_plan/test_plans/models/_update_test_plans.py new file mode 100644 index 00000000..33174d3f --- /dev/null +++ b/nisystemlink/clients/test_plan/test_plans/models/_update_test_plans.py @@ -0,0 +1,67 @@ +from typing import List, Optional, Dict, Union + +from nisystemlink.clients.core._uplink._json_model import JsonModel +from nisystemlink.clients.core import ApiError +from . import TestPlan + +class UpdateTestPlanRequestBodyContent(JsonModel): + """Represents the content for updating a single test plan.""" + + id: str + """The unique identifier of the test plan to update.""" + + name: Optional[str] = None + """The new name for the test plan.""" + + state: Optional[str] = None + """The new state of the test plan.""" + + description: Optional[str] = None + """The new description for the test plan.""" + + dut_id: Optional[Union[str, None]] = None + """The device under test (DUT) identifier.""" + + part_number: Optional[str] = None + """The part number associated with the test plan.""" + + assigned_to: Optional[Union[str, None]] = None + """The user or group assigned to the test plan.""" + + test_program: Optional[Union[str, None]] = None + """The test program associated with the test plan.""" + + properties: Optional[Union[Dict[str, str], None]] = None + """Additional properties for the test plan as key-value pairs.""" + + workspace: Optional[Union[str, None]] = None + """The workspace to which the test plan belongs.""" + + work_order_id: Optional[Union[str, None]] = None + """The work order identifier associated with the test plan.""" + + file_ids_from_template: Optional[List[str]] = None + """List of file IDs from the template to associate with the test plan.""" + + +class UpdateTestPlansRequestBody(JsonModel): + """Represents the request body for updating multiple test plans.""" + + test_plans: List[UpdateTestPlanRequestBodyContent] + """A list of test plans to update.""" + + replace: Optional[bool] = None + """Whether to replace the existing test plans or update them.""" + + +class UpdateTestPlansResponse(JsonModel): + """Represents the response after attempting to update test plans.""" + + updated_test_plans: Optional[List[TestPlan]] = None + """List of successfully updated test plans.""" + + failed_test_plans: Optional[List[UpdateTestPlanRequestBodyContent]] = None + """List of test plans that failed to update.""" + + error: Optional[ApiError] = None + """Error information if the update operation failed.""" diff --git a/nisystemlink/clients/test_plan/test_plans/models/_workflow_definition.py b/nisystemlink/clients/test_plan/test_plans/models/_workflow_definition.py new file mode 100644 index 00000000..cbae1635 --- /dev/null +++ b/nisystemlink/clients/test_plan/test_plans/models/_workflow_definition.py @@ -0,0 +1,66 @@ +from nisystemlink.clients.core._uplink._json_model import JsonModel +from ._state import State +from ...models._execution_definition import ExecutionDefinition + +class ActionTransitionDefinition(JsonModel): + """Represents a transition between workflow states triggered by a specific action.""" + + action: str + """The name of the action that triggers the transition.""" + + nextState: State + """The state to transition to after the action is performed.""" + + nextSubstate: str + """The substate to transition to within the next state.""" + + showInUI: bool + """Indicates whether this transition should be visible in the user interface.""" + +class SubstateDefinition(JsonModel): + """Represents a substate within a workflow definition.""" + + id: str + """The unique identifier for the substate.""" + + label: str + """The display label for the substate.""" + + availableActions: list[ActionTransitionDefinition] + """List of actions that can be performed from this substate.""" + +class StateDefinition(JsonModel): + """Represents the definition of a workflow state within a test plan.""" + + state: State + """The state associated with this definition.""" + + dashboardAvailable: bool + """Indicates if the state is available on the dashboard.""" + + defaultSubstate: str + """The name of the default substate for this state.""" + + substates: list[SubstateDefinition] + """A list of substates defined for this state.""" + +class ActionDefinition(JsonModel): + """Represents the definition of an action within a workflow.""" + + id: str + """The unique identifier for the action.""" + + label: str + """The display label for the action.""" + + executionAction: ExecutionDefinition + """The execution details associated with the action.""" + +class WorkflowDefinition(JsonModel): + """Contains information about a workflow definition.""" + + actions: list[ActionDefinition] + """A list of action definitions in the workflow.""" + + states: list[StateDefinition] + """A list of state definitions in the workflow.""" From 0ebc4a53f72c030ebff2a242c79d4cf50595f11e Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Fri, 16 May 2025 16:01:47 +0530 Subject: [PATCH 04/64] update request model name --- .../test_plans/_test_plans_client.py | 20 +++++++++---------- .../test_plan/test_plans/models/__init__.py | 10 +++++----- .../test_plans/models/_create_test_plans.py | 2 +- .../test_plans/models/_delete_test_plans.py | 2 +- .../test_plans/models/_query_test_plans.py | 2 +- .../test_plans/models/_schedule_test_plans.py | 2 +- .../test_plans/models/_update_test_plans.py | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py b/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py index 843d4614..637dd915 100644 --- a/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py +++ b/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py @@ -4,16 +4,16 @@ from nisystemlink.clients import core from .models import ( TestPlan, - CreateTestPlansRequestBody, + CreateTestPlansRequest, CreateTestPlansResponse, - ScheduleTestPlansRequestBody, + ScheduleTestPlansRequest, ScheduleTestPlansResponse, - QueryTestPlansRequestBody, + QueryTestPlansRequest, QueryTestPlansResponse, - UpdateTestPlansRequestBody, + UpdateTestPlansRequest, UpdateTestPlansResponse, DeleteTestPlansResponse, - DeleteTestPlansRequestBody + DeleteTestPlansRequest ) class TestPlansClient(BaseClient): @@ -46,7 +46,7 @@ def get_test_plan(self, test_plan_id) -> TestPlan: ... @post("testplans", args=[Field("test_plan")]) - def create_test_plan(self, test_plan: CreateTestPlansRequestBody) -> CreateTestPlansResponse: + def create_test_plan(self, test_plan: CreateTestPlansRequest) -> CreateTestPlansResponse: """Create a new test plan. Args: @@ -58,7 +58,7 @@ def create_test_plan(self, test_plan: CreateTestPlansRequestBody) -> CreateTestP ... @post("delete-testplans", args=[Field("test_plan_ids")]) - def delete_test_plans(self, test_plan_ids: DeleteTestPlansRequestBody) -> DeleteTestPlansResponse: + def delete_test_plans(self, test_plan_ids: DeleteTestPlansRequest) -> DeleteTestPlansResponse: """Delete test plans by IDs. Args: @@ -70,7 +70,7 @@ def delete_test_plans(self, test_plan_ids: DeleteTestPlansRequestBody) -> Delete ... @post("query-testplans", args=[Field("query")]) - def query_test_plans(self, query: QueryTestPlansRequestBody) -> QueryTestPlansResponse: + def query_test_plans(self, query: QueryTestPlansRequest) -> QueryTestPlansResponse: """Query test plans. Args: @@ -82,7 +82,7 @@ def query_test_plans(self, query: QueryTestPlansRequestBody) -> QueryTestPlansRe ... @post("schedule-testplans", args=[Field("schedule")]) - def schedule_test_plan(self, schedule: ScheduleTestPlansRequestBody) -> ScheduleTestPlansResponse: + def schedule_test_plan(self, schedule: ScheduleTestPlansRequest) -> ScheduleTestPlansResponse: """Schedule a test plan. Args: @@ -94,7 +94,7 @@ def schedule_test_plan(self, schedule: ScheduleTestPlansRequestBody) -> Schedule ... @post("update-testplans", args=[Field("test_plans")]) - def update_test_plan(self, test_plans: UpdateTestPlansRequestBody) -> UpdateTestPlansResponse: + def update_test_plan(self, test_plans: UpdateTestPlansRequest) -> UpdateTestPlansResponse: """Update a test plan. Args: diff --git a/nisystemlink/clients/test_plan/test_plans/models/__init__.py b/nisystemlink/clients/test_plan/test_plans/models/__init__.py index ad1be873..f3465ccb 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/__init__.py +++ b/nisystemlink/clients/test_plan/test_plans/models/__init__.py @@ -1,11 +1,11 @@ -from ._create_test_plans import CreateTestPlansRequestBody, CreateTestPlansResponse -from ._delete_test_plans import DeleteTestPlansRequestBody, DeleteTestPlansResponse +from ._create_test_plans import CreateTestPlansRequest, CreateTestPlansResponse +from ._delete_test_plans import DeleteTestPlansRequest, DeleteTestPlansResponse from ._execution_event import ExecutionEvent -from ._query_test_plans import QueryTestPlansRequestBody, QueryTestPlansResponse -from ._schedule_test_plans import ScheduleTestPlansRequestBody, ScheduleTestPlansResponse +from ._query_test_plans import QueryTestPlansRequest, QueryTestPlansResponse +from ._schedule_test_plans import ScheduleTestPlansRequest, ScheduleTestPlansResponse from ._state import State from ._test_plan import TestPlan -from ._update_test_plans import UpdateTestPlansRequestBody, UpdateTestPlansResponse +from ._update_test_plans import UpdateTestPlansRequest, UpdateTestPlansResponse from ._workflow_definition import WorkflowDefinition # flake8: noqa \ No newline at end of file diff --git a/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans.py b/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans.py index 8488275a..deef1a0f 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans.py @@ -68,7 +68,7 @@ class CreateTestPlanRequestBodyContent: executionActions: Optional[List[ExecutionDefinition]] = None """List of execution actions for the test plan.""" -class CreateTestPlansRequestBody: +class CreateTestPlansRequest: """Represents the request body for creating multiple test plans.""" testPlans: List[CreateTestPlanRequestBodyContent] diff --git a/nisystemlink/clients/test_plan/test_plans/models/_delete_test_plans.py b/nisystemlink/clients/test_plan/test_plans/models/_delete_test_plans.py index 70054227..d3bf8c05 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_delete_test_plans.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_delete_test_plans.py @@ -2,7 +2,7 @@ from nisystemlink.clients.core import ApiError -class DeleteTestPlansRequestBody: +class DeleteTestPlansRequest: """Represents a request to delete one or more test plans.""" ids: List[str] diff --git a/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans.py b/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans.py index e2da414d..a0a2df5d 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans.py @@ -3,7 +3,7 @@ from nisystemlink.clients.core._uplink._json_model import JsonModel from ._test_plan import TestPlan -class QueryTestPlansRequestBody(JsonModel): +class QueryTestPlansRequest(JsonModel): """ Represents the request body for querying test plans. Allows filtering, sorting, and pagination of test plan results. diff --git a/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans.py b/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans.py index 8279dae9..b68455be 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans.py @@ -31,7 +31,7 @@ class ScheduleTestPlanRequestBodyContent(JsonModel): fixture_ids: Optional[List[str]] = None """(Optional) List of fixture identifiers associated with the test plan.""" -class ScheduleTestPlansRequestBody(JsonModel): +class ScheduleTestPlansRequest(JsonModel): """Represents the request body for scheduling multiple test plans.""" test_plans: List['ScheduleTestPlanRequestBodyContent'] diff --git a/nisystemlink/clients/test_plan/test_plans/models/_update_test_plans.py b/nisystemlink/clients/test_plan/test_plans/models/_update_test_plans.py index 33174d3f..b095b774 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_update_test_plans.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_update_test_plans.py @@ -44,7 +44,7 @@ class UpdateTestPlanRequestBodyContent(JsonModel): """List of file IDs from the template to associate with the test plan.""" -class UpdateTestPlansRequestBody(JsonModel): +class UpdateTestPlansRequest(JsonModel): """Represents the request body for updating multiple test plans.""" test_plans: List[UpdateTestPlanRequestBodyContent] From 95053ad7d73dc2181322c39bfc7bd83ae326dfde Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Fri, 16 May 2025 16:04:37 +0530 Subject: [PATCH 05/64] test setup --- tests/test_plan/test_plans/__init__.py | 1 + tests/test_plan/test_plans/test_test_plans.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 tests/test_plan/test_plans/__init__.py create mode 100644 tests/test_plan/test_plans/test_test_plans.py diff --git a/tests/test_plan/test_plans/__init__.py b/tests/test_plan/test_plans/__init__.py new file mode 100644 index 00000000..a517c684 --- /dev/null +++ b/tests/test_plan/test_plans/__init__.py @@ -0,0 +1 @@ +# flake8: noqa \ No newline at end of file diff --git a/tests/test_plan/test_plans/test_test_plans.py b/tests/test_plan/test_plans/test_test_plans.py new file mode 100644 index 00000000..d73d932b --- /dev/null +++ b/tests/test_plan/test_plans/test_test_plans.py @@ -0,0 +1,16 @@ + + +import pytest +from nisystemlink.clients.core._http_configuration import HttpConfiguration +from nisystemlink.clients.test_plan.test_plans import TestPlansClient +from typing import List + +@pytest.fixtures(scope="class") +def client(enterprise_config: HttpConfiguration) -> TestPlansClient: + """Fixture to create a TestPlansClient instance""" + return TestPlansClient(enterprise_config) + +@pytest.mark.integration +@pytest.mark.enterprise +class TestTestPlans: + ... \ No newline at end of file From 5d96899fefb4bf2b0eaccf44874cd83ee40d4552 Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Fri, 16 May 2025 16:45:52 +0530 Subject: [PATCH 06/64] add create test --- .../test_plan/test_plans/__init__.py | 1 + .../test_plan/test_plans/test_test_plans.py | 50 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 tests/integration/test_plan/test_plans/__init__.py create mode 100644 tests/integration/test_plan/test_plans/test_test_plans.py diff --git a/tests/integration/test_plan/test_plans/__init__.py b/tests/integration/test_plan/test_plans/__init__.py new file mode 100644 index 00000000..a517c684 --- /dev/null +++ b/tests/integration/test_plan/test_plans/__init__.py @@ -0,0 +1 @@ +# flake8: noqa \ No newline at end of file diff --git a/tests/integration/test_plan/test_plans/test_test_plans.py b/tests/integration/test_plan/test_plans/test_test_plans.py new file mode 100644 index 00000000..26ede196 --- /dev/null +++ b/tests/integration/test_plan/test_plans/test_test_plans.py @@ -0,0 +1,50 @@ +import pytest +from typing import List + +from nisystemlink.clients.core._http_configuration import HttpConfiguration +from nisystemlink.clients.test_plan.test_plans import TestPlansClient +from nisystemlink.clients.test_plan.test_plans.models import ( + CreateTestPlanRequestBodyContent, + CreateTestPlansRequest, + CreateTestPlansResponse, +) + +@pytest.fixture(scope="class") +def test_plan_create() -> CreateTestPlansRequest: + """Fixture to create create test plan object.""" + + testPlan = CreateTestPlansRequest( + testPlans = List[CreateTestPlanRequestBodyContent( + name="Sample Test Plan", + state="NEW", + partNumber="px40482" + )] + ) + + return testPlan + +@pytest.fixtures(scope="class") +def client(enterprise_config: HttpConfiguration) -> TestPlansClient: + """Fixture to create a TestPlansClient instance""" + return TestPlansClient(enterprise_config) + + +@pytest.mark.integration +@pytest.mark.enterprise +class TestTestPlans: + + def test__create_test_plan__returns_created_test_plan( + self, client: TestPlansClient, test_plan_create: CreateTestPlansRequest + ): + test_plan_create_response: CreateTestPlansResponse = client.create_test_plan( + test_plan=test_plan_create + ) + + client.delete_test_plans(test_plan_ids=[created_test_plan.id]) + + assert test_plan_create_response is not None + assert len(test_plan_create_response.testPlans) == 1 + created_test_plan = test_plan_create_response.testPlans[0] + assert created_test_plan.name == "Sample Test Plan" + assert created_test_plan.state == "NEW" + assert created_test_plan.partNumber == "px40482" From 8eca2b325eb017518a19caf2be66897bbf229beb Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Fri, 16 May 2025 16:46:20 +0530 Subject: [PATCH 07/64] lint --- .../test_plan/test_plans/models/__init__.py | 2 +- .../test_plans/models/_execution_event.py | 6 +++--- tests/{ => integration}/test_plan/__init__.py | 0 .../test_plan/test_plan_templates/__init__.py | 0 tests/test_plan/test_plans/__init__.py | 1 - tests/test_plan/test_plans/test_test_plans.py | 16 ---------------- 6 files changed, 4 insertions(+), 21 deletions(-) rename tests/{ => integration}/test_plan/__init__.py (100%) rename tests/{ => integration}/test_plan/test_plan_templates/__init__.py (100%) delete mode 100644 tests/test_plan/test_plans/__init__.py delete mode 100644 tests/test_plan/test_plans/test_test_plans.py diff --git a/nisystemlink/clients/test_plan/test_plans/models/__init__.py b/nisystemlink/clients/test_plan/test_plans/models/__init__.py index f3465ccb..7063554a 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/__init__.py +++ b/nisystemlink/clients/test_plan/test_plans/models/__init__.py @@ -1,4 +1,4 @@ -from ._create_test_plans import CreateTestPlansRequest, CreateTestPlansResponse +from ._create_test_plans import CreateTestPlansRequest, CreateTestPlanRequestBodyContent, CreateTestPlansResponse from ._delete_test_plans import DeleteTestPlansRequest, DeleteTestPlansResponse from ._execution_event import ExecutionEvent from ._query_test_plans import QueryTestPlansRequest, QueryTestPlansResponse diff --git a/nisystemlink/clients/test_plan/test_plans/models/_execution_event.py b/nisystemlink/clients/test_plan/test_plans/models/_execution_event.py index db4e3355..b9c8a2e5 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_execution_event.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_execution_event.py @@ -12,7 +12,7 @@ class ExecutionEventBase: class NotebookExecutionEvent(ExecutionEventBase): - type: Literal['NOTEBOOK'] + type: str = 'NOTEBOOK' """Represents an execution event triggered by a notebook.""" executionId: str @@ -20,7 +20,7 @@ class NotebookExecutionEvent(ExecutionEventBase): class JobExecutionEvent(ExecutionEventBase): - type: Literal['JOB'] + type: str = 'JOB' """Represents an execution event triggered by a job.""" jobIds: List[str] @@ -28,7 +28,7 @@ class JobExecutionEvent(ExecutionEventBase): class ManualExecutionEvent(ExecutionEventBase): - type: Literal['MANUAL'] + type: str = 'MANUAL' """Represents an execution event triggered manually. Includes only the type identifier.""" ExecutionEvent = Union[NotebookExecutionEvent, ManualExecutionEvent, JobExecutionEvent] diff --git a/tests/test_plan/__init__.py b/tests/integration/test_plan/__init__.py similarity index 100% rename from tests/test_plan/__init__.py rename to tests/integration/test_plan/__init__.py diff --git a/tests/test_plan/test_plan_templates/__init__.py b/tests/integration/test_plan/test_plan_templates/__init__.py similarity index 100% rename from tests/test_plan/test_plan_templates/__init__.py rename to tests/integration/test_plan/test_plan_templates/__init__.py diff --git a/tests/test_plan/test_plans/__init__.py b/tests/test_plan/test_plans/__init__.py deleted file mode 100644 index a517c684..00000000 --- a/tests/test_plan/test_plans/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# flake8: noqa \ No newline at end of file diff --git a/tests/test_plan/test_plans/test_test_plans.py b/tests/test_plan/test_plans/test_test_plans.py deleted file mode 100644 index d73d932b..00000000 --- a/tests/test_plan/test_plans/test_test_plans.py +++ /dev/null @@ -1,16 +0,0 @@ - - -import pytest -from nisystemlink.clients.core._http_configuration import HttpConfiguration -from nisystemlink.clients.test_plan.test_plans import TestPlansClient -from typing import List - -@pytest.fixtures(scope="class") -def client(enterprise_config: HttpConfiguration) -> TestPlansClient: - """Fixture to create a TestPlansClient instance""" - return TestPlansClient(enterprise_config) - -@pytest.mark.integration -@pytest.mark.enterprise -class TestTestPlans: - ... \ No newline at end of file From e9dfe5d59f81c12cfd6267bc61da8d36a989df65 Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Fri, 16 May 2025 18:24:29 +0530 Subject: [PATCH 08/64] fix test --- .../test_plans/_test_plans_client.py | 5 +++- .../test_plans/models/_create_test_plans.py | 23 ++++++++----------- .../test_plans/models/_execution_event.py | 3 ++- .../test_plans/models/_schedule_test_plans.py | 2 +- .../test_plan/test_plans/test_test_plans.py | 14 ++++++----- 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py b/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py index 637dd915..ff392349 100644 --- a/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py +++ b/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py @@ -1,5 +1,7 @@ from uplink import Field +from typing import Optional from nisystemlink.clients.core._uplink._base_client import BaseClient +from nisystemlink.clients.core._http_configuration import HttpConfiguration from nisystemlink.clients.core._uplink._methods import get, post from nisystemlink.clients import core from .models import ( @@ -17,7 +19,7 @@ ) class TestPlansClient(BaseClient): - def __init__(self, client): + def __init__(self, configuration: Optional[HttpConfiguration] = None): """Initialize an instance. Args: @@ -31,6 +33,7 @@ def __init__(self, client): """ if configuration is None: configuration = core.HttpConfigurationManager.get_configuration() + super().__init__(configuration, base_path="/niworkorder/v1/") @get("testplans/{test_plan_id}") diff --git a/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans.py b/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans.py index deef1a0f..3a13a54a 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans.py @@ -14,40 +14,40 @@ class Dashboard(JsonModel): variables: Optional[Dict[str, str]] = None """Variables for the dashboard""" -class CreateTestPlanRequestBodyContent: +class CreateTestPlanRequestBodyContent(JsonModel): """Represents the request body content for creating a test plan.""" name: str """The name of the test plan.""" - templateId: Optional[str] + templateId: Optional[str] = None """The ID of the template to use for the test plan.""" state: str """The state of the test plan.""" - description: Optional[str] + description: Optional[str] = None """A description of the test plan.""" - assignedTo: Optional[str] + assignedTo: Optional[str] = None """The user or group assigned to the test plan.""" - workOrderId: Optional[str] + workOrderId: Optional[str] = None """The work order ID associated with the test plan.""" - estimatedDurationInSeconds: Optional[int] + estimatedDurationInSeconds: Optional[int] = None """The estimated duration of the test plan in seconds.""" properties: Optional[Dict[str, str]] = None """Additional properties for the test plan.""" - partNumber: str = "" + partNumber: str """The part number associated with the test plan.""" dutId: Optional[str] = None """The Device Under Test (DUT) ID.""" - testProgram: str = "" + testProgram: Optional[str] = None """The test program associated with the test plan.""" systemFilter: Optional[str] = None @@ -59,16 +59,13 @@ class CreateTestPlanRequestBodyContent: fileIdsFromTemplate: Optional[List[str]] = None """List of file IDs from the template.""" - dashboardReference: Optional[Dashboard] = None - """Reference to a dashboard.""" - dashboard: Optional[Dashboard] = None """The dashboard associated with the test plan.""" executionActions: Optional[List[ExecutionDefinition]] = None """List of execution actions for the test plan.""" -class CreateTestPlansRequest: +class CreateTestPlansRequest(JsonModel): """Represents the request body for creating multiple test plans.""" testPlans: List[CreateTestPlanRequestBodyContent] @@ -77,7 +74,7 @@ class CreateTestPlansRequest: the content required to create an individual test plan. """ -class CreateTestPlansResponse: +class CreateTestPlansResponse(JsonModel): """ Represents the response from creating test plans, including successfully created, failed test plans, and any associated errors. diff --git a/nisystemlink/clients/test_plan/test_plans/models/_execution_event.py b/nisystemlink/clients/test_plan/test_plans/models/_execution_event.py index b9c8a2e5..2b332710 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_execution_event.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_execution_event.py @@ -1,6 +1,7 @@ from typing import List, Literal, Union +from nisystemlink.clients.core._uplink._json_model import JsonModel -class ExecutionEventBase: +class ExecutionEventBase(JsonModel): action: str """Base class for execution events, containing common attributes such as action.""" diff --git a/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans.py b/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans.py index b68455be..17f4b8f6 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans.py @@ -34,7 +34,7 @@ class ScheduleTestPlanRequestBodyContent(JsonModel): class ScheduleTestPlansRequest(JsonModel): """Represents the request body for scheduling multiple test plans.""" - test_plans: List['ScheduleTestPlanRequestBodyContent'] + test_plans: List[ScheduleTestPlanRequestBodyContent] """List of test plan scheduling content objects.""" replace: Optional[bool] = None diff --git a/tests/integration/test_plan/test_plans/test_test_plans.py b/tests/integration/test_plan/test_plans/test_test_plans.py index 26ede196..c95cdbc8 100644 --- a/tests/integration/test_plan/test_plans/test_test_plans.py +++ b/tests/integration/test_plan/test_plans/test_test_plans.py @@ -14,16 +14,18 @@ def test_plan_create() -> CreateTestPlansRequest: """Fixture to create create test plan object.""" testPlan = CreateTestPlansRequest( - testPlans = List[CreateTestPlanRequestBodyContent( - name="Sample Test Plan", - state="NEW", - partNumber="px40482" - )] + testPlans=[ + CreateTestPlanRequestBodyContent( + name="Sample Test Plan", + state="NEW", + partNumber="px40482" + ) + ] ) return testPlan -@pytest.fixtures(scope="class") +@pytest.fixture(scope="class") def client(enterprise_config: HttpConfiguration) -> TestPlansClient: """Fixture to create a TestPlansClient instance""" return TestPlansClient(enterprise_config) From 39630d8b1ec37b791df461cffa2c9d3f03cade78 Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Fri, 16 May 2025 22:39:29 +0530 Subject: [PATCH 09/64] test try 1 --- .../test_plan/test_plans/test_test_plans.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/integration/test_plan/test_plans/test_test_plans.py b/tests/integration/test_plan/test_plans/test_test_plans.py index c95cdbc8..20831290 100644 --- a/tests/integration/test_plan/test_plans/test_test_plans.py +++ b/tests/integration/test_plan/test_plans/test_test_plans.py @@ -7,6 +7,7 @@ CreateTestPlanRequestBodyContent, CreateTestPlansRequest, CreateTestPlansResponse, + TestPlan ) @pytest.fixture(scope="class") @@ -35,14 +36,23 @@ def client(enterprise_config: HttpConfiguration) -> TestPlansClient: @pytest.mark.enterprise class TestTestPlans: - def test__create_test_plan__returns_created_test_plan( + def test__get_test_plan__returns_get_test_plan( + self, client: TestPlansClient + ): + get_test_plan_response: TestPlan = client.get_test_plan("1567158") + + assert get_test_plan_response is not None + assert isinstance(get_test_plan_response, TestPlan) + assert get_test_plan_response.id == "1567158" + + def test__create_test_plan__returns_created_test_plans( self, client: TestPlansClient, test_plan_create: CreateTestPlansRequest ): - test_plan_create_response: CreateTestPlansResponse = client.create_test_plan( - test_plan=test_plan_create + test_plan_create_response: CreateTestPlansResponse = client.create_test_plans( + testplans=test_plan_create ) - client.delete_test_plans(test_plan_ids=[created_test_plan.id]) + client.delete_test_plans(test_plan_ids=[test_plan_create_response.createdTestPlans[0].id]) assert test_plan_create_response is not None assert len(test_plan_create_response.testPlans) == 1 From 703d06024c743c968b1a9e8767656e42ea4fb0bc Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Fri, 16 May 2025 22:39:44 +0530 Subject: [PATCH 10/64] test try 1 --- .../test_plans/_test_plans_client.py | 10 +++--- .../test_plan/test_plans/models/_test_plan.py | 36 +++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py b/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py index ff392349..8e47db06 100644 --- a/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py +++ b/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py @@ -48,20 +48,20 @@ def get_test_plan(self, test_plan_id) -> TestPlan: """ ... - @post("testplans", args=[Field("test_plan")]) - def create_test_plan(self, test_plan: CreateTestPlansRequest) -> CreateTestPlansResponse: + @post("testplans", args=[Field("testplans")]) + def create_test_plans(self, testplans: CreateTestPlansRequest) -> CreateTestPlansResponse: """Create a new test plan. Args: - test_plan: The test plan to create. + test_plan: The test plans to create. Returns: The created test plan object. """ ... - @post("delete-testplans", args=[Field("test_plan_ids")]) - def delete_test_plans(self, test_plan_ids: DeleteTestPlansRequest) -> DeleteTestPlansResponse: + @post("delete-testplans", args=[Field("ids")]) + def delete_test_plans(self, ids: DeleteTestPlansRequest) -> DeleteTestPlansResponse: """Delete test plans by IDs. Args: diff --git a/nisystemlink/clients/test_plan/test_plans/models/_test_plan.py b/nisystemlink/clients/test_plan/test_plans/models/_test_plan.py index bd61cc4e..8b8f70a7 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_test_plan.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_test_plan.py @@ -12,7 +12,7 @@ class TestPlan(JsonModel): id: str """The unique identifier of the test plan.""" - templateId: Optional[str] + templateId: Optional[str] = None """The identifier of the template used to create the test plan.""" name: str @@ -21,19 +21,19 @@ class TestPlan(JsonModel): state: State """The current state of the test plan.""" - substate: Optional[str] + substate: Optional[str] = None """The substate of the test plan, if any.""" - description: Optional[str] + description: Optional[str] = None """The description of the test plan.""" - assignedTo: Optional[str] + assignedTo: Optional[str] = None """The user or group assigned to the test plan.""" - workOrderId: Optional[str] + workOrderId: Optional[str] = None """The identifier of the associated work order.""" - workOrderName: Optional[str] + workOrderName: Optional[str] = None """The name of the associated work order.""" workspace: str @@ -57,43 +57,43 @@ class TestPlan(JsonModel): partNumber: str """The part number associated with the test plan.""" - dutId: Optional[str] + dutId: Optional[str] = None """The identifier of the device under test (DUT).""" - testProgram: Optional[str] + testProgram: Optional[str] = None """The test program associated with the test plan.""" - systemId: Optional[str] + systemId: Optional[str] = None """The identifier of the system used for the test plan.""" - fixtureIds: List[str] + fixtureIds: List[str] = None """The list of fixture identifiers associated with the test plan.""" - systemFilter: Optional[str] + systemFilter: Optional[str] = None """The filter used to select systems for the test plan.""" - plannedStartDateTime: Optional[str] + plannedStartDateTime: Optional[str] = None """The planned start date and time for the test plan.""" - estimatedEndDateTime: Optional[str] + estimatedEndDateTime: Optional[str] = None """The estimated end date and time for the test plan.""" - estimatedDurationInSeconds: Optional[float] + estimatedDurationInSeconds: Optional[float] = None """The estimated duration of the test plan in seconds.""" fileIdsFromTemplate: List[str] """The list of file identifiers inherited from the template.""" - executionActions: Optional[ExecutionDefinition] + executionActions: Optional[ExecutionDefinition] = None """The execution actions defined for the test plan.""" - executionHistory: Optional[ExecutionEvent] + executionHistory: Optional[ExecutionEvent] = None """The execution history of the test plan.""" - dashboardUrl: Optional[Dict[str, str]] + dashboardUrl: Optional[Dict[str, str]] = None """The URLs for dashboards related to the test plan.""" - dashboard: Optional[Dict[str, str]] + dashboard: Optional[Dict[str, str]] = None """The dashboard data related to the test plan.""" workflow: WorkflowDefinition From 881a44dae19f70e4a49a17e1e20c814c544a1b1a Mon Sep 17 00:00:00 2001 From: Ammar Husain Mian Fazulul Date: Sat, 17 May 2025 00:09:31 +0530 Subject: [PATCH 11/64] draft implementation --- .../test_plan/models/_execution_definition.py | 8 +- .../test_plan/test_plan_templates/__init__.py | 1 + .../_test_plan_templates_client.py | 62 +++++++++++++++ .../test_plan_templates/models/__init__.py | 4 + .../models/_create_test_plan_templates.py | 21 +++++ .../models/_delete_test_plan_templates.py | 14 ++++ .../models/_query_test_plan_templates.py | 71 +++++++++++++++++ .../models/_test_plan_templates.py | 32 ++++++++ tests/{ => integration}/test_plan/__init__.py | 0 .../test_plan/test_plan_templates/__init__.py | 0 .../test__create_test_plan_template.py | 78 +++++++++++++++++++ 11 files changed, 287 insertions(+), 4 deletions(-) create mode 100644 nisystemlink/clients/test_plan/test_plan_templates/_test_plan_templates_client.py create mode 100644 nisystemlink/clients/test_plan/test_plan_templates/models/_create_test_plan_templates.py create mode 100644 nisystemlink/clients/test_plan/test_plan_templates/models/_delete_test_plan_templates.py create mode 100644 nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates.py create mode 100644 nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py rename tests/{ => integration}/test_plan/__init__.py (100%) rename tests/{ => integration}/test_plan/test_plan_templates/__init__.py (100%) create mode 100644 tests/integration/test_plan/test_plan_templates/test__create_test_plan_template.py diff --git a/nisystemlink/clients/test_plan/models/_execution_definition.py b/nisystemlink/clients/test_plan/models/_execution_definition.py index 853c453f..2303c553 100644 --- a/nisystemlink/clients/test_plan/models/_execution_definition.py +++ b/nisystemlink/clients/test_plan/models/_execution_definition.py @@ -1,14 +1,14 @@ -from typing import Union +from typing import List, Union from nisystemlink.clients.core._uplink._json_model import JsonModel class Job(JsonModel): """ Represents a job to be executed, including its functions, arguments, and metadata. """ - functions: list[str] + functions: List[str] """List of function names to execute""" - arguments: list[list[object]] + arguments: List[List[object]] """List of argument lists for each function""" metadata: dict[str, object] @@ -48,7 +48,7 @@ class JobExecutionDefinition(JsonModel): type: str = 'JOB' """Type of execution, default is 'JOB'""" - jobs: list[Job] + jobs: List[Job] """List of jobs to execute""" systemId: str | None = None diff --git a/nisystemlink/clients/test_plan/test_plan_templates/__init__.py b/nisystemlink/clients/test_plan/test_plan_templates/__init__.py index e69de29b..52c379b0 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/__init__.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/__init__.py @@ -0,0 +1 @@ +from nisystemlink.clients.test_plan.test_plan_templates._test_plan_templates_client import TestPlanTemplateClient \ No newline at end of file diff --git a/nisystemlink/clients/test_plan/test_plan_templates/_test_plan_templates_client.py b/nisystemlink/clients/test_plan/test_plan_templates/_test_plan_templates_client.py new file mode 100644 index 00000000..d385bb01 --- /dev/null +++ b/nisystemlink/clients/test_plan/test_plan_templates/_test_plan_templates_client.py @@ -0,0 +1,62 @@ +"""Implementation of Test plan template Client""" + +from typing import List, Optional + +from uplink import Field, retry + +from nisystemlink.clients import core +from nisystemlink.clients.core._uplink._base_client import BaseClient +from nisystemlink.clients.core._uplink._methods import post + +from . import models + +@retry( + when=retry.when.status(408, 429, 502, 503, 504), + stop=retry.stop.after_attempt(5), + on_exception=retry.CONNECTION_ERROR, +) +class TestPlanTemplateClient(BaseClient): + def __init__(self, configuration: Optional[core.HttpConfiguration] = None): + """Initialize an instance. + + Args: + configuration: Defines the web server to connect to and information about + how to connect. If not provided, the + :class:`HttpConfigurationManager ` + is used to obtain the configuration. + + Raises: + ApiException: if unable to communicate with the Workorder Service. + """ + if configuration is None: + configuration = core.HttpConfigurationManager.get_configuration() + super().__init__(configuration, base_path="/niworkorder/v1/") + + @post("testplan-templates", args=[Field("testPlanTemplates")]) + def create_testPlanTemplates( + self, testPlanTemplates: List[models.CreateTestPlanTemplate] + ) -> models.CreateTestPlanTemplateResponse: + """Creates one or more test plan template and return errors for failed creations. + + Args: + products: A list of test plan templates to attempt to create. + + Returns: A list of created test plan templates, test plan templates that failed to create, and errors for + failures. + + Raises: ApiException: if unable to communicate with the ``/niworkorder`` service of provided invalid + arguments. + """ + ... + + @post("query-testplan-templates") + def query_test_plan_templates( + self, queryTestPlanTemplates: models.QueryTestPlanTemplatesRequestBody + ) -> models.QueryTestPlanTemplatesResponse: + ... + + @post("delete-testplan-templates") + def delete_test_plan_templates( + self, Ids: models.DeleteTestPlanTemplates + ) -> Optional[models.DeleteTestPlanTemplatesResponseSuccess]: + ... \ No newline at end of file diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py b/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py index e69de29b..ec6e8af1 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py @@ -0,0 +1,4 @@ +from nisystemlink.clients.test_plan.test_plan_templates.models._create_test_plan_templates import CreateTestPlanTemplate, CreateTestPlanTemplateResponse +from nisystemlink.clients.test_plan.test_plan_templates.models._query_test_plan_templates import QueryTestPlanTemplatesRequestBody, QueryTestPlanTemplatesResponse +from nisystemlink.clients.test_plan.test_plan_templates.models._delete_test_plan_templates import DeleteTestPlanTemplates, DeleteTestPlanTemplatesResponseSuccess +# flake8: noqa \ No newline at end of file diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_create_test_plan_templates.py b/nisystemlink/clients/test_plan/test_plan_templates/models/_create_test_plan_templates.py new file mode 100644 index 00000000..05445226 --- /dev/null +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/_create_test_plan_templates.py @@ -0,0 +1,21 @@ + + +from typing import List, Optional +from nisystemlink.clients.core._api_error import ApiError +from nisystemlink.clients.core._uplink._json_model import JsonModel +from ._test_plan_templates import TestPlanTemplateBase, TestPlanTemplateResponse + + +class CreateTestPlanTemplate(JsonModel): + """Creates one or more test plan templates with the provided data.""" + + testPlanTemplates: List[TestPlanTemplateBase] + """List of test plan templates to create.""" + +class CreateTestPlanTemplateResponse(JsonModel): + + createdTestPlanTemplates: Optional[List[TestPlanTemplateResponse]] = None + + failedTestPlanTemplates: Optional[List[TestPlanTemplateResponse]] = None + + error: Optional[ApiError] = None \ No newline at end of file diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_delete_test_plan_templates.py b/nisystemlink/clients/test_plan/test_plan_templates/models/_delete_test_plan_templates.py new file mode 100644 index 00000000..60d307fd --- /dev/null +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/_delete_test_plan_templates.py @@ -0,0 +1,14 @@ +from typing import List, Optional +from nisystemlink.clients.core._api_error import ApiError +from nisystemlink.clients.core._uplink._json_model import JsonModel + +class DeleteTestPlanTemplates(JsonModel): + """Deletes one or more test plan templates identified by their IDs.""" + + ids: List[str] + """ List of test plan template IDs to delete """ + +class DeleteTestPlanTemplatesResponseSuccess(JsonModel): + deletedTestPlanTemplateIds: List[str] + failedTestPlanTemplateIds: Optional[List[str]] = None + error: Optional[ApiError] = None \ No newline at end of file diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates.py b/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates.py new file mode 100644 index 00000000..560968ee --- /dev/null +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates.py @@ -0,0 +1,71 @@ +from enum import Enum +from typing import List, Optional + +from nisystemlink.clients.core._uplink._json_model import JsonModel +from ._test_plan_templates import TestPlanTemplateResponse + +class QueryTestPlanTemplateBase(JsonModel): + filter: Optional[str] = None + """The test plan template query filter in dynamic LINQ format. + + `id`: String representing the ID of a test plan template. Field supports only equals '=' and not equal '!=' operators for filtering. + `productFamilies`: Array of strings representing the product families to which the test plan template belongs. + `partNumbers`: Array of strings representing the part numbers of the products to which the test plan template belongs. + `fileIds`: The array of file IDs associated with the test plan template. + `name`: String representing the name of a test plan template. + `summary`: String representing the summary of a test plan template. + `description`: String representing description of the test plan created from this template. + `templateGroup`: String representing the template group defined by the user. + `testProgram`: String representing the test program name of the test plan created from this template. + `systemFilter`: String representing the LINQ filter used to filter the potential list of systems capable of executing test plans created from this template. + `workspace`: String representing the workspace where the test plan template belongs. + `createdBy`: String representing the user who created the test plan template. + `updatedBy`: String representing the user who updated the test plan template. + `createdAt`: ISO-8601 formatted timestamp indicating when the test plan template was created. + `updatedAt`: ISO-8601 formatted timestamp indicating when the test plan template was most recently updated. + `properties`: Collection of key-value pairs related to a test plan created from this template. Example: properties.Any(key == "Location" & value == "Austin") + + See [Dynamic Linq](https://github.com/ni/systemlink-OpenAPI-documents/wiki/Dynamic-Linq-Query-Language) + documentation for more details. + + `"@0"`, `"@1"` etc. can be used in conjunction with the `substitutions` parameter to keep this + query string more simple and reusable.""" + +class TestPlanTemplateOrderBy(str, Enum): + """An enumeration by which test plan templates can be ordered/sorted.""" + + ID = "ID" + NAME = "NAME" + TEMPLATE_GROUP = "TEMPLATE_GROUP" + CREATED_AT = "CREATED_AT" + UPDATED_AT ="UPDATED_AT" + +class QueryTestPlanTemplatesRequestBody(QueryTestPlanTemplateBase): + """Request information for the query test plan templates API.""" + + take: Optional[int] = None + """The maximum number of test plan templates to return.""" + orderBy: Optional[TestPlanTemplateOrderBy] = None + """Field by which test plan templates can be ordered/sorted.""" + descending: Optional[bool] = None + """Whether to return the test plan templates in the descending order. By default, test plan templates are sorted in the ascending order.""" + continuationToken: Optional[str] = None + """Allows users to continue the query at the next test plan templates that matches the given criteria. + + To retrieve the next page of test plan templates, pass the continuation token from the previous + page in the next request. The service responds with the next page of data and provides a new + continuation token. To paginate results, continue sending requests with the newest continuation + token provided in each response.""" + +class QueryTestPlanTemplatesResponse(JsonModel): + """Response information for the query test plan templates API.""" + + testPlanTemplates: List[TestPlanTemplateResponse] + """Queried test plan templates.""" + continuationToken: Optional[str] = None + """Allows users to continue the query at the next test plan templates that matches the given criteria. + + To retrieve the next page of test plan templates, pass the continuation token from the previous + page in the next request. The service responds with the next page of data and provides a new + continuation token. To paginate results, continue sending requests with the newest continuation + token provided in each response.""" \ No newline at end of file diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py b/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py new file mode 100644 index 00000000..1cca2d8e --- /dev/null +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py @@ -0,0 +1,32 @@ +from typing import Dict, List, Optional +from nisystemlink.clients.core._uplink._json_model import JsonModel +from nisystemlink.clients.test_plan.models._execution_definition import ExecutionDefinition + +class DashboardReference(JsonModel): + id: Optional[str] = None + variables: Dict[str, str] + +class Dashboard(JsonModel): + id: Optional[str] = None + variables: Dict[str, str] + +class TestPlanTemplateBase(JsonModel): + name: str + templateGroup: str = None + summary: Optional[str] = None + productFamilies: Optional[List[str]] = None + partNumbers: Optional[List[str]] = None + description: Optional[str] = None + testProgram: Optional[str] = None + systemFilter: Optional[str] = None + estimatedDurationInSeconds: Optional[int] = None + workspace: Optional[str] = None + properties: Optional[Dict[str, str]] = None + fileIds: Optional[List[str]] = None + dashboardReference: Optional[DashboardReference] = None + dashboard: Optional[Dashboard] = None + executionActions: Optional[List[ExecutionDefinition]] = None + +class TestPlanTemplateResponse(TestPlanTemplateBase): + id: Optional[str] = None + name: Optional[str] = None \ No newline at end of file diff --git a/tests/test_plan/__init__.py b/tests/integration/test_plan/__init__.py similarity index 100% rename from tests/test_plan/__init__.py rename to tests/integration/test_plan/__init__.py diff --git a/tests/test_plan/test_plan_templates/__init__.py b/tests/integration/test_plan/test_plan_templates/__init__.py similarity index 100% rename from tests/test_plan/test_plan_templates/__init__.py rename to tests/integration/test_plan/test_plan_templates/__init__.py diff --git a/tests/integration/test_plan/test_plan_templates/test__create_test_plan_template.py b/tests/integration/test_plan/test_plan_templates/test__create_test_plan_template.py new file mode 100644 index 00000000..3f4fb671 --- /dev/null +++ b/tests/integration/test_plan/test_plan_templates/test__create_test_plan_template.py @@ -0,0 +1,78 @@ + +import json +from typing import List +import pytest + +from nisystemlink.clients.core._http_configuration import HttpConfiguration +from nisystemlink.clients.test_plan.models._execution_definition import ManualExecutionDefinition +from nisystemlink.clients.test_plan.test_plan_templates._test_plan_templates_client import TestPlanTemplateClient +from nisystemlink.clients.test_plan.test_plan_templates.models._create_test_plan_templates import CreateTestPlanTemplateResponse +from nisystemlink.clients.test_plan.test_plan_templates.models._delete_test_plan_templates import DeleteTestPlanTemplates, DeleteTestPlanTemplatesResponseSuccess +from nisystemlink.clients.test_plan.test_plan_templates.models._query_test_plan_templates import QueryTestPlanTemplatesRequestBody, QueryTestPlanTemplatesResponse +from nisystemlink.clients.test_plan.test_plan_templates.models._test_plan_templates import TestPlanTemplateBase + + +@pytest.fixture(scope="class") +def create_test_plan_template() -> List[TestPlanTemplateBase]: + """Fixture to create test plan """ + + testPlanTemplates = [ + TestPlanTemplateBase( + name = "Sample testplan template", + templateGroup = "sample template group", + workspace = "33eba2fe-fe42-48a1-a47f-a6669479a8aa", + executionActions=[ + ManualExecutionDefinition( + action="TEST", + type="MANUAl" + ) + ] + ) + ] + + return testPlanTemplates + +@pytest.fixture(scope="class") +def client(enterprise_config: HttpConfiguration) -> TestPlanTemplateClient: + """Fixture to create a TestPlanTemplateClient instance""" + return TestPlanTemplateClient(enterprise_config) + +@pytest.mark.integration +@pytest.mark.enterprise +class TestTestPlanTemplate: + + def test__create_test_plan_template__returns_created_test_plan_template( + self, client: TestPlanTemplateClient, create_test_plan_template: List[TestPlanTemplateBase] + ): + create_response: CreateTestPlanTemplateResponse = client.create_testPlanTemplates( + testPlanTemplates=create_test_plan_template + ) + + template_id = ( + create_response.createdTestPlanTemplates[0].id + if create_response.createdTestPlanTemplates and create_response.createdTestPlanTemplates[0].id + else None + ) + + template_name = ( + create_response.createdTestPlanTemplates[0].name + if create_response.createdTestPlanTemplates and create_response.createdTestPlanTemplates[0].name + else None + ) + + assert template_id is not None + + delete_response: DeleteTestPlanTemplatesResponseSuccess = client.delete_test_plan_templates( + Ids=DeleteTestPlanTemplates( + ids=[template_id] + ) + ) + + query_deleted_test_plan_template_response: QueryTestPlanTemplatesResponse = client.query_test_plan_templates( + queryTestPlanTemplates=QueryTestPlanTemplatesRequestBody( + filter=f'id="{template_id}"', + take=1 + ) + ) + + assert len(query_deleted_test_plan_template_response.testPlanTemplates) == 0, query_deleted_test_plan_template_response \ No newline at end of file From db0d53aea8cd88444a769a50d0f2fd7ca22f0f72 Mon Sep 17 00:00:00 2001 From: Ammar Husain Mian Fazulul Date: Sat, 17 May 2025 00:14:17 +0530 Subject: [PATCH 12/64] moved test plan to integration folder --- tests/{ => integration}/test_plan/__init__.py | 0 tests/{ => integration}/test_plan/test_plan_templates/__init__.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename tests/{ => integration}/test_plan/__init__.py (100%) rename tests/{ => integration}/test_plan/test_plan_templates/__init__.py (100%) diff --git a/tests/test_plan/__init__.py b/tests/integration/test_plan/__init__.py similarity index 100% rename from tests/test_plan/__init__.py rename to tests/integration/test_plan/__init__.py diff --git a/tests/test_plan/test_plan_templates/__init__.py b/tests/integration/test_plan/test_plan_templates/__init__.py similarity index 100% rename from tests/test_plan/test_plan_templates/__init__.py rename to tests/integration/test_plan/test_plan_templates/__init__.py From 5e2699edb0095ddfd911c1a6b77e3b0782a97c9b Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Sat, 17 May 2025 00:58:24 +0530 Subject: [PATCH 13/64] lint --- .../clients/test_plan/models/__init__.py | 2 +- .../test_plan/models/_execution_definition.py | 33 +++++++++++++------ .../clients/test_plan/test_plans/__init__.py | 2 +- .../test_plans/_test_plans_client.py | 17 +++++++--- .../test_plan/test_plans/models/__init__.py | 8 +++-- .../test_plans/models/_create_test_plans.py | 4 +++ .../test_plans/models/_delete_test_plans.py | 2 ++ .../test_plans/models/_execution_event.py | 14 ++++---- .../test_plans/models/_query_test_plans.py | 2 ++ .../test_plans/models/_schedule_test_plans.py | 3 ++ .../test_plan/test_plans/models/_state.py | 17 +++++----- .../test_plan/test_plans/models/_test_plan.py | 3 +- .../test_plans/models/_update_test_plans.py | 1 + .../test_plans/models/_workflow_definition.py | 5 +++ .../test_plan/test_plans/__init__.py | 2 +- .../test_plan/test_plans/test_test_plans.py | 20 +++++------ 16 files changed, 90 insertions(+), 45 deletions(-) diff --git a/nisystemlink/clients/test_plan/models/__init__.py b/nisystemlink/clients/test_plan/models/__init__.py index a67830a7..317b563f 100644 --- a/nisystemlink/clients/test_plan/models/__init__.py +++ b/nisystemlink/clients/test_plan/models/__init__.py @@ -1 +1 @@ -from ._execution_definition import ExecutionDefinition \ No newline at end of file +from ._execution_definition import ExecutionDefinition diff --git a/nisystemlink/clients/test_plan/models/_execution_definition.py b/nisystemlink/clients/test_plan/models/_execution_definition.py index 853c453f..84239902 100644 --- a/nisystemlink/clients/test_plan/models/_execution_definition.py +++ b/nisystemlink/clients/test_plan/models/_execution_definition.py @@ -1,10 +1,13 @@ -from typing import Union +from typing import Union, Optional from nisystemlink.clients.core._uplink._json_model import JsonModel + + class Job(JsonModel): """ Represents a job to be executed, including its functions, arguments, and metadata. """ + functions: list[str] """List of function names to execute""" @@ -14,14 +17,16 @@ class Job(JsonModel): metadata: dict[str, object] """Additional metadata for the job""" + class NotebookExecutionDefinition(JsonModel): """ Defines the execution of a notebook. """ + action: str """User defined action to perform in workflow (user defined)""" - type: str = 'NOTEBOOK' + type: str = "NOTEBOOK" """Type of execution, default is 'NOTEBOOK'""" notebookId: str @@ -32,26 +37,29 @@ class ManualExecutionDefinition(JsonModel): """ Represents a manual execution definition. """ + action: str """User defined action to perform in workflow (user defined)""" - type: str = 'MANUAL' + type: str = "MANUAL" """Type of execution, default is 'MANUAL'""" + class JobExecutionDefinition(JsonModel): """ Defines the execution of one or more jobs. """ + action: str """User defined action to perform in workflow (user defined)""" - type: str = 'JOB' + type: str = "JOB" """Type of execution, default is 'JOB'""" jobs: list[Job] """List of jobs to execute""" - systemId: str | None = None + systemId: Optional[str] = None """Optional system ID where jobs will run""" @@ -59,10 +67,11 @@ class ScheduleExecutionDefinition(JsonModel): """ Represents a scheduled execution definition. """ + action: str """User defined action to perform in workflow (user defined)""" - type: str = 'SCHEDULE' + type: str = "SCHEDULE" """Type of execution, default is 'SCHEDULE'""" @@ -70,27 +79,31 @@ class UnscheduleExecutionDefinition(JsonModel): """ Represents an unscheduled execution definition. """ + action: str """User defined action to perform in workflow (user defined)""" - type: str = 'UNSCHEDULE' + type: Optional[str] = "UNSCHEDULE" """Type of execution, default is 'UNSCHEDULE'""" + class NoneExecutionDefinition(JsonModel): """ Represents a definition where no execution is specified. """ + action: str """User defined action to perform in workflow (user defined)""" - type: str = 'None' + type: Optional[str] = "None" """Type of execution, default is 'None'""" + ExecutionDefinition = Union[ NotebookExecutionDefinition, ManualExecutionDefinition, JobExecutionDefinition, NoneExecutionDefinition, ScheduleExecutionDefinition, - UnscheduleExecutionDefinition -] \ No newline at end of file + UnscheduleExecutionDefinition, +] diff --git a/nisystemlink/clients/test_plan/test_plans/__init__.py b/nisystemlink/clients/test_plan/test_plans/__init__.py index b1e7f049..fe33d7d0 100644 --- a/nisystemlink/clients/test_plan/test_plans/__init__.py +++ b/nisystemlink/clients/test_plan/test_plans/__init__.py @@ -1,3 +1,3 @@ from ._test_plans_client import TestPlansClient -# flake8: noqa \ No newline at end of file +# flake8: noqa diff --git a/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py b/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py index 8e47db06..3640560d 100644 --- a/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py +++ b/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py @@ -15,9 +15,10 @@ UpdateTestPlansRequest, UpdateTestPlansResponse, DeleteTestPlansResponse, - DeleteTestPlansRequest + DeleteTestPlansRequest, ) + class TestPlansClient(BaseClient): def __init__(self, configuration: Optional[HttpConfiguration] = None): """Initialize an instance. @@ -48,8 +49,10 @@ def get_test_plan(self, test_plan_id) -> TestPlan: """ ... - @post("testplans", args=[Field("testplans")]) - def create_test_plans(self, testplans: CreateTestPlansRequest) -> CreateTestPlansResponse: + @post("testplans") + def create_test_plans( + self, testplans: CreateTestPlansRequest + ) -> CreateTestPlansResponse: """Create a new test plan. Args: @@ -85,7 +88,9 @@ def query_test_plans(self, query: QueryTestPlansRequest) -> QueryTestPlansRespon ... @post("schedule-testplans", args=[Field("schedule")]) - def schedule_test_plan(self, schedule: ScheduleTestPlansRequest) -> ScheduleTestPlansResponse: + def schedule_test_plan( + self, schedule: ScheduleTestPlansRequest + ) -> ScheduleTestPlansResponse: """Schedule a test plan. Args: @@ -97,7 +102,9 @@ def schedule_test_plan(self, schedule: ScheduleTestPlansRequest) -> ScheduleTest ... @post("update-testplans", args=[Field("test_plans")]) - def update_test_plan(self, test_plans: UpdateTestPlansRequest) -> UpdateTestPlansResponse: + def update_test_plan( + self, test_plans: UpdateTestPlansRequest + ) -> UpdateTestPlansResponse: """Update a test plan. Args: diff --git a/nisystemlink/clients/test_plan/test_plans/models/__init__.py b/nisystemlink/clients/test_plan/test_plans/models/__init__.py index 7063554a..3f9eaee4 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/__init__.py +++ b/nisystemlink/clients/test_plan/test_plans/models/__init__.py @@ -1,4 +1,8 @@ -from ._create_test_plans import CreateTestPlansRequest, CreateTestPlanRequestBodyContent, CreateTestPlansResponse +from ._create_test_plans import ( + CreateTestPlansRequest, + CreateTestPlanRequestBodyContent, + CreateTestPlansResponse, +) from ._delete_test_plans import DeleteTestPlansRequest, DeleteTestPlansResponse from ._execution_event import ExecutionEvent from ._query_test_plans import QueryTestPlansRequest, QueryTestPlansResponse @@ -8,4 +12,4 @@ from ._update_test_plans import UpdateTestPlansRequest, UpdateTestPlansResponse from ._workflow_definition import WorkflowDefinition -# flake8: noqa \ No newline at end of file +# flake8: noqa diff --git a/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans.py b/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans.py index 3a13a54a..763a2881 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans.py @@ -5,6 +5,7 @@ from ...models._execution_definition import ExecutionDefinition from ._test_plan import TestPlan + class Dashboard(JsonModel): """Represents a dashboard reference.""" @@ -14,6 +15,7 @@ class Dashboard(JsonModel): variables: Optional[Dict[str, str]] = None """Variables for the dashboard""" + class CreateTestPlanRequestBodyContent(JsonModel): """Represents the request body content for creating a test plan.""" @@ -65,6 +67,7 @@ class CreateTestPlanRequestBodyContent(JsonModel): executionActions: Optional[List[ExecutionDefinition]] = None """List of execution actions for the test plan.""" + class CreateTestPlansRequest(JsonModel): """Represents the request body for creating multiple test plans.""" @@ -74,6 +77,7 @@ class CreateTestPlansRequest(JsonModel): the content required to create an individual test plan. """ + class CreateTestPlansResponse(JsonModel): """ Represents the response from creating test plans, including successfully created, diff --git a/nisystemlink/clients/test_plan/test_plans/models/_delete_test_plans.py b/nisystemlink/clients/test_plan/test_plans/models/_delete_test_plans.py index d3bf8c05..80e8cf04 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_delete_test_plans.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_delete_test_plans.py @@ -2,12 +2,14 @@ from nisystemlink.clients.core import ApiError + class DeleteTestPlansRequest: """Represents a request to delete one or more test plans.""" ids: List[str] """List of test plan IDS of test plans to be deleted""" + class DeleteTestPlansResponse: """Response fields for delete test plans operation.""" diff --git a/nisystemlink/clients/test_plan/test_plans/models/_execution_event.py b/nisystemlink/clients/test_plan/test_plans/models/_execution_event.py index 2b332710..95c21e0b 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_execution_event.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_execution_event.py @@ -1,4 +1,5 @@ -from typing import List, Literal, Union +from typing import List, Union, Optional + from nisystemlink.clients.core._uplink._json_model import JsonModel class ExecutionEventBase(JsonModel): @@ -13,23 +14,24 @@ class ExecutionEventBase(JsonModel): class NotebookExecutionEvent(ExecutionEventBase): - type: str = 'NOTEBOOK' + type: Optional[str] = "NOTEBOOK" """Represents an execution event triggered by a notebook.""" - executionId: str + executionId: Optional[str] = None """Includes the type identifier and the execution ID.""" class JobExecutionEvent(ExecutionEventBase): - type: str = 'JOB' + type: Optional[str] = "JOB" """Represents an execution event triggered by a job.""" - jobIds: List[str] + jobIds: Optional[List[str]] """Includes the type identifier and a list of job IDs.""" class ManualExecutionEvent(ExecutionEventBase): - type: str = 'MANUAL' + type: Optional[str] = "MANUAL" """Represents an execution event triggered manually. Includes only the type identifier.""" + ExecutionEvent = Union[NotebookExecutionEvent, ManualExecutionEvent, JobExecutionEvent] diff --git a/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans.py b/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans.py index a0a2df5d..d29184b9 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans.py @@ -3,6 +3,7 @@ from nisystemlink.clients.core._uplink._json_model import JsonModel from ._test_plan import TestPlan + class QueryTestPlansRequest(JsonModel): """ Represents the request body for querying test plans. @@ -27,6 +28,7 @@ class QueryTestPlansRequest(JsonModel): continuation_token: Optional[str] = None """A token to retrieve the next page of results for paginated queries.""" + class QueryTestPlansResponse(JsonModel): """ Represents the response from querying test plans. diff --git a/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans.py b/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans.py index 17f4b8f6..9addf052 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans.py @@ -4,6 +4,7 @@ from nisystemlink.clients.core._uplink._json_model import JsonModel from ._test_plan import TestPlan + class ScheduleTestPlanRequestBodyContent(JsonModel): """Represents the request body content for scheduling a test plan.""" @@ -31,6 +32,7 @@ class ScheduleTestPlanRequestBodyContent(JsonModel): fixture_ids: Optional[List[str]] = None """(Optional) List of fixture identifiers associated with the test plan.""" + class ScheduleTestPlansRequest(JsonModel): """Represents the request body for scheduling multiple test plans.""" @@ -40,6 +42,7 @@ class ScheduleTestPlansRequest(JsonModel): replace: Optional[bool] = None """(Optional) If true, replaces existing scheduled test plans.""" + class ScheduleTestPlansResponse(JsonModel): """Represents the response returned after attempting to schedule one or more test plans.""" diff --git a/nisystemlink/clients/test_plan/test_plans/models/_state.py b/nisystemlink/clients/test_plan/test_plans/models/_state.py index 63f7d2a6..ecc6f03d 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_state.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_state.py @@ -1,13 +1,14 @@ from enum import Enum + class State(Enum): """The state of the test plan.""" - New = 'NEW' - Defined = 'DEFINED' - Reviewed = 'REVIEWED' - Scheduled = 'SCHEDULED' - InProgress = 'IN_PROGRESS' - PendingApproval = 'PENDING_APPROVAL' - Closed = 'CLOSED' - Canceled = 'CANCELED' + New = "NEW" + Defined = "DEFINED" + Reviewed = "REVIEWED" + Scheduled = "SCHEDULED" + InProgress = "IN_PROGRESS" + PendingApproval = "PENDING_APPROVAL" + Closed = "CLOSED" + Canceled = "CANCELED" diff --git a/nisystemlink/clients/test_plan/test_plans/models/_test_plan.py b/nisystemlink/clients/test_plan/test_plans/models/_test_plan.py index 8b8f70a7..b36f2845 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_test_plan.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_test_plan.py @@ -6,6 +6,7 @@ from ._execution_event import ExecutionEvent from ...models._execution_definition import ExecutionDefinition + class TestPlan(JsonModel): """Contains information about a test plan.""" @@ -14,7 +15,7 @@ class TestPlan(JsonModel): templateId: Optional[str] = None """The identifier of the template used to create the test plan.""" - + name: str """The name of the test plan.""" diff --git a/nisystemlink/clients/test_plan/test_plans/models/_update_test_plans.py b/nisystemlink/clients/test_plan/test_plans/models/_update_test_plans.py index b095b774..d0ba9a92 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_update_test_plans.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_update_test_plans.py @@ -4,6 +4,7 @@ from nisystemlink.clients.core import ApiError from . import TestPlan + class UpdateTestPlanRequestBodyContent(JsonModel): """Represents the content for updating a single test plan.""" diff --git a/nisystemlink/clients/test_plan/test_plans/models/_workflow_definition.py b/nisystemlink/clients/test_plan/test_plans/models/_workflow_definition.py index cbae1635..0e081b0d 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_workflow_definition.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_workflow_definition.py @@ -2,6 +2,7 @@ from ._state import State from ...models._execution_definition import ExecutionDefinition + class ActionTransitionDefinition(JsonModel): """Represents a transition between workflow states triggered by a specific action.""" @@ -17,6 +18,7 @@ class ActionTransitionDefinition(JsonModel): showInUI: bool """Indicates whether this transition should be visible in the user interface.""" + class SubstateDefinition(JsonModel): """Represents a substate within a workflow definition.""" @@ -29,6 +31,7 @@ class SubstateDefinition(JsonModel): availableActions: list[ActionTransitionDefinition] """List of actions that can be performed from this substate.""" + class StateDefinition(JsonModel): """Represents the definition of a workflow state within a test plan.""" @@ -44,6 +47,7 @@ class StateDefinition(JsonModel): substates: list[SubstateDefinition] """A list of substates defined for this state.""" + class ActionDefinition(JsonModel): """Represents the definition of an action within a workflow.""" @@ -56,6 +60,7 @@ class ActionDefinition(JsonModel): executionAction: ExecutionDefinition """The execution details associated with the action.""" + class WorkflowDefinition(JsonModel): """Contains information about a workflow definition.""" diff --git a/tests/integration/test_plan/test_plans/__init__.py b/tests/integration/test_plan/test_plans/__init__.py index a517c684..9c0fa90a 100644 --- a/tests/integration/test_plan/test_plans/__init__.py +++ b/tests/integration/test_plan/test_plans/__init__.py @@ -1 +1 @@ -# flake8: noqa \ No newline at end of file +# flake8: noqa diff --git a/tests/integration/test_plan/test_plans/test_test_plans.py b/tests/integration/test_plan/test_plans/test_test_plans.py index 20831290..fb2f48ed 100644 --- a/tests/integration/test_plan/test_plans/test_test_plans.py +++ b/tests/integration/test_plan/test_plans/test_test_plans.py @@ -10,6 +10,7 @@ TestPlan ) + @pytest.fixture(scope="class") def test_plan_create() -> CreateTestPlansRequest: """Fixture to create create test plan object.""" @@ -17,15 +18,14 @@ def test_plan_create() -> CreateTestPlansRequest: testPlan = CreateTestPlansRequest( testPlans=[ CreateTestPlanRequestBodyContent( - name="Sample Test Plan", - state="NEW", - partNumber="px40482" + name="Sample Test Plan", state="NEW", partNumber="px40482" ) ] ) return testPlan + @pytest.fixture(scope="class") def client(enterprise_config: HttpConfiguration) -> TestPlansClient: """Fixture to create a TestPlansClient instance""" @@ -36,23 +36,23 @@ def client(enterprise_config: HttpConfiguration) -> TestPlansClient: @pytest.mark.enterprise class TestTestPlans: - def test__get_test_plan__returns_get_test_plan( - self, client: TestPlansClient - ): - get_test_plan_response: TestPlan = client.get_test_plan("1567158") + def test__get_test_plan__returns_get_test_plan(self, client: TestPlansClient): + get_test_plan_response: TestPlan = client.get_test_plan("1568982") assert get_test_plan_response is not None assert isinstance(get_test_plan_response, TestPlan) - assert get_test_plan_response.id == "1567158" + assert get_test_plan_response.id == "1568982" def test__create_test_plan__returns_created_test_plans( - self, client: TestPlansClient, test_plan_create: CreateTestPlansRequest + self, client: TestPlansClient, test_plan_create: CreateTestPlansRequest ): test_plan_create_response: CreateTestPlansResponse = client.create_test_plans( testplans=test_plan_create ) - client.delete_test_plans(test_plan_ids=[test_plan_create_response.createdTestPlans[0].id]) + client.delete_test_plans( + test_plan_ids=[test_plan_create_response.createdTestPlans[0].id] + ) assert test_plan_create_response is not None assert len(test_plan_create_response.testPlans) == 1 From a08df7dee8aba324aeac7e8c24ce918fd3cfda0f Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Sat, 17 May 2025 02:11:49 +0530 Subject: [PATCH 14/64] add tests --- .../test_plans/_test_plans_client.py | 6 +- .../test_plan/test_plans/models/__init__.py | 4 +- .../test_plans/models/_delete_test_plans.py | 4 +- .../test_plan/test_plans/models/_test_plan.py | 4 +- .../test_plan/test_plans/test_test_plans.py | 114 +++++++++++++++--- 5 files changed, 109 insertions(+), 23 deletions(-) diff --git a/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py b/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py index 3640560d..294fe4e6 100644 --- a/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py +++ b/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py @@ -63,7 +63,7 @@ def create_test_plans( """ ... - @post("delete-testplans", args=[Field("ids")]) + @post("delete-testplans") def delete_test_plans(self, ids: DeleteTestPlansRequest) -> DeleteTestPlansResponse: """Delete test plans by IDs. @@ -87,7 +87,7 @@ def query_test_plans(self, query: QueryTestPlansRequest) -> QueryTestPlansRespon """ ... - @post("schedule-testplans", args=[Field("schedule")]) + @post("schedule-testplans") def schedule_test_plan( self, schedule: ScheduleTestPlansRequest ) -> ScheduleTestPlansResponse: @@ -101,7 +101,7 @@ def schedule_test_plan( """ ... - @post("update-testplans", args=[Field("test_plans")]) + @post("update-testplans") def update_test_plan( self, test_plans: UpdateTestPlansRequest ) -> UpdateTestPlansResponse: diff --git a/nisystemlink/clients/test_plan/test_plans/models/__init__.py b/nisystemlink/clients/test_plan/test_plans/models/__init__.py index 3f9eaee4..1afb2b22 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/__init__.py +++ b/nisystemlink/clients/test_plan/test_plans/models/__init__.py @@ -6,10 +6,10 @@ from ._delete_test_plans import DeleteTestPlansRequest, DeleteTestPlansResponse from ._execution_event import ExecutionEvent from ._query_test_plans import QueryTestPlansRequest, QueryTestPlansResponse -from ._schedule_test_plans import ScheduleTestPlansRequest, ScheduleTestPlansResponse +from ._schedule_test_plans import ScheduleTestPlansRequest, ScheduleTestPlansResponse, ScheduleTestPlanRequestBodyContent from ._state import State from ._test_plan import TestPlan -from ._update_test_plans import UpdateTestPlansRequest, UpdateTestPlansResponse +from ._update_test_plans import UpdateTestPlansRequest, UpdateTestPlansResponse, UpdateTestPlanRequestBodyContent from ._workflow_definition import WorkflowDefinition # flake8: noqa diff --git a/nisystemlink/clients/test_plan/test_plans/models/_delete_test_plans.py b/nisystemlink/clients/test_plan/test_plans/models/_delete_test_plans.py index 80e8cf04..b6cc0f83 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_delete_test_plans.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_delete_test_plans.py @@ -1,9 +1,11 @@ from typing import List, Optional +from nisystemlink.clients.core._uplink._json_model import JsonModel + from nisystemlink.clients.core import ApiError -class DeleteTestPlansRequest: +class DeleteTestPlansRequest(JsonModel): """Represents a request to delete one or more test plans.""" ids: List[str] diff --git a/nisystemlink/clients/test_plan/test_plans/models/_test_plan.py b/nisystemlink/clients/test_plan/test_plans/models/_test_plan.py index b36f2845..79e95872 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_test_plan.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_test_plan.py @@ -85,10 +85,10 @@ class TestPlan(JsonModel): fileIdsFromTemplate: List[str] """The list of file identifiers inherited from the template.""" - executionActions: Optional[ExecutionDefinition] = None + # executionActions: Optional[ExecutionDefinition] = None """The execution actions defined for the test plan.""" - executionHistory: Optional[ExecutionEvent] = None + # executionHistory: Optional[ExecutionEvent] = None """The execution history of the test plan.""" dashboardUrl: Optional[Dict[str, str]] = None diff --git a/tests/integration/test_plan/test_plans/test_test_plans.py b/tests/integration/test_plan/test_plans/test_test_plans.py index fb2f48ed..b20850ef 100644 --- a/tests/integration/test_plan/test_plans/test_test_plans.py +++ b/tests/integration/test_plan/test_plans/test_test_plans.py @@ -7,7 +7,16 @@ CreateTestPlanRequestBodyContent, CreateTestPlansRequest, CreateTestPlansResponse, - TestPlan + DeleteTestPlansRequest, + State, + TestPlan, + UpdateTestPlansRequest, + UpdateTestPlanRequestBodyContent, + ScheduleTestPlansRequest, + ScheduleTestPlansResponse, + ScheduleTestPlanRequestBodyContent, + QueryTestPlansRequest, + QueryTestPlansResponse ) @@ -35,28 +44,103 @@ def client(enterprise_config: HttpConfiguration) -> TestPlansClient: @pytest.mark.integration @pytest.mark.enterprise class TestTestPlans: + def test__create_and_delete_test_plan__returns_created_and_deleted_test_plans( + self, client: TestPlansClient, test_plan_create: CreateTestPlansRequest + ): + create_test_plan_response: CreateTestPlansResponse = client.create_test_plans(testplans=test_plan_create) + created_test_plan = create_test_plan_response.createdTestPlans[0] - def test__get_test_plan__returns_get_test_plan(self, client: TestPlansClient): - get_test_plan_response: TestPlan = client.get_test_plan("1568982") + delete_test_plan_request = DeleteTestPlansRequest(ids=[created_test_plan.id]) + delete_test_plan_response = client.delete_test_plans(ids=delete_test_plan_request) + + assert created_test_plan is not None + assert created_test_plan.name == "Sample Test Plan" + assert created_test_plan.state == State.New + assert created_test_plan.partNumber == "px40482" + assert created_test_plan.id == delete_test_plan_response.deletedTestPlanIds[0] + + def test__get_test_plan__returns_get_test_plan( + self, client: TestPlansClient, test_plan_create: CreateTestPlansRequest + ): + create_test_plan_response: CreateTestPlansResponse = client.create_test_plans(testplans=test_plan_create) + created_test_plan = create_test_plan_response.createdTestPlans[0] + + get_test_plan_response: TestPlan = client.get_test_plan(created_test_plan.id) + + delete_request = DeleteTestPlansRequest(ids=[create_test_plan_response.createdTestPlans[0].id]) + client.delete_test_plans(ids=delete_request) assert get_test_plan_response is not None assert isinstance(get_test_plan_response, TestPlan) - assert get_test_plan_response.id == "1568982" + assert get_test_plan_response.id == created_test_plan.id + + def test__update_test_plan__returns_updated_test_plan( + self, client: TestPlansClient, test_plan_create: CreateTestPlansRequest + ): + create_test_plan_response: CreateTestPlansResponse = client.create_test_plans(testplans=test_plan_create) + created_test_plan = create_test_plan_response.createdTestPlans[0] - def test__create_test_plan__returns_created_test_plans( + update_request = UpdateTestPlansRequest( + testPlans=[ + UpdateTestPlanRequestBodyContent( + id=created_test_plan.id, + name= "Updated Test Plan", + ) + ] + ) + update_test_plan_response = client.update_test_plan(test_plans=update_request) + + delete_request = DeleteTestPlansRequest(ids=[create_test_plan_response.createdTestPlans[0].id]) + client.delete_test_plans(ids=delete_request) + + assert update_test_plan_response is not None + updated_test_plan = update_test_plan_response.updated_test_plans[0] + assert updated_test_plan.id == created_test_plan.id + assert updated_test_plan.name == "Updated Test Plan" + + def test__schedule_test_plan__returns_scheduled_test_plan( self, client: TestPlansClient, test_plan_create: CreateTestPlansRequest ): - test_plan_create_response: CreateTestPlansResponse = client.create_test_plans( - testplans=test_plan_create + create_test_plan_response: CreateTestPlansResponse = client.create_test_plans(testplans=test_plan_create) + created_test_plan = create_test_plan_response.createdTestPlans[0] + + schedule_request = ScheduleTestPlansRequest( + test_plans=[ + ScheduleTestPlanRequestBodyContent( + id=created_test_plan.id, + planned_start_date_time="2025-05-20T15:07:42.527Z", + estimated_end_date_time="2025-05-20T15:07:42.527Z", + system_id="fake-system" + ) + ] ) + schedule_test_plan_response = client.schedule_test_plan(schedule=schedule_request) + + delete_request = DeleteTestPlansRequest(ids=[created_test_plan.id]) + client.delete_test_plans(ids=delete_request) + + assert schedule_test_plan_response is not None + scheduled_test_plan = schedule_test_plan_response.scheduled_test_plans[0] + assert scheduled_test_plan.id == created_test_plan.id + assert scheduled_test_plan.plannedStartDateTime == "2025-05-20T15:07:42.527Z" + assert scheduled_test_plan.systemId == "fake-system" - client.delete_test_plans( - test_plan_ids=[test_plan_create_response.createdTestPlans[0].id] + def test__query_test_plans__return_queried_test_plan( + self, client: TestPlansClient, test_plan_create: CreateTestPlansRequest + ): + create_test_plan_response: CreateTestPlansResponse = client.create_test_plans(testplans=test_plan_create) + created_test_plan = create_test_plan_response.createdTestPlans[0] + + query_test_plans_request = QueryTestPlansRequest( + filter = "id == {created_test_plan.id}", + return_count = True ) + queried_test_plans_response = client.query_test_plans(query = query_test_plans_request) - assert test_plan_create_response is not None - assert len(test_plan_create_response.testPlans) == 1 - created_test_plan = test_plan_create_response.testPlans[0] - assert created_test_plan.name == "Sample Test Plan" - assert created_test_plan.state == "NEW" - assert created_test_plan.partNumber == "px40482" + delete_request = DeleteTestPlansRequest(ids=[created_test_plan.id]) + client.delete_test_plans(ids=delete_request) + + assert queried_test_plans_response is not None + assert queried_test_plans_response.test_plans[0].id == created_test_plan.id + assert queried_test_plans_response.total_count > 0 + From 6100544d537bdcbfb918f87273e412a7e33a26ab Mon Sep 17 00:00:00 2001 From: Ammar Husain Mian Fazulul Date: Mon, 19 May 2025 10:23:21 +0530 Subject: [PATCH 15/64] added rest of test cases --- .../test__create_test_plan_template.py | 67 +++++++++++++++++-- 1 file changed, 60 insertions(+), 7 deletions(-) diff --git a/tests/integration/test_plan/test_plan_templates/test__create_test_plan_template.py b/tests/integration/test_plan/test_plan_templates/test__create_test_plan_template.py index 3f4fb671..17d2f856 100644 --- a/tests/integration/test_plan/test_plan_templates/test__create_test_plan_template.py +++ b/tests/integration/test_plan/test_plan_templates/test__create_test_plan_template.py @@ -1,5 +1,3 @@ - -import json from typing import List import pytest @@ -54,15 +52,70 @@ def test__create_test_plan_template__returns_created_test_plan_template( else None ) - template_name = ( - create_response.createdTestPlanTemplates[0].name - if create_response.createdTestPlanTemplates and create_response.createdTestPlanTemplates[0].name + assert template_id is not None + + client.delete_test_plan_templates( + Ids=DeleteTestPlanTemplates( + ids=[template_id] + ) + ) + + query_deleted_test_plan_template_response: QueryTestPlanTemplatesResponse = client.query_test_plan_templates( + queryTestPlanTemplates=QueryTestPlanTemplatesRequestBody( + filter=f'id="{template_id}"', + take=1 + ) + ) + + assert len(query_deleted_test_plan_template_response.testPlanTemplates) == 0 + + def test__query_test_plan_template__returns_queried_test_plan_template( + self, client: TestPlanTemplateClient, create_test_plan_template: List[TestPlanTemplateBase] + ): + create_response: CreateTestPlanTemplateResponse = client.create_testPlanTemplates( + testPlanTemplates=create_test_plan_template + ) + + template_id = ( + create_response.createdTestPlanTemplates[0].id + if create_response.createdTestPlanTemplates and create_response.createdTestPlanTemplates[0].id + else None + ) + + assert template_id is not None + + query_test_plan_template_response: QueryTestPlanTemplatesResponse = client.query_test_plan_templates( + queryTestPlanTemplates=QueryTestPlanTemplatesRequestBody( + filter=f'id="{template_id}"', + take=1 + ) + ) + + assert len(query_test_plan_template_response.testPlanTemplates) == 1 + assert query_test_plan_template_response.testPlanTemplates[0].name == create_test_plan_template[0].name + + client.delete_test_plan_templates( + Ids=DeleteTestPlanTemplates( + ids=[template_id] + ) + ) + + def test__delete_test_plan_template( + self, client: TestPlanTemplateClient, create_test_plan_template: List[TestPlanTemplateBase] + ): + create_response: CreateTestPlanTemplateResponse = client.create_testPlanTemplates( + testPlanTemplates=create_test_plan_template + ) + + template_id = ( + create_response.createdTestPlanTemplates[0].id + if create_response.createdTestPlanTemplates and create_response.createdTestPlanTemplates[0].id else None ) assert template_id is not None - delete_response: DeleteTestPlanTemplatesResponseSuccess = client.delete_test_plan_templates( + client.delete_test_plan_templates( Ids=DeleteTestPlanTemplates( ids=[template_id] ) @@ -75,4 +128,4 @@ def test__create_test_plan_template__returns_created_test_plan_template( ) ) - assert len(query_deleted_test_plan_template_response.testPlanTemplates) == 0, query_deleted_test_plan_template_response \ No newline at end of file + assert len(query_deleted_test_plan_template_response.testPlanTemplates) == 0 From 293d1850357041e112d0c7cf0bd9962817128f8c Mon Sep 17 00:00:00 2001 From: Ammar Husain Mian Fazulul Date: Mon, 19 May 2025 12:51:19 +0530 Subject: [PATCH 16/64] added documentation --- .../_test_plan_templates_client.py | 24 ++++++-- .../test_plan_templates/models/__init__.py | 2 +- .../models/_create_test_plan_templates.py | 11 +++- .../models/_delete_test_plan_templates.py | 11 +++- .../models/_query_test_plan_templates.py | 4 ++ .../models/_test_plan_templates.py | 57 +++++++++++++++---- .../test__create_test_plan_template.py | 4 +- 7 files changed, 93 insertions(+), 20 deletions(-) diff --git a/nisystemlink/clients/test_plan/test_plan_templates/_test_plan_templates_client.py b/nisystemlink/clients/test_plan/test_plan_templates/_test_plan_templates_client.py index d385bb01..8be3f429 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/_test_plan_templates_client.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/_test_plan_templates_client.py @@ -26,7 +26,7 @@ def __init__(self, configuration: Optional[core.HttpConfiguration] = None): is used to obtain the configuration. Raises: - ApiException: if unable to communicate with the Workorder Service. + ApiException: if unable to communicate with the `/niworkorder` Service. """ if configuration is None: configuration = core.HttpConfigurationManager.get_configuration() @@ -39,12 +39,12 @@ def create_testPlanTemplates( """Creates one or more test plan template and return errors for failed creations. Args: - products: A list of test plan templates to attempt to create. + testPlanTempaltes: A list of test plan templates to attempt to create. Returns: A list of created test plan templates, test plan templates that failed to create, and errors for failures. - Raises: ApiException: if unable to communicate with the ``/niworkorder`` service of provided invalid + Raises: ApiException: if unable to communicate with the `/niworkorder` service of provided invalid arguments. """ ... @@ -53,10 +53,26 @@ def create_testPlanTemplates( def query_test_plan_templates( self, queryTestPlanTemplates: models.QueryTestPlanTemplatesRequestBody ) -> models.QueryTestPlanTemplatesResponse: + """Queries one or more test plan templates and return errors for failed queries. + + Returns: A list of test plan templates, based on the query and errors for the wrong query. + + Raises: ApiException: if unable to communicate with the `/niworkorder` service of provided invalid + arguments. + """ ... @post("delete-testplan-templates") def delete_test_plan_templates( self, Ids: models.DeleteTestPlanTemplates - ) -> Optional[models.DeleteTestPlanTemplatesResponseSuccess]: + ) -> Optional[models.DeleteTestPlanTemplatesPartialSuccess]: + """Deletes one or more test plan templates and return errors for failed deletion. + + Returns: + A partial success if any test plan templates failed to delete, or None if all + test plan templates were deleted successfully. + + Raises: ApiException: if unable to communicate with the `/niworkorder` service of provided invalid + arguments. + """ ... \ No newline at end of file diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py b/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py index ec6e8af1..8afdd9ef 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py @@ -1,4 +1,4 @@ from nisystemlink.clients.test_plan.test_plan_templates.models._create_test_plan_templates import CreateTestPlanTemplate, CreateTestPlanTemplateResponse from nisystemlink.clients.test_plan.test_plan_templates.models._query_test_plan_templates import QueryTestPlanTemplatesRequestBody, QueryTestPlanTemplatesResponse -from nisystemlink.clients.test_plan.test_plan_templates.models._delete_test_plan_templates import DeleteTestPlanTemplates, DeleteTestPlanTemplatesResponseSuccess +from nisystemlink.clients.test_plan.test_plan_templates.models._delete_test_plan_templates import DeleteTestPlanTemplates, DeleteTestPlanTemplatesPartialSuccess # flake8: noqa \ No newline at end of file diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_create_test_plan_templates.py b/nisystemlink/clients/test_plan/test_plan_templates/models/_create_test_plan_templates.py index 05445226..290f2425 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/_create_test_plan_templates.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/_create_test_plan_templates.py @@ -15,7 +15,16 @@ class CreateTestPlanTemplate(JsonModel): class CreateTestPlanTemplateResponse(JsonModel): createdTestPlanTemplates: Optional[List[TestPlanTemplateResponse]] = None + """The list of test plan templates that were successfully created.""" failedTestPlanTemplates: Optional[List[TestPlanTemplateResponse]] = None + """The list of test plan templates that were not created. - error: Optional[ApiError] = None \ No newline at end of file + If this is `None`, then all test plan templates were successfully created. + """ + + error: Optional[ApiError] = None + """Error messages for products that were not created. + + If this is `None`, then all products were successfully created. + """ \ No newline at end of file diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_delete_test_plan_templates.py b/nisystemlink/clients/test_plan/test_plan_templates/models/_delete_test_plan_templates.py index 60d307fd..215a0ec4 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/_delete_test_plan_templates.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/_delete_test_plan_templates.py @@ -8,7 +8,14 @@ class DeleteTestPlanTemplates(JsonModel): ids: List[str] """ List of test plan template IDs to delete """ -class DeleteTestPlanTemplatesResponseSuccess(JsonModel): +class DeleteTestPlanTemplatesPartialSuccess(JsonModel): + """The result of deleting multiple test plan templates when one or more test plan templates could not be deleted.""" + deletedTestPlanTemplateIds: List[str] + """The IDs of the test plan template that could not be deleted.""" + failedTestPlanTemplateIds: Optional[List[str]] = None - error: Optional[ApiError] = None \ No newline at end of file + """The IDs of the test plan template that could not be deleted.""" + + error: Optional[ApiError] = None + """The error that occurred when deleting the test plan template.""" diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates.py b/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates.py index 560968ee..c046ee2b 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates.py @@ -45,10 +45,13 @@ class QueryTestPlanTemplatesRequestBody(QueryTestPlanTemplateBase): take: Optional[int] = None """The maximum number of test plan templates to return.""" + orderBy: Optional[TestPlanTemplateOrderBy] = None """Field by which test plan templates can be ordered/sorted.""" + descending: Optional[bool] = None """Whether to return the test plan templates in the descending order. By default, test plan templates are sorted in the ascending order.""" + continuationToken: Optional[str] = None """Allows users to continue the query at the next test plan templates that matches the given criteria. @@ -62,6 +65,7 @@ class QueryTestPlanTemplatesResponse(JsonModel): testPlanTemplates: List[TestPlanTemplateResponse] """Queried test plan templates.""" + continuationToken: Optional[str] = None """Allows users to continue the query at the next test plan templates that matches the given criteria. diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py b/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py index 1cca2d8e..79eed517 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py @@ -2,31 +2,68 @@ from nisystemlink.clients.core._uplink._json_model import JsonModel from nisystemlink.clients.test_plan.models._execution_definition import ExecutionDefinition -class DashboardReference(JsonModel): - id: Optional[str] = None - variables: Dict[str, str] - class Dashboard(JsonModel): + """Contains information about a reference of a dashboard linked to test plan template.""" + id: Optional[str] = None + """The globally unique id of the dashboard.""" + variables: Dict[str, str] + """Dictionary of variables set on the dashboard. + These will be appended to the URL as query parameters. + Each key will be prefixed with "var-" and the value will be the value of the variable + """ class TestPlanTemplateBase(JsonModel): + """Contains information about a test plan template.""" + name: str + """Name of the test plan template.""" + templateGroup: str = None - summary: Optional[str] = None + """The template group defined by the user.""" + productFamilies: Optional[List[str]] = None + """Array of product families to which the test plan template belongs.""" + partNumbers: Optional[List[str]] = None + """Array of part numbers of the products to which the test plan template belongs.""" + + summary: Optional[str] = None + """Summary of the test plan template.""" + description: Optional[str] = None + """Description of the test plan created from this template.""" + testProgram: Optional[str] = None - systemFilter: Optional[str] = None + """Test program name of the test plan created from this template.""" + estimatedDurationInSeconds: Optional[int] = None + """The estimated time in seconds for executing the test plan created from this template.""" + + systemFilter: Optional[str] = None + """The LINQ filter string is used to filter the potential list of systems capable of executing test plans created from this template.""" + + executionActions: Optional[List[ExecutionDefinition]] = None + """Defines the executions that will be used for test plan actions created from this template.""" + + fileIds: Optional[List[str]] = None + """Array of file IDs associated with the test plan template.""" + workspace: Optional[str] = None + """ID of the workspace where the test plan template belongs. Default workspace will be taken if the value is not given.""" + properties: Optional[Dict[str, str]] = None - fileIds: Optional[List[str]] = None - dashboardReference: Optional[DashboardReference] = None + """Properties of the test plan created from this template as key-value pairs.""" + dashboard: Optional[Dashboard] = None - executionActions: Optional[List[ExecutionDefinition]] = None + """Defines a dashboard reference for a test plan.""" class TestPlanTemplateResponse(TestPlanTemplateBase): + """Contains response information for test plan template.""" + id: Optional[str] = None - name: Optional[str] = None \ No newline at end of file + """The globally unique id of the test plan template.""" + + name: Optional[str] = None + """Name of the test plan template.""" diff --git a/tests/integration/test_plan/test_plan_templates/test__create_test_plan_template.py b/tests/integration/test_plan/test_plan_templates/test__create_test_plan_template.py index 17d2f856..327cc684 100644 --- a/tests/integration/test_plan/test_plan_templates/test__create_test_plan_template.py +++ b/tests/integration/test_plan/test_plan_templates/test__create_test_plan_template.py @@ -5,7 +5,7 @@ from nisystemlink.clients.test_plan.models._execution_definition import ManualExecutionDefinition from nisystemlink.clients.test_plan.test_plan_templates._test_plan_templates_client import TestPlanTemplateClient from nisystemlink.clients.test_plan.test_plan_templates.models._create_test_plan_templates import CreateTestPlanTemplateResponse -from nisystemlink.clients.test_plan.test_plan_templates.models._delete_test_plan_templates import DeleteTestPlanTemplates, DeleteTestPlanTemplatesResponseSuccess +from nisystemlink.clients.test_plan.test_plan_templates.models._delete_test_plan_templates import DeleteTestPlanTemplates, DeleteTestPlanTemplatesPartialSuccess from nisystemlink.clients.test_plan.test_plan_templates.models._query_test_plan_templates import QueryTestPlanTemplatesRequestBody, QueryTestPlanTemplatesResponse from nisystemlink.clients.test_plan.test_plan_templates.models._test_plan_templates import TestPlanTemplateBase @@ -54,7 +54,7 @@ def test__create_test_plan_template__returns_created_test_plan_template( assert template_id is not None - client.delete_test_plan_templates( + delete_response: DeleteTestPlanTemplatesPartialSuccess = client.delete_test_plan_templates( Ids=DeleteTestPlanTemplates( ids=[template_id] ) From 10c8d8b6e7fc9db2b02a17ded67aaed048fc2358 Mon Sep 17 00:00:00 2001 From: Ammar Husain Mian Fazulul Date: Mon, 19 May 2025 14:37:27 +0530 Subject: [PATCH 17/64] updated documentation --- .../models/_create_test_plan_templates.py | 4 ++-- .../test__create_test_plan_template.py | 24 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_create_test_plan_templates.py b/nisystemlink/clients/test_plan/test_plan_templates/models/_create_test_plan_templates.py index 290f2425..3118c17d 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/_create_test_plan_templates.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/_create_test_plan_templates.py @@ -24,7 +24,7 @@ class CreateTestPlanTemplateResponse(JsonModel): """ error: Optional[ApiError] = None - """Error messages for products that were not created. + """Error messages for test plan templates that were not created. - If this is `None`, then all products were successfully created. + If this is `None`, then all test plan templates were successfully created. """ \ No newline at end of file diff --git a/tests/integration/test_plan/test_plan_templates/test__create_test_plan_template.py b/tests/integration/test_plan/test_plan_templates/test__create_test_plan_template.py index 327cc684..03a0896e 100644 --- a/tests/integration/test_plan/test_plan_templates/test__create_test_plan_template.py +++ b/tests/integration/test_plan/test_plan_templates/test__create_test_plan_template.py @@ -5,14 +5,14 @@ from nisystemlink.clients.test_plan.models._execution_definition import ManualExecutionDefinition from nisystemlink.clients.test_plan.test_plan_templates._test_plan_templates_client import TestPlanTemplateClient from nisystemlink.clients.test_plan.test_plan_templates.models._create_test_plan_templates import CreateTestPlanTemplateResponse -from nisystemlink.clients.test_plan.test_plan_templates.models._delete_test_plan_templates import DeleteTestPlanTemplates, DeleteTestPlanTemplatesPartialSuccess +from nisystemlink.clients.test_plan.test_plan_templates.models._delete_test_plan_templates import DeleteTestPlanTemplates from nisystemlink.clients.test_plan.test_plan_templates.models._query_test_plan_templates import QueryTestPlanTemplatesRequestBody, QueryTestPlanTemplatesResponse from nisystemlink.clients.test_plan.test_plan_templates.models._test_plan_templates import TestPlanTemplateBase @pytest.fixture(scope="class") def create_test_plan_template() -> List[TestPlanTemplateBase]: - """Fixture to create test plan """ + """Fixture to create test plan template.""" testPlanTemplates = [ TestPlanTemplateBase( @@ -42,19 +42,19 @@ class TestTestPlanTemplate: def test__create_test_plan_template__returns_created_test_plan_template( self, client: TestPlanTemplateClient, create_test_plan_template: List[TestPlanTemplateBase] ): - create_response: CreateTestPlanTemplateResponse = client.create_testPlanTemplates( + create_test_plan_template_response: CreateTestPlanTemplateResponse = client.create_testPlanTemplates( testPlanTemplates=create_test_plan_template ) template_id = ( - create_response.createdTestPlanTemplates[0].id - if create_response.createdTestPlanTemplates and create_response.createdTestPlanTemplates[0].id + create_test_plan_template_response.createdTestPlanTemplates[0].id + if create_test_plan_template_response.createdTestPlanTemplates and create_test_plan_template_response.createdTestPlanTemplates[0].id else None ) assert template_id is not None - delete_response: DeleteTestPlanTemplatesPartialSuccess = client.delete_test_plan_templates( + client.delete_test_plan_templates( Ids=DeleteTestPlanTemplates( ids=[template_id] ) @@ -72,13 +72,13 @@ def test__create_test_plan_template__returns_created_test_plan_template( def test__query_test_plan_template__returns_queried_test_plan_template( self, client: TestPlanTemplateClient, create_test_plan_template: List[TestPlanTemplateBase] ): - create_response: CreateTestPlanTemplateResponse = client.create_testPlanTemplates( + create_test_plan_template_response: CreateTestPlanTemplateResponse = client.create_testPlanTemplates( testPlanTemplates=create_test_plan_template ) template_id = ( - create_response.createdTestPlanTemplates[0].id - if create_response.createdTestPlanTemplates and create_response.createdTestPlanTemplates[0].id + create_test_plan_template_response.createdTestPlanTemplates[0].id + if create_test_plan_template_response.createdTestPlanTemplates and create_test_plan_template_response.createdTestPlanTemplates[0].id else None ) @@ -103,13 +103,13 @@ def test__query_test_plan_template__returns_queried_test_plan_template( def test__delete_test_plan_template( self, client: TestPlanTemplateClient, create_test_plan_template: List[TestPlanTemplateBase] ): - create_response: CreateTestPlanTemplateResponse = client.create_testPlanTemplates( + create_test_plan_template_response: CreateTestPlanTemplateResponse = client.create_testPlanTemplates( testPlanTemplates=create_test_plan_template ) template_id = ( - create_response.createdTestPlanTemplates[0].id - if create_response.createdTestPlanTemplates and create_response.createdTestPlanTemplates[0].id + create_test_plan_template_response.createdTestPlanTemplates[0].id + if create_test_plan_template_response.createdTestPlanTemplates and create_test_plan_template_response.createdTestPlanTemplates[0].id else None ) From 02984034e00987749811dc76993905489acba81a Mon Sep 17 00:00:00 2001 From: Ammar Husain Mian Fazulul Date: Mon, 19 May 2025 14:47:49 +0530 Subject: [PATCH 18/64] updated nit changes --- .../test_plan/models/_execution_definition.py | 71 +++++++++---------- .../models/_delete_test_plan_templates.py | 2 +- .../models/_test_plan_templates.py | 2 +- .../test__create_test_plan_template.py | 3 +- 4 files changed, 36 insertions(+), 42 deletions(-) diff --git a/nisystemlink/clients/test_plan/models/_execution_definition.py b/nisystemlink/clients/test_plan/models/_execution_definition.py index 2303c553..c83fedfa 100644 --- a/nisystemlink/clients/test_plan/models/_execution_definition.py +++ b/nisystemlink/clients/test_plan/models/_execution_definition.py @@ -2,89 +2,82 @@ from nisystemlink.clients.core._uplink._json_model import JsonModel class Job(JsonModel): - """ - Represents a job to be executed, including its functions, arguments, and metadata. - """ + """Represents a job to be executed, including its functions, arguments, and metadata.""" + functions: List[str] - """List of function names to execute""" + """List of function names to execute.""" arguments: List[List[object]] - """List of argument lists for each function""" + """List of argument lists for each function.""" metadata: dict[str, object] - """Additional metadata for the job""" + """Additional metadata for the job.""" class NotebookExecutionDefinition(JsonModel): - """ - Defines the execution of a notebook. - """ + """Defines the execution of a notebook.""" + action: str - """User defined action to perform in workflow (user defined)""" + """User defined action to perform in workflow (user defined).""" type: str = 'NOTEBOOK' - """Type of execution, default is 'NOTEBOOK'""" + """Type of execution, default is 'NOTEBOOK'.""" notebookId: str - """ID of the notebook to execute""" + """ID of the notebook to execute.""" class ManualExecutionDefinition(JsonModel): - """ - Represents a manual execution definition. - """ + """Represents a manual execution definition.""" + action: str - """User defined action to perform in workflow (user defined)""" + """User defined action to perform in workflow (user defined).""" type: str = 'MANUAL' - """Type of execution, default is 'MANUAL'""" + """Type of execution, default is 'MANUAL'.""" class JobExecutionDefinition(JsonModel): - """ - Defines the execution of one or more jobs. - """ + """Defines the execution of one or more jobs.""" + action: str - """User defined action to perform in workflow (user defined)""" + """User defined action to perform in workflow (user defined).""" type: str = 'JOB' - """Type of execution, default is 'JOB'""" + """Type of execution, default is 'JOB'.""" jobs: List[Job] - """List of jobs to execute""" + """List of jobs to execute.""" systemId: str | None = None - """Optional system ID where jobs will run""" + """Optional system ID where jobs will run.""" class ScheduleExecutionDefinition(JsonModel): - """ - Represents a scheduled execution definition. - """ + """Represents a scheduled execution definition.""" + action: str - """User defined action to perform in workflow (user defined)""" + """User defined action to perform in workflow (user defined).""" type: str = 'SCHEDULE' - """Type of execution, default is 'SCHEDULE'""" + """Type of execution, default is 'SCHEDULE'.""" class UnscheduleExecutionDefinition(JsonModel): - """ - Represents an unscheduled execution definition. - """ + """Represents an unscheduled execution definition.""" + action: str - """User defined action to perform in workflow (user defined)""" + """User defined action to perform in workflow (user defined).""" type: str = 'UNSCHEDULE' - """Type of execution, default is 'UNSCHEDULE'""" + """Type of execution, default is 'UNSCHEDULE'.""" class NoneExecutionDefinition(JsonModel): - """ - Represents a definition where no execution is specified. - """ + """Represents a definition where no execution is specified.""" + action: str - """User defined action to perform in workflow (user defined)""" + """User defined action to perform in workflow (user defined).""" type: str = 'None' - """Type of execution, default is 'None'""" + """Type of execution, default is 'None'.""" ExecutionDefinition = Union[ NotebookExecutionDefinition, diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_delete_test_plan_templates.py b/nisystemlink/clients/test_plan/test_plan_templates/models/_delete_test_plan_templates.py index 215a0ec4..c55f65dd 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/_delete_test_plan_templates.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/_delete_test_plan_templates.py @@ -6,7 +6,7 @@ class DeleteTestPlanTemplates(JsonModel): """Deletes one or more test plan templates identified by their IDs.""" ids: List[str] - """ List of test plan template IDs to delete """ + """List of test plan template IDs to delete.""" class DeleteTestPlanTemplatesPartialSuccess(JsonModel): """The result of deleting multiple test plan templates when one or more test plan templates could not be deleted.""" diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py b/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py index 79eed517..a6798e03 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py @@ -11,7 +11,7 @@ class Dashboard(JsonModel): variables: Dict[str, str] """Dictionary of variables set on the dashboard. These will be appended to the URL as query parameters. - Each key will be prefixed with "var-" and the value will be the value of the variable + Each key will be prefixed with "var-" and the value will be the value of the variable. """ class TestPlanTemplateBase(JsonModel): diff --git a/tests/integration/test_plan/test_plan_templates/test__create_test_plan_template.py b/tests/integration/test_plan/test_plan_templates/test__create_test_plan_template.py index 03a0896e..1b480895 100644 --- a/tests/integration/test_plan/test_plan_templates/test__create_test_plan_template.py +++ b/tests/integration/test_plan/test_plan_templates/test__create_test_plan_template.py @@ -32,7 +32,8 @@ def create_test_plan_template() -> List[TestPlanTemplateBase]: @pytest.fixture(scope="class") def client(enterprise_config: HttpConfiguration) -> TestPlanTemplateClient: - """Fixture to create a TestPlanTemplateClient instance""" + """Fixture to create a TestPlanTemplateClient instance.""" + return TestPlanTemplateClient(enterprise_config) @pytest.mark.integration From 0b8fa56daca572f113a3da9c301f599f786516fc Mon Sep 17 00:00:00 2001 From: Ammar Husain Mian Fazulul Date: Mon, 19 May 2025 15:07:14 +0530 Subject: [PATCH 19/64] added comments in init files --- nisystemlink/clients/test_plan/__init__.py | 1 + .../clients/test_plan/test_plan_templates/__init__.py | 4 +++- .../clients/test_plan/test_plan_templates/models/__init__.py | 1 + tests/integration/test_plan/__init__.py | 1 + tests/integration/test_plan/test_plan_templates/__init__.py | 1 + 5 files changed, 7 insertions(+), 1 deletion(-) diff --git a/nisystemlink/clients/test_plan/__init__.py b/nisystemlink/clients/test_plan/__init__.py index e69de29b..a517c684 100644 --- a/nisystemlink/clients/test_plan/__init__.py +++ b/nisystemlink/clients/test_plan/__init__.py @@ -0,0 +1 @@ +# flake8: noqa \ No newline at end of file diff --git a/nisystemlink/clients/test_plan/test_plan_templates/__init__.py b/nisystemlink/clients/test_plan/test_plan_templates/__init__.py index 52c379b0..47304f4a 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/__init__.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/__init__.py @@ -1 +1,3 @@ -from nisystemlink.clients.test_plan.test_plan_templates._test_plan_templates_client import TestPlanTemplateClient \ No newline at end of file +from nisystemlink.clients.test_plan.test_plan_templates._test_plan_templates_client import TestPlanTemplateClient + +# flake8: noqa \ No newline at end of file diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py b/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py index 8afdd9ef..e0b6471a 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py @@ -1,4 +1,5 @@ from nisystemlink.clients.test_plan.test_plan_templates.models._create_test_plan_templates import CreateTestPlanTemplate, CreateTestPlanTemplateResponse from nisystemlink.clients.test_plan.test_plan_templates.models._query_test_plan_templates import QueryTestPlanTemplatesRequestBody, QueryTestPlanTemplatesResponse from nisystemlink.clients.test_plan.test_plan_templates.models._delete_test_plan_templates import DeleteTestPlanTemplates, DeleteTestPlanTemplatesPartialSuccess + # flake8: noqa \ No newline at end of file diff --git a/tests/integration/test_plan/__init__.py b/tests/integration/test_plan/__init__.py index e69de29b..a517c684 100644 --- a/tests/integration/test_plan/__init__.py +++ b/tests/integration/test_plan/__init__.py @@ -0,0 +1 @@ +# flake8: noqa \ No newline at end of file diff --git a/tests/integration/test_plan/test_plan_templates/__init__.py b/tests/integration/test_plan/test_plan_templates/__init__.py index e69de29b..a517c684 100644 --- a/tests/integration/test_plan/test_plan_templates/__init__.py +++ b/tests/integration/test_plan/test_plan_templates/__init__.py @@ -0,0 +1 @@ +# flake8: noqa \ No newline at end of file From 99d7d9ebda1a16b75fe9717c15a081b09dd9c7e1 Mon Sep 17 00:00:00 2001 From: Ammar Husain Mian Fazulul Date: Tue, 20 May 2025 13:34:22 +0530 Subject: [PATCH 20/64] resolved comments --- .../test_plan/models/_execution_definition.py | 24 +-- .../_test_plan_templates_client.py | 14 +- .../test_plan_templates/models/__init__.py | 8 +- ...lan_templates_partial_success_response.py} | 13 +- ...lan_templates_partial_success_response.py} | 12 +- ... => _query_test_plan_templates_request.py} | 47 ++---- .../_query_test_plan_templates_response.py | 18 ++ .../models/_test_plan_templates.py | 16 +- .../test__create_test_plan_template.py | 157 ++++++++++-------- 9 files changed, 158 insertions(+), 151 deletions(-) rename nisystemlink/clients/test_plan/test_plan_templates/models/{_create_test_plan_templates.py => _create_test_plan_templates_partial_success_response.py} (61%) rename nisystemlink/clients/test_plan/test_plan_templates/models/{_delete_test_plan_templates.py => _delete_test_plan_templates_partial_success_response.py} (60%) rename nisystemlink/clients/test_plan/test_plan_templates/models/{_query_test_plan_templates.py => _query_test_plan_templates_request.py} (73%) create mode 100644 nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates_response.py diff --git a/nisystemlink/clients/test_plan/models/_execution_definition.py b/nisystemlink/clients/test_plan/models/_execution_definition.py index c83fedfa..d8a22bbf 100644 --- a/nisystemlink/clients/test_plan/models/_execution_definition.py +++ b/nisystemlink/clients/test_plan/models/_execution_definition.py @@ -13,7 +13,7 @@ class Job(JsonModel): metadata: dict[str, object] """Additional metadata for the job.""" -class NotebookExecutionDefinition(JsonModel): +class NotebookExecution(JsonModel): """Defines the execution of a notebook.""" action: str @@ -26,7 +26,7 @@ class NotebookExecutionDefinition(JsonModel): """ID of the notebook to execute.""" -class ManualExecutionDefinition(JsonModel): +class ManualExecution(JsonModel): """Represents a manual execution definition.""" action: str @@ -35,7 +35,7 @@ class ManualExecutionDefinition(JsonModel): type: str = 'MANUAL' """Type of execution, default is 'MANUAL'.""" -class JobExecutionDefinition(JsonModel): +class JobExecution(JsonModel): """Defines the execution of one or more jobs.""" action: str @@ -51,7 +51,7 @@ class JobExecutionDefinition(JsonModel): """Optional system ID where jobs will run.""" -class ScheduleExecutionDefinition(JsonModel): +class ScheduleExecution(JsonModel): """Represents a scheduled execution definition.""" action: str @@ -61,7 +61,7 @@ class ScheduleExecutionDefinition(JsonModel): """Type of execution, default is 'SCHEDULE'.""" -class UnscheduleExecutionDefinition(JsonModel): +class UnscheduleExecution(JsonModel): """Represents an unscheduled execution definition.""" action: str @@ -70,7 +70,7 @@ class UnscheduleExecutionDefinition(JsonModel): type: str = 'UNSCHEDULE' """Type of execution, default is 'UNSCHEDULE'.""" -class NoneExecutionDefinition(JsonModel): +class NoneExecution(JsonModel): """Represents a definition where no execution is specified.""" action: str @@ -80,10 +80,10 @@ class NoneExecutionDefinition(JsonModel): """Type of execution, default is 'None'.""" ExecutionDefinition = Union[ - NotebookExecutionDefinition, - ManualExecutionDefinition, - JobExecutionDefinition, - NoneExecutionDefinition, - ScheduleExecutionDefinition, - UnscheduleExecutionDefinition + NotebookExecution, + ManualExecution, + JobExecution, + NoneExecution, + ScheduleExecution, + UnscheduleExecution ] \ No newline at end of file diff --git a/nisystemlink/clients/test_plan/test_plan_templates/_test_plan_templates_client.py b/nisystemlink/clients/test_plan/test_plan_templates/_test_plan_templates_client.py index 8be3f429..e0fb809a 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/_test_plan_templates_client.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/_test_plan_templates_client.py @@ -33,9 +33,9 @@ def __init__(self, configuration: Optional[core.HttpConfiguration] = None): super().__init__(configuration, base_path="/niworkorder/v1/") @post("testplan-templates", args=[Field("testPlanTemplates")]) - def create_testPlanTemplates( - self, testPlanTemplates: List[models.CreateTestPlanTemplate] - ) -> models.CreateTestPlanTemplateResponse: + def create_test_plan_templates( + self, test_plan_templates: List[models.TestPlanTemplateBase] + ) -> models.CreateTestPlanTemplatePartialSuccessResponse: """Creates one or more test plan template and return errors for failed creations. Args: @@ -51,7 +51,7 @@ def create_testPlanTemplates( @post("query-testplan-templates") def query_test_plan_templates( - self, queryTestPlanTemplates: models.QueryTestPlanTemplatesRequestBody + self, query_test_plan_templates: models.QueryTestPlanTemplatesRequest ) -> models.QueryTestPlanTemplatesResponse: """Queries one or more test plan templates and return errors for failed queries. @@ -62,10 +62,10 @@ def query_test_plan_templates( """ ... - @post("delete-testplan-templates") + @post("delete-testplan-templates", args=[Field("ids")]) def delete_test_plan_templates( - self, Ids: models.DeleteTestPlanTemplates - ) -> Optional[models.DeleteTestPlanTemplatesPartialSuccess]: + self, ids: List[str] + ) -> Optional[models.DeleteTestPlanTemplatesPartialSuccessResponse]: """Deletes one or more test plan templates and return errors for failed deletion. Returns: diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py b/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py index e0b6471a..56119e82 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py @@ -1,5 +1,7 @@ -from nisystemlink.clients.test_plan.test_plan_templates.models._create_test_plan_templates import CreateTestPlanTemplate, CreateTestPlanTemplateResponse -from nisystemlink.clients.test_plan.test_plan_templates.models._query_test_plan_templates import QueryTestPlanTemplatesRequestBody, QueryTestPlanTemplatesResponse -from nisystemlink.clients.test_plan.test_plan_templates.models._delete_test_plan_templates import DeleteTestPlanTemplates, DeleteTestPlanTemplatesPartialSuccess +from nisystemlink.clients.test_plan.test_plan_templates.models._create_test_plan_templates_partial_success_response import CreateTestPlanTemplatePartialSuccessResponse +from nisystemlink.clients.test_plan.test_plan_templates.models._query_test_plan_templates_request import QueryTestPlanTemplatesRequest +from nisystemlink.clients.test_plan.test_plan_templates.models._query_test_plan_templates_response import QueryTestPlanTemplatesResponse +from nisystemlink.clients.test_plan.test_plan_templates.models._delete_test_plan_templates_partial_success_response import DeleteTestPlanTemplatesPartialSuccessResponse +from nisystemlink.clients.test_plan.test_plan_templates.models._test_plan_templates import TestPlanTemplateBase # flake8: noqa \ No newline at end of file diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_create_test_plan_templates.py b/nisystemlink/clients/test_plan/test_plan_templates/models/_create_test_plan_templates_partial_success_response.py similarity index 61% rename from nisystemlink/clients/test_plan/test_plan_templates/models/_create_test_plan_templates.py rename to nisystemlink/clients/test_plan/test_plan_templates/models/_create_test_plan_templates_partial_success_response.py index 3118c17d..7735096a 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/_create_test_plan_templates.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/_create_test_plan_templates_partial_success_response.py @@ -5,19 +5,12 @@ from nisystemlink.clients.core._uplink._json_model import JsonModel from ._test_plan_templates import TestPlanTemplateBase, TestPlanTemplateResponse +class CreateTestPlanTemplatePartialSuccessResponse(JsonModel): -class CreateTestPlanTemplate(JsonModel): - """Creates one or more test plan templates with the provided data.""" - - testPlanTemplates: List[TestPlanTemplateBase] - """List of test plan templates to create.""" - -class CreateTestPlanTemplateResponse(JsonModel): - - createdTestPlanTemplates: Optional[List[TestPlanTemplateResponse]] = None + created_test_plan_templates: Optional[List[TestPlanTemplateResponse]] = None """The list of test plan templates that were successfully created.""" - failedTestPlanTemplates: Optional[List[TestPlanTemplateResponse]] = None + failed_test_plan_templates: Optional[List[TestPlanTemplateBase]] = None """The list of test plan templates that were not created. If this is `None`, then all test plan templates were successfully created. diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_delete_test_plan_templates.py b/nisystemlink/clients/test_plan/test_plan_templates/models/_delete_test_plan_templates_partial_success_response.py similarity index 60% rename from nisystemlink/clients/test_plan/test_plan_templates/models/_delete_test_plan_templates.py rename to nisystemlink/clients/test_plan/test_plan_templates/models/_delete_test_plan_templates_partial_success_response.py index c55f65dd..5186f6b9 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/_delete_test_plan_templates.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/_delete_test_plan_templates_partial_success_response.py @@ -2,19 +2,13 @@ from nisystemlink.clients.core._api_error import ApiError from nisystemlink.clients.core._uplink._json_model import JsonModel -class DeleteTestPlanTemplates(JsonModel): - """Deletes one or more test plan templates identified by their IDs.""" - - ids: List[str] - """List of test plan template IDs to delete.""" - -class DeleteTestPlanTemplatesPartialSuccess(JsonModel): +class DeleteTestPlanTemplatesPartialSuccessResponse(JsonModel): """The result of deleting multiple test plan templates when one or more test plan templates could not be deleted.""" - deletedTestPlanTemplateIds: List[str] + deleted_test_plan_template_ids: List[str] """The IDs of the test plan template that could not be deleted.""" - failedTestPlanTemplateIds: Optional[List[str]] = None + failed_test_plan_template_ids: Optional[List[str]] = None """The IDs of the test plan template that could not be deleted.""" error: Optional[ApiError] = None diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates.py b/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates_request.py similarity index 73% rename from nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates.py rename to nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates_request.py index c046ee2b..7af91d0f 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates_request.py @@ -1,10 +1,21 @@ from enum import Enum -from typing import List, Optional +import enum +from typing import Optional from nisystemlink.clients.core._uplink._json_model import JsonModel -from ._test_plan_templates import TestPlanTemplateResponse -class QueryTestPlanTemplateBase(JsonModel): +class TestPlanTemplateOrderBy(str, Enum): + """An enumeration by which test plan templates can be ordered/sorted.""" + + ID = enum.auto() + NAME = enum.auto() + TEMPLATE_GROUP = enum.auto() + CREATED_AT = enum.auto() + UPDATED_AT = enum.auto() + +class QueryTestPlanTemplatesRequest(JsonModel): + """Request information for the query test plan templates API.""" + filter: Optional[str] = None """The test plan template query filter in dynamic LINQ format. @@ -31,45 +42,19 @@ class QueryTestPlanTemplateBase(JsonModel): `"@0"`, `"@1"` etc. can be used in conjunction with the `substitutions` parameter to keep this query string more simple and reusable.""" -class TestPlanTemplateOrderBy(str, Enum): - """An enumeration by which test plan templates can be ordered/sorted.""" - - ID = "ID" - NAME = "NAME" - TEMPLATE_GROUP = "TEMPLATE_GROUP" - CREATED_AT = "CREATED_AT" - UPDATED_AT ="UPDATED_AT" - -class QueryTestPlanTemplatesRequestBody(QueryTestPlanTemplateBase): - """Request information for the query test plan templates API.""" - take: Optional[int] = None """The maximum number of test plan templates to return.""" - orderBy: Optional[TestPlanTemplateOrderBy] = None + order_by: Optional[TestPlanTemplateOrderBy] = None """Field by which test plan templates can be ordered/sorted.""" descending: Optional[bool] = None """Whether to return the test plan templates in the descending order. By default, test plan templates are sorted in the ascending order.""" - continuationToken: Optional[str] = None + continuation_token: Optional[str] = None """Allows users to continue the query at the next test plan templates that matches the given criteria. To retrieve the next page of test plan templates, pass the continuation token from the previous page in the next request. The service responds with the next page of data and provides a new continuation token. To paginate results, continue sending requests with the newest continuation token provided in each response.""" - -class QueryTestPlanTemplatesResponse(JsonModel): - """Response information for the query test plan templates API.""" - - testPlanTemplates: List[TestPlanTemplateResponse] - """Queried test plan templates.""" - - continuationToken: Optional[str] = None - """Allows users to continue the query at the next test plan templates that matches the given criteria. - - To retrieve the next page of test plan templates, pass the continuation token from the previous - page in the next request. The service responds with the next page of data and provides a new - continuation token. To paginate results, continue sending requests with the newest continuation - token provided in each response.""" \ No newline at end of file diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates_response.py b/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates_response.py new file mode 100644 index 00000000..a50d0c0e --- /dev/null +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates_response.py @@ -0,0 +1,18 @@ +from typing import List, Optional +from nisystemlink.clients.core._uplink._json_model import JsonModel +from nisystemlink.clients.test_plan.test_plan_templates.models._test_plan_templates import TestPlanTemplateResponse + + +class QueryTestPlanTemplatesResponse(JsonModel): + """Response information for the query test plan templates API.""" + + test_plan_templates: List[TestPlanTemplateResponse] + """Queried test plan templates.""" + + continuation_token: Optional[str] = None + """Allows users to continue the query at the next test plan templates that matches the given criteria. + + To retrieve the next page of test plan templates, pass the continuation token from the previous + page in the next request. The service responds with the next page of data and provides a new + continuation token. To paginate results, continue sending requests with the newest continuation + token provided in each response.""" \ No newline at end of file diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py b/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py index a6798e03..7f6dcae6 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py @@ -20,13 +20,13 @@ class TestPlanTemplateBase(JsonModel): name: str """Name of the test plan template.""" - templateGroup: str = None + template_group: str = None """The template group defined by the user.""" - productFamilies: Optional[List[str]] = None + product_families: Optional[List[str]] = None """Array of product families to which the test plan template belongs.""" - partNumbers: Optional[List[str]] = None + part_numbers: Optional[List[str]] = None """Array of part numbers of the products to which the test plan template belongs.""" summary: Optional[str] = None @@ -35,19 +35,19 @@ class TestPlanTemplateBase(JsonModel): description: Optional[str] = None """Description of the test plan created from this template.""" - testProgram: Optional[str] = None + test_program: Optional[str] = None """Test program name of the test plan created from this template.""" - estimatedDurationInSeconds: Optional[int] = None + estimated_duration_in_seconds: Optional[int] = None """The estimated time in seconds for executing the test plan created from this template.""" - systemFilter: Optional[str] = None + system_filter: Optional[str] = None """The LINQ filter string is used to filter the potential list of systems capable of executing test plans created from this template.""" - executionActions: Optional[List[ExecutionDefinition]] = None + execution_actions: Optional[List[ExecutionDefinition]] = None """Defines the executions that will be used for test plan actions created from this template.""" - fileIds: Optional[List[str]] = None + file_ids: Optional[List[str]] = None """Array of file IDs associated with the test plan template.""" workspace: Optional[str] = None diff --git a/tests/integration/test_plan/test_plan_templates/test__create_test_plan_template.py b/tests/integration/test_plan/test_plan_templates/test__create_test_plan_template.py index 1b480895..e499d8fc 100644 --- a/tests/integration/test_plan/test_plan_templates/test__create_test_plan_template.py +++ b/tests/integration/test_plan/test_plan_templates/test__create_test_plan_template.py @@ -2,33 +2,12 @@ import pytest from nisystemlink.clients.core._http_configuration import HttpConfiguration -from nisystemlink.clients.test_plan.models._execution_definition import ManualExecutionDefinition +from nisystemlink.clients.test_plan.models._execution_definition import ManualExecution from nisystemlink.clients.test_plan.test_plan_templates._test_plan_templates_client import TestPlanTemplateClient -from nisystemlink.clients.test_plan.test_plan_templates.models._create_test_plan_templates import CreateTestPlanTemplateResponse -from nisystemlink.clients.test_plan.test_plan_templates.models._delete_test_plan_templates import DeleteTestPlanTemplates -from nisystemlink.clients.test_plan.test_plan_templates.models._query_test_plan_templates import QueryTestPlanTemplatesRequestBody, QueryTestPlanTemplatesResponse -from nisystemlink.clients.test_plan.test_plan_templates.models._test_plan_templates import TestPlanTemplateBase - - -@pytest.fixture(scope="class") -def create_test_plan_template() -> List[TestPlanTemplateBase]: - """Fixture to create test plan template.""" - - testPlanTemplates = [ - TestPlanTemplateBase( - name = "Sample testplan template", - templateGroup = "sample template group", - workspace = "33eba2fe-fe42-48a1-a47f-a6669479a8aa", - executionActions=[ - ManualExecutionDefinition( - action="TEST", - type="MANUAl" - ) - ] - ) - ] - - return testPlanTemplates +from nisystemlink.clients.test_plan.test_plan_templates.models._create_test_plan_templates_partial_success_response import CreateTestPlanTemplatePartialSuccessResponse +from nisystemlink.clients.test_plan.test_plan_templates.models._query_test_plan_templates_request import QueryTestPlanTemplatesRequest +from nisystemlink.clients.test_plan.test_plan_templates.models._query_test_plan_templates_response import QueryTestPlanTemplatesResponse +from nisystemlink.clients.test_plan.test_plan_templates.models._test_plan_templates import TestPlanTemplateBase, TestPlanTemplateResponse @pytest.fixture(scope="class") def client(enterprise_config: HttpConfiguration) -> TestPlanTemplateClient: @@ -36,97 +15,133 @@ def client(enterprise_config: HttpConfiguration) -> TestPlanTemplateClient: return TestPlanTemplateClient(enterprise_config) +@pytest.fixture +def create_test_plan_templates(client: TestPlanTemplateClient): + """FIxture to return a factory that create test plan templates.""" + responses: List[CreateTestPlanTemplatePartialSuccessResponse] = [] + + def _create_test_plan_templates( + new_test_plan_templates: List[TestPlanTemplateBase], + ) -> CreateTestPlanTemplatePartialSuccessResponse: + response = client.create_test_plan_templates(test_plan_templates=new_test_plan_templates) + responses.append(response) + return response + + yield _create_test_plan_templates + + created_test_plan_templates: List[TestPlanTemplateResponse] = [] + for response in responses: + if response.created_test_plan_templates: + created_test_plan_templates = created_test_plan_templates + response.created_test_plan_templates + client.delete_test_plan_templates(ids=[test_plan_template.id for test_plan_template in created_test_plan_templates]) + @pytest.mark.integration @pytest.mark.enterprise -class TestTestPlanTemplate: +class TestPlanTemplateTest: def test__create_test_plan_template__returns_created_test_plan_template( - self, client: TestPlanTemplateClient, create_test_plan_template: List[TestPlanTemplateBase] + self, client: TestPlanTemplateClient, create_test_plan_templates ): - create_test_plan_template_response: CreateTestPlanTemplateResponse = client.create_testPlanTemplates( - testPlanTemplates=create_test_plan_template + create_test_plan_template_request: List[TestPlanTemplateBase] = [ + TestPlanTemplateBase( + name = "Python integration test plan template", + templateGroup = "sample template group", + workspace = "33eba2fe-fe42-48a1-a47f-a6669479a8aa", + executionActions=[ + ManualExecution( + action="TEST", + type="MANUAl" + ) + ] ) + ] + create_test_plan_template_response = create_test_plan_templates(create_test_plan_template_request) template_id = ( - create_test_plan_template_response.createdTestPlanTemplates[0].id - if create_test_plan_template_response.createdTestPlanTemplates and create_test_plan_template_response.createdTestPlanTemplates[0].id + create_test_plan_template_response.created_test_plan_templates[0].id + if create_test_plan_template_response.created_test_plan_templates and create_test_plan_template_response.created_test_plan_templates[0].id else None ) assert template_id is not None - - client.delete_test_plan_templates( - Ids=DeleteTestPlanTemplates( - ids=[template_id] - ) - ) - - query_deleted_test_plan_template_response: QueryTestPlanTemplatesResponse = client.query_test_plan_templates( - queryTestPlanTemplates=QueryTestPlanTemplatesRequestBody( - filter=f'id="{template_id}"', - take=1 - ) - ) - - assert len(query_deleted_test_plan_template_response.testPlanTemplates) == 0 + assert create_test_plan_template_response.created_test_plan_templates[0].name == create_test_plan_template_request[0].name def test__query_test_plan_template__returns_queried_test_plan_template( - self, client: TestPlanTemplateClient, create_test_plan_template: List[TestPlanTemplateBase] + self, client: TestPlanTemplateClient, create_test_plan_templates ): - create_test_plan_template_response: CreateTestPlanTemplateResponse = client.create_testPlanTemplates( - testPlanTemplates=create_test_plan_template + + create_test_plan_template_request: List[TestPlanTemplateBase] = [ + TestPlanTemplateBase( + name = "Python integration test plan template", + templateGroup = "sample template group", + workspace = "33eba2fe-fe42-48a1-a47f-a6669479a8aa", + executionActions=[ + ManualExecution( + action="TEST", + type="MANUAl" + ) + ] ) + ] + + create_test_plan_template_response = create_test_plan_templates(create_test_plan_template_request) template_id = ( - create_test_plan_template_response.createdTestPlanTemplates[0].id - if create_test_plan_template_response.createdTestPlanTemplates and create_test_plan_template_response.createdTestPlanTemplates[0].id + create_test_plan_template_response.created_test_plan_templates[0].id + if create_test_plan_template_response.created_test_plan_templates and create_test_plan_template_response.created_test_plan_templates[0].id else None ) assert template_id is not None query_test_plan_template_response: QueryTestPlanTemplatesResponse = client.query_test_plan_templates( - queryTestPlanTemplates=QueryTestPlanTemplatesRequestBody( + query_test_plan_templates=QueryTestPlanTemplatesRequest( filter=f'id="{template_id}"', take=1 ) ) - assert len(query_test_plan_template_response.testPlanTemplates) == 1 - assert query_test_plan_template_response.testPlanTemplates[0].name == create_test_plan_template[0].name - - client.delete_test_plan_templates( - Ids=DeleteTestPlanTemplates( - ids=[template_id] - ) - ) + assert len(query_test_plan_template_response.test_plan_templates) == 1 + assert query_test_plan_template_response.test_plan_templates[0].id == template_id def test__delete_test_plan_template( - self, client: TestPlanTemplateClient, create_test_plan_template: List[TestPlanTemplateBase] + self, client: TestPlanTemplateClient ): - create_test_plan_template_response: CreateTestPlanTemplateResponse = client.create_testPlanTemplates( - testPlanTemplates=create_test_plan_template + + create_test_plan_template_request: List[TestPlanTemplateBase] = [ + TestPlanTemplateBase( + name = "Python integration test plan template", + templateGroup = "sample template group", + workspace = "33eba2fe-fe42-48a1-a47f-a6669479a8aa", + executionActions=[ + ManualExecution( + action="TEST", + type="MANUAl" + ) + ] + ) + ] + create_test_plan_template_response: CreateTestPlanTemplatePartialSuccessResponse = client.create_test_plan_templates( + test_plan_templates=create_test_plan_template_request ) template_id = ( - create_test_plan_template_response.createdTestPlanTemplates[0].id - if create_test_plan_template_response.createdTestPlanTemplates and create_test_plan_template_response.createdTestPlanTemplates[0].id + create_test_plan_template_response.created_test_plan_templates[0].id + if create_test_plan_template_response.created_test_plan_templates and create_test_plan_template_response.created_test_plan_templates[0].id else None ) assert template_id is not None client.delete_test_plan_templates( - Ids=DeleteTestPlanTemplates( - ids=[template_id] - ) + ids=[template_id] ) query_deleted_test_plan_template_response: QueryTestPlanTemplatesResponse = client.query_test_plan_templates( - queryTestPlanTemplates=QueryTestPlanTemplatesRequestBody( + query_test_plan_templates=QueryTestPlanTemplatesRequest( filter=f'id="{template_id}"', take=1 ) ) - assert len(query_deleted_test_plan_template_response.testPlanTemplates) == 0 + assert len(query_deleted_test_plan_template_response.test_plan_templates) == 0 From d93bbac64e5fc08c354f22547be6fe10adfae8f2 Mon Sep 17 00:00:00 2001 From: Ammar Husain Mian Fazulul Date: Tue, 20 May 2025 14:38:49 +0530 Subject: [PATCH 21/64] added documentation for test plan template --- docs/api_reference.rst | 1 + docs/api_reference/test_plan_templates.rst | 16 +++++++ docs/getting_started.rst | 26 ++++++++++ .../test_plan_templates.py | 47 +++++++++++++++++++ 4 files changed, 90 insertions(+) create mode 100644 docs/api_reference/test_plan_templates.rst create mode 100644 examples/test_plan/test_plan_templates/test_plan_templates.py diff --git a/docs/api_reference.rst b/docs/api_reference.rst index 5a5e1d7c..0a4bcadc 100644 --- a/docs/api_reference.rst +++ b/docs/api_reference.rst @@ -16,6 +16,7 @@ API Reference api_reference/file api_reference/notebook api_reference/feeds + api_reference/test_plan_templates Indices and tables ------------------ diff --git a/docs/api_reference/test_plan_templates.rst b/docs/api_reference/test_plan_templates.rst new file mode 100644 index 00000000..b35ddeaa --- /dev/null +++ b/docs/api_reference/test_plan_templates.rst @@ -0,0 +1,16 @@ +.. _api_tag_page: + +nisystemlink.clients.test_plan.test_plan_templates +====================== + +.. autoclass:: nisystemlink.clients.test_plan.test_plan_templates.TestPlanTemplateClient + :exclude-members: __init__ + + .. automethod:: __init__ + .. automethod:: create_test_plan_templates + .. automethod:: query_test_plan_templates + .. automethod:: delete_test_plan_templates + +.. automodule:: nisystemlink.clients.test_plan.test_plan_templates.models + :members: + :imported-members: \ No newline at end of file diff --git a/docs/getting_started.rst b/docs/getting_started.rst index 5e98cfe7..e36b3d73 100644 --- a/docs/getting_started.rst +++ b/docs/getting_started.rst @@ -318,5 +318,31 @@ Create, query, update, and delete some notebooks. Create, query, retry, and cancel notebook executions. .. literalinclude:: ../examples/notebook/notebook_execution.py + :language: python + :linenos: + +TestPlanTemplate API +------- + +Overview +~~~~~~~~ + +The :class:`.TestPlanTemplateClient` class is the primary entry point of the TestPlanTemplate API. + +When constructing a :class:`.TestPlanTemplateClient`, you can pass an +:class:`.HttpConfiguration` (like one retrieved from the +:class:`.HttpConfigurationManager`), or let :class:`.TestPlanTemplateClient` use the +default connection. The default connection depends on your environment. + +With a :class:`.TestPlanTemplateClient` object, you can: + +* Create, query, and delete TestPlanTemplate + +Examples +~~~~~~~~ + +Create, query and delete test plan templates. + +.. literalinclude:: ../examples/test_plan/test_plan_templates/test_plan_templates.py :language: python :linenos: \ No newline at end of file diff --git a/examples/test_plan/test_plan_templates/test_plan_templates.py b/examples/test_plan/test_plan_templates/test_plan_templates.py new file mode 100644 index 00000000..9dd53fe6 --- /dev/null +++ b/examples/test_plan/test_plan_templates/test_plan_templates.py @@ -0,0 +1,47 @@ +from nisystemlink.clients.core._http_configuration import HttpConfiguration +from nisystemlink.clients.test_plan.models._execution_definition import ManualExecution +from nisystemlink.clients.test_plan.test_plan_templates._test_plan_templates_client import TestPlanTemplateClient +from nisystemlink.clients.test_plan.test_plan_templates.models._query_test_plan_templates_request import QueryTestPlanTemplatesRequest +from nisystemlink.clients.test_plan.test_plan_templates.models._test_plan_templates import TestPlanTemplateBase + +# Setup the server configuration to point to your instance of SystemLink Enterprise +server_configuration = HttpConfiguration( + server_uri="https://yourserver.yourcompany.com", + api_key="YourAPIKeyGeneratedFromSystemLink", +) +client = TestPlanTemplateClient(configuration=server_configuration) + +#Test plan template request metadata +create_test_plan_template_request = [ + TestPlanTemplateBase( + name = "Python integration test plan template", + templateGroup = "sample template group", + workspace = "33eba2fe-fe42-48a1-a47f-a6669479a8aa", + executionActions=[ + ManualExecution( + action="TEST", + type="MANUAl" + ) + ] + ) + ] + +# Create a test plan template +create_test_plan_template_response = client.create_test_plan_templates(test_plan_templates=create_test_plan_template_request) + +create_test_plan_template_id = None + +if create_test_plan_template_response.created_test_plan_templates and create_test_plan_template_response.created_test_plan_templates[0].id: + create_test_plan_template_id = str(create_test_plan_template_response.created_test_plan_templates[0].id) + +# Query test plan templates using id +query_test_plan_template_request = QueryTestPlanTemplatesRequest( + filter=f'id="{create_test_plan_template_id}"', + take=1 +) + +client.query_test_plan_templates(query_test_plan_templates=query_test_plan_template_request) + +#Delete the created test plan template. +if create_test_plan_template_id is not None: + client.delete_test_plan_templates(ids=[create_test_plan_template_id]) \ No newline at end of file From a10a6b6bf5412dc2b332e87fafed9284f013cae2 Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Tue, 20 May 2025 19:02:35 +0530 Subject: [PATCH 22/64] update test --- .../test_plans/_test_plans_client.py | 5 +-- .../test_plan/test_plans/models/__init__.py | 17 ++++---- ...s.py => _create_test_plan_body_content.py} | 41 +++---------------- .../models/_create_test_plans_request.py | 14 +++++++ .../models/_create_test_plans_response.py | 22 ++++++++++ .../test_plans/models/_delete_test_plans.py | 25 ----------- .../models/_delete_test_plans_request.py | 10 +++++ ..._plans.py => _query_test_plans_request.py} | 19 +-------- .../models/_query_test_plans_response.py | 20 +++++++++ ...y => _schedule_test_plans_body_content.py} | 27 +----------- .../models/_schedule_test_plans_request.py | 14 +++++++ .../models/_schedule_test_plans_response.py | 14 +++++++ .../test_plan/test_plans/models/_test_plan.py | 28 ++++++------- .../test_plan/test_plans/test_test_plans.py | 24 ++++++----- 14 files changed, 139 insertions(+), 141 deletions(-) rename nisystemlink/clients/test_plan/test_plans/models/{_create_test_plans.py => _create_test_plan_body_content.py} (60%) create mode 100644 nisystemlink/clients/test_plan/test_plans/models/_create_test_plans_request.py create mode 100644 nisystemlink/clients/test_plan/test_plans/models/_create_test_plans_response.py delete mode 100644 nisystemlink/clients/test_plan/test_plans/models/_delete_test_plans.py create mode 100644 nisystemlink/clients/test_plan/test_plans/models/_delete_test_plans_request.py rename nisystemlink/clients/test_plan/test_plans/models/{_query_test_plans.py => _query_test_plans_request.py} (60%) create mode 100644 nisystemlink/clients/test_plan/test_plans/models/_query_test_plans_response.py rename nisystemlink/clients/test_plan/test_plans/models/{_schedule_test_plans.py => _schedule_test_plans_body_content.py} (53%) create mode 100644 nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans_request.py create mode 100644 nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans_response.py diff --git a/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py b/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py index 294fe4e6..2713e7ee 100644 --- a/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py +++ b/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py @@ -14,7 +14,6 @@ QueryTestPlansResponse, UpdateTestPlansRequest, UpdateTestPlansResponse, - DeleteTestPlansResponse, DeleteTestPlansRequest, ) @@ -64,7 +63,7 @@ def create_test_plans( ... @post("delete-testplans") - def delete_test_plans(self, ids: DeleteTestPlansRequest) -> DeleteTestPlansResponse: + def delete_test_plans(self, ids: DeleteTestPlansRequest) -> None: """Delete test plans by IDs. Args: @@ -75,7 +74,7 @@ def delete_test_plans(self, ids: DeleteTestPlansRequest) -> DeleteTestPlansRespo """ ... - @post("query-testplans", args=[Field("query")]) + @post("query-testplans") def query_test_plans(self, query: QueryTestPlansRequest) -> QueryTestPlansResponse: """Query test plans. diff --git a/nisystemlink/clients/test_plan/test_plans/models/__init__.py b/nisystemlink/clients/test_plan/test_plans/models/__init__.py index 1afb2b22..a9dcf251 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/__init__.py +++ b/nisystemlink/clients/test_plan/test_plans/models/__init__.py @@ -1,12 +1,13 @@ -from ._create_test_plans import ( - CreateTestPlansRequest, - CreateTestPlanRequestBodyContent, - CreateTestPlansResponse, -) -from ._delete_test_plans import DeleteTestPlansRequest, DeleteTestPlansResponse +from ._create_test_plans_request import CreateTestPlansRequest +from ._create_test_plan_body_content import CreateTestPlanBodyContent +from ._create_test_plans_response import CreateTestPlansResponse +from ._schedule_test_plans_body_content import ScheduleTestPlanBodyContent +from ._schedule_test_plans_response import ScheduleTestPlansResponse +from ._delete_test_plans_request import DeleteTestPlansRequest from ._execution_event import ExecutionEvent -from ._query_test_plans import QueryTestPlansRequest, QueryTestPlansResponse -from ._schedule_test_plans import ScheduleTestPlansRequest, ScheduleTestPlansResponse, ScheduleTestPlanRequestBodyContent +from ._query_test_plans_request import QueryTestPlansRequest +from ._query_test_plans_response import QueryTestPlansResponse +from ._schedule_test_plans_request import ScheduleTestPlansRequest from ._state import State from ._test_plan import TestPlan from ._update_test_plans import UpdateTestPlansRequest, UpdateTestPlansResponse, UpdateTestPlanRequestBodyContent diff --git a/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans.py b/nisystemlink/clients/test_plan/test_plans/models/_create_test_plan_body_content.py similarity index 60% rename from nisystemlink/clients/test_plan/test_plans/models/_create_test_plans.py rename to nisystemlink/clients/test_plan/test_plans/models/_create_test_plan_body_content.py index 763a2881..b616fcad 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_create_test_plan_body_content.py @@ -1,31 +1,29 @@ from typing import Dict, List, Optional -from nisystemlink.clients.core import ApiError from nisystemlink.clients.core._uplink._json_model import JsonModel from ...models._execution_definition import ExecutionDefinition -from ._test_plan import TestPlan class Dashboard(JsonModel): """Represents a dashboard reference.""" - id: str + id: Optional[str] = None """ID of the dashboard""" variables: Optional[Dict[str, str]] = None """Variables for the dashboard""" -class CreateTestPlanRequestBodyContent(JsonModel): +class CreateTestPlanBodyContent(JsonModel): """Represents the request body content for creating a test plan.""" - name: str + name: Optional[str] = None """The name of the test plan.""" templateId: Optional[str] = None """The ID of the template to use for the test plan.""" - state: str + state: Optional[str] = None """The state of the test plan.""" description: Optional[str] = None @@ -43,7 +41,7 @@ class CreateTestPlanRequestBodyContent(JsonModel): properties: Optional[Dict[str, str]] = None """Additional properties for the test plan.""" - partNumber: str + partNumber: Optional[str] = None """The part number associated with the test plan.""" dutId: Optional[str] = None @@ -66,32 +64,3 @@ class CreateTestPlanRequestBodyContent(JsonModel): executionActions: Optional[List[ExecutionDefinition]] = None """List of execution actions for the test plan.""" - - -class CreateTestPlansRequest(JsonModel): - """Represents the request body for creating multiple test plans.""" - - testPlans: List[CreateTestPlanRequestBodyContent] - """ - A list of test plan creation request bodies. Each item in the list contains - the content required to create an individual test plan. - """ - - -class CreateTestPlansResponse(JsonModel): - """ - Represents the response from creating test plans, including successfully created, - failed test plans, and any associated errors. - """ - - testPlans: Optional[List[TestPlan]] = None - """List of all test plans involved in the operation.""" - - createdTestPlans: Optional[List[TestPlan]] = None - """List of test plans that were successfully created.""" - - failedTestPlans: Optional[List[CreateTestPlanRequestBodyContent]] = None - """List of test plans that failed to be created, with their request body content.""" - - error: Optional[ApiError] = None - """Error information if the operation encountered issues.""" diff --git a/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans_request.py b/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans_request.py new file mode 100644 index 00000000..b3341fad --- /dev/null +++ b/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans_request.py @@ -0,0 +1,14 @@ +from typing import List, Optional + +from nisystemlink.clients.core._uplink._json_model import JsonModel +from ._create_test_plan_body_content import CreateTestPlanBodyContent + + +class CreateTestPlansRequest(JsonModel): + """Represents the request body for creating multiple test plans.""" + + testPlans: Optional[List[CreateTestPlanBodyContent]] = None + """ + A list of test plan creation request bodies. Each item in the list contains + the content required to create an individual test plan. + """ \ No newline at end of file diff --git a/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans_response.py b/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans_response.py new file mode 100644 index 00000000..76bae60d --- /dev/null +++ b/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans_response.py @@ -0,0 +1,22 @@ +from typing import List, Optional + +from nisystemlink.clients.core._uplink._json_model import JsonModel + +from ._test_plan import TestPlan +from ._create_test_plan_body_content import CreateTestPlanBodyContent + + +class CreateTestPlansResponse(JsonModel): + """ + Represents the response from creating test plans, including successfully created, + failed test plans, and any associated errors. + """ + + testPlans: Optional[List[TestPlan]] = None + """List of all test plans involved in the operation.""" + + createdTestPlans: Optional[List[TestPlan]] = None + """List of test plans that were successfully created.""" + + failedTestPlans: Optional[List[CreateTestPlanBodyContent]] = None + """List of test plans that failed to be created, with their request body content.""" diff --git a/nisystemlink/clients/test_plan/test_plans/models/_delete_test_plans.py b/nisystemlink/clients/test_plan/test_plans/models/_delete_test_plans.py deleted file mode 100644 index b6cc0f83..00000000 --- a/nisystemlink/clients/test_plan/test_plans/models/_delete_test_plans.py +++ /dev/null @@ -1,25 +0,0 @@ -from typing import List, Optional - -from nisystemlink.clients.core._uplink._json_model import JsonModel - -from nisystemlink.clients.core import ApiError - - -class DeleteTestPlansRequest(JsonModel): - """Represents a request to delete one or more test plans.""" - - ids: List[str] - """List of test plan IDS of test plans to be deleted""" - - -class DeleteTestPlansResponse: - """Response fields for delete test plans operation.""" - - deletedTestPlanIds: Optional[List[str]] = None - """List of test plan IDs that were successfully deleted.""" - - failedTestPlanIds: Optional[List[str]] = None - """List of test plan IDs that failed to be deleted.""" - - error: Optional[ApiError] = None - """Error information if the delete operation encountered issues.""" diff --git a/nisystemlink/clients/test_plan/test_plans/models/_delete_test_plans_request.py b/nisystemlink/clients/test_plan/test_plans/models/_delete_test_plans_request.py new file mode 100644 index 00000000..aef42b7f --- /dev/null +++ b/nisystemlink/clients/test_plan/test_plans/models/_delete_test_plans_request.py @@ -0,0 +1,10 @@ +from typing import List + +from nisystemlink.clients.core._uplink._json_model import JsonModel + + +class DeleteTestPlansRequest(JsonModel): + """Represents a request to delete one or more test plans.""" + + ids: List[str] + """List of test plan IDS of test plans to be deleted""" diff --git a/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans.py b/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans_request.py similarity index 60% rename from nisystemlink/clients/test_plan/test_plans/models/_query_test_plans.py rename to nisystemlink/clients/test_plan/test_plans/models/_query_test_plans_request.py index d29184b9..45620d11 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans_request.py @@ -1,7 +1,6 @@ -from typing import List, Optional +from typing import Optional from nisystemlink.clients.core._uplink._json_model import JsonModel -from ._test_plan import TestPlan class QueryTestPlansRequest(JsonModel): @@ -27,19 +26,3 @@ class QueryTestPlansRequest(JsonModel): continuation_token: Optional[str] = None """A token to retrieve the next page of results for paginated queries.""" - - -class QueryTestPlansResponse(JsonModel): - """ - Represents the response from querying test plans. - Contains a list of test plans, a continuation token for pagination, and the total count. - """ - - test_plans: List[TestPlan] - """A list of test plans returned by the query.""" - - continuation_token: Optional[str] = None - """A token to retrieve the next page of results for paginated queries.""" - - total_count: Optional[int] = None - """The total number of test plans matching the query filter.""" diff --git a/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans_response.py b/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans_response.py new file mode 100644 index 00000000..82d964bc --- /dev/null +++ b/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans_response.py @@ -0,0 +1,20 @@ +from typing import List, Optional + +from nisystemlink.clients.core._uplink._json_model import JsonModel +from ._test_plan import TestPlan + + +class QueryTestPlansResponse(JsonModel): + """ + Represents the response from querying test plans. + Contains a list of test plans, a continuation token for pagination, and the total count. + """ + + test_plans: Optional[List[TestPlan]] + """A list of test plans returned by the query.""" + + continuation_token: Optional[str] = None + """A token to retrieve the next page of results for paginated queries.""" + + total_count: Optional[int] = None + """The total number of test plans matching the query filter.""" diff --git a/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans.py b/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans_body_content.py similarity index 53% rename from nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans.py rename to nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans_body_content.py index 9addf052..f744a190 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans_body_content.py @@ -1,11 +1,9 @@ from typing import List, Optional -from nisystemlink.clients.core import ApiError from nisystemlink.clients.core._uplink._json_model import JsonModel -from ._test_plan import TestPlan -class ScheduleTestPlanRequestBodyContent(JsonModel): +class ScheduleTestPlanBodyContent(JsonModel): """Represents the request body content for scheduling a test plan.""" id: str @@ -31,26 +29,3 @@ class ScheduleTestPlanRequestBodyContent(JsonModel): fixture_ids: Optional[List[str]] = None """(Optional) List of fixture identifiers associated with the test plan.""" - - -class ScheduleTestPlansRequest(JsonModel): - """Represents the request body for scheduling multiple test plans.""" - - test_plans: List[ScheduleTestPlanRequestBodyContent] - """List of test plan scheduling content objects.""" - - replace: Optional[bool] = None - """(Optional) If true, replaces existing scheduled test plans.""" - - -class ScheduleTestPlansResponse(JsonModel): - """Represents the response returned after attempting to schedule one or more test plans.""" - - scheduled_test_plans: Optional[List[TestPlan]] = None - """(Optional) List of successfully scheduled test plans.""" - - failed_test_plans: Optional[List[ScheduleTestPlanRequestBodyContent]] = None - """(Optional) List of test plan requests that failed to schedule.""" - - error: Optional[ApiError] = None - """(Optional) API error information if scheduling failed.""" diff --git a/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans_request.py b/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans_request.py new file mode 100644 index 00000000..557bf2bb --- /dev/null +++ b/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans_request.py @@ -0,0 +1,14 @@ +from typing import List, Optional + +from nisystemlink.clients.core._uplink._json_model import JsonModel +from ._schedule_test_plans_body_content import ScheduleTestPlanBodyContent + + +class ScheduleTestPlansRequest(JsonModel): + """Represents the request body for scheduling multiple test plans.""" + + test_plans: Optional[List[ScheduleTestPlanBodyContent]] + """List of test plan scheduling content objects.""" + + replace: Optional[bool] = None + """(Optional) If true, replaces existing scheduled test plans.""" diff --git a/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans_response.py b/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans_response.py new file mode 100644 index 00000000..8bfc9fc7 --- /dev/null +++ b/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans_response.py @@ -0,0 +1,14 @@ +from typing import List, Optional + +from nisystemlink.clients.core._uplink._json_model import JsonModel +from ._test_plan import TestPlan +from ._schedule_test_plans_body_content import ScheduleTestPlanBodyContent + +class ScheduleTestPlansResponse(JsonModel): + """Represents the response returned after attempting to schedule one or more test plans.""" + + scheduled_test_plans: Optional[List[TestPlan]] = None + """(Optional) List of successfully scheduled test plans.""" + + failed_test_plans: Optional[List[ScheduleTestPlanBodyContent]] = None + """(Optional) List of test plan requests that failed to schedule.""" diff --git a/nisystemlink/clients/test_plan/test_plans/models/_test_plan.py b/nisystemlink/clients/test_plan/test_plans/models/_test_plan.py index 79e95872..68970a4b 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_test_plan.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_test_plan.py @@ -16,10 +16,10 @@ class TestPlan(JsonModel): templateId: Optional[str] = None """The identifier of the template used to create the test plan.""" - name: str + name: Optional[str] = None """The name of the test plan.""" - state: State + state: Optional[State] = None """The current state of the test plan.""" substate: Optional[str] = None @@ -37,25 +37,25 @@ class TestPlan(JsonModel): workOrderName: Optional[str] = None """The name of the associated work order.""" - workspace: str + workspace: Optional[str] = None """The workspace to which the test plan belongs.""" - createdBy: str + createdBy: Optional[str] = None """The user who created the test plan.""" - updatedBy: str + updatedBy: Optional[str] = None """The user who last updated the test plan.""" - createdAt: str + createdAt: Optional[str] = None """The date and time when the test plan was created.""" - updatedAt: str + updatedAt: Optional[str] = None """The date and time when the test plan was last updated.""" - properties: Dict[str, str] + properties: Optional[Dict[str, str]] = None """Additional properties associated with the test plan.""" - partNumber: str + partNumber: Optional[str] = None """The part number associated with the test plan.""" dutId: Optional[str] = None @@ -67,7 +67,7 @@ class TestPlan(JsonModel): systemId: Optional[str] = None """The identifier of the system used for the test plan.""" - fixtureIds: List[str] = None + fixtureIds: Optional[List[str]] = None """The list of fixture identifiers associated with the test plan.""" systemFilter: Optional[str] = None @@ -82,7 +82,7 @@ class TestPlan(JsonModel): estimatedDurationInSeconds: Optional[float] = None """The estimated duration of the test plan in seconds.""" - fileIdsFromTemplate: List[str] + fileIdsFromTemplate: Optional[List[str]] = None """The list of file identifiers inherited from the template.""" # executionActions: Optional[ExecutionDefinition] = None @@ -91,11 +91,11 @@ class TestPlan(JsonModel): # executionHistory: Optional[ExecutionEvent] = None """The execution history of the test plan.""" - dashboardUrl: Optional[Dict[str, str]] = None + # dashboardUrl: Optional[Dict[str, str]] = None """The URLs for dashboards related to the test plan.""" - dashboard: Optional[Dict[str, str]] = None + # dashboard: Optional[Dict[str, str]] = None """The dashboard data related to the test plan.""" - workflow: WorkflowDefinition + workflow: Optional[WorkflowDefinition] = None """The workflow definition associated with the test plan.""" diff --git a/tests/integration/test_plan/test_plans/test_test_plans.py b/tests/integration/test_plan/test_plans/test_test_plans.py index b20850ef..486e659e 100644 --- a/tests/integration/test_plan/test_plans/test_test_plans.py +++ b/tests/integration/test_plan/test_plans/test_test_plans.py @@ -4,7 +4,7 @@ from nisystemlink.clients.core._http_configuration import HttpConfiguration from nisystemlink.clients.test_plan.test_plans import TestPlansClient from nisystemlink.clients.test_plan.test_plans.models import ( - CreateTestPlanRequestBodyContent, + CreateTestPlanBodyContent, CreateTestPlansRequest, CreateTestPlansResponse, DeleteTestPlansRequest, @@ -13,10 +13,8 @@ UpdateTestPlansRequest, UpdateTestPlanRequestBodyContent, ScheduleTestPlansRequest, - ScheduleTestPlansResponse, - ScheduleTestPlanRequestBodyContent, + ScheduleTestPlanBodyContent, QueryTestPlansRequest, - QueryTestPlansResponse ) @@ -26,8 +24,8 @@ def test_plan_create() -> CreateTestPlansRequest: testPlan = CreateTestPlansRequest( testPlans=[ - CreateTestPlanRequestBodyContent( - name="Sample Test Plan", state="NEW", partNumber="px40482" + CreateTestPlanBodyContent( + name="Python integration test plan", state="NEW", partNumber="px40482" ) ] ) @@ -50,14 +48,18 @@ def test__create_and_delete_test_plan__returns_created_and_deleted_test_plans( create_test_plan_response: CreateTestPlansResponse = client.create_test_plans(testplans=test_plan_create) created_test_plan = create_test_plan_response.createdTestPlans[0] + get_test_plan_response: TestPlan = client.get_test_plan(created_test_plan.id) + delete_test_plan_request = DeleteTestPlansRequest(ids=[created_test_plan.id]) - delete_test_plan_response = client.delete_test_plans(ids=delete_test_plan_request) + client.delete_test_plans(ids=delete_test_plan_request) assert created_test_plan is not None - assert created_test_plan.name == "Sample Test Plan" + assert created_test_plan.name == "Python integration test plan" assert created_test_plan.state == State.New assert created_test_plan.partNumber == "px40482" - assert created_test_plan.id == delete_test_plan_response.deletedTestPlanIds[0] + assert get_test_plan_response is not None + assert get_test_plan_response.name == "Python integration test plan" + def test__get_test_plan__returns_get_test_plan( self, client: TestPlansClient, test_plan_create: CreateTestPlansRequest @@ -106,7 +108,7 @@ def test__schedule_test_plan__returns_scheduled_test_plan( schedule_request = ScheduleTestPlansRequest( test_plans=[ - ScheduleTestPlanRequestBodyContent( + ScheduleTestPlanBodyContent( id=created_test_plan.id, planned_start_date_time="2025-05-20T15:07:42.527Z", estimated_end_date_time="2025-05-20T15:07:42.527Z", @@ -132,7 +134,7 @@ def test__query_test_plans__return_queried_test_plan( created_test_plan = create_test_plan_response.createdTestPlans[0] query_test_plans_request = QueryTestPlansRequest( - filter = "id == {created_test_plan.id}", + filter = f'id = "{created_test_plan.id}"', return_count = True ) queried_test_plans_response = client.query_test_plans(query = query_test_plans_request) From 1b4b88c8fb48e108a5a3a315aab9968cf0ff32ca Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Tue, 20 May 2025 19:56:17 +0530 Subject: [PATCH 23/64] update lint --- .../test_plan/models/_execution_definition.py | 2 +- .../test_plans/_test_plans_client.py | 15 ++--- .../test_plan/test_plans/models/__init__.py | 4 +- .../models/_create_test_plan_body_content.py | 1 + .../models/_create_test_plans_request.py | 5 +- .../models/_create_test_plans_response.py | 5 +- .../test_plans/models/_execution_event.py | 9 +-- .../models/_query_test_plans_request.py | 3 +- .../models/_query_test_plans_response.py | 4 +- .../models/_schedule_test_plans_request.py | 1 + .../models/_schedule_test_plans_response.py | 4 +- .../test_plan/test_plans/models/_test_plan.py | 13 +++-- ....py => _update_test_plans_body_content.py} | 29 +--------- .../models/_update_test_plans_request.py | 15 +++++ .../models/_update_test_plans_response.py | 19 ++++++ .../test_plans/models/_workflow_definition.py | 1 + tests/integration/test_plan/__init__.py | 1 + .../test_plan/test_plans/test_test_plans.py | 58 +++++++++++-------- 18 files changed, 110 insertions(+), 79 deletions(-) rename nisystemlink/clients/test_plan/test_plans/models/{_update_test_plans.py => _update_test_plans_body_content.py} (58%) create mode 100644 nisystemlink/clients/test_plan/test_plans/models/_update_test_plans_request.py create mode 100644 nisystemlink/clients/test_plan/test_plans/models/_update_test_plans_response.py diff --git a/nisystemlink/clients/test_plan/models/_execution_definition.py b/nisystemlink/clients/test_plan/models/_execution_definition.py index 84239902..a979ef87 100644 --- a/nisystemlink/clients/test_plan/models/_execution_definition.py +++ b/nisystemlink/clients/test_plan/models/_execution_definition.py @@ -59,7 +59,7 @@ class JobExecutionDefinition(JsonModel): jobs: list[Job] """List of jobs to execute""" - systemId: Optional[str] = None + systemId: Optional[str] = None """Optional system ID where jobs will run""" diff --git a/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py b/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py index 2713e7ee..31b2f02b 100644 --- a/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py +++ b/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py @@ -1,20 +1,21 @@ -from uplink import Field from typing import Optional -from nisystemlink.clients.core._uplink._base_client import BaseClient + +from nisystemlink.clients import core from nisystemlink.clients.core._http_configuration import HttpConfiguration +from nisystemlink.clients.core._uplink._base_client import BaseClient from nisystemlink.clients.core._uplink._methods import get, post -from nisystemlink.clients import core + from .models import ( - TestPlan, CreateTestPlansRequest, CreateTestPlansResponse, - ScheduleTestPlansRequest, - ScheduleTestPlansResponse, + DeleteTestPlansRequest, QueryTestPlansRequest, QueryTestPlansResponse, + ScheduleTestPlansRequest, + ScheduleTestPlansResponse, + TestPlan, UpdateTestPlansRequest, UpdateTestPlansResponse, - DeleteTestPlansRequest, ) diff --git a/nisystemlink/clients/test_plan/test_plans/models/__init__.py b/nisystemlink/clients/test_plan/test_plans/models/__init__.py index a9dcf251..cbd08a84 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/__init__.py +++ b/nisystemlink/clients/test_plan/test_plans/models/__init__.py @@ -10,7 +10,9 @@ from ._schedule_test_plans_request import ScheduleTestPlansRequest from ._state import State from ._test_plan import TestPlan -from ._update_test_plans import UpdateTestPlansRequest, UpdateTestPlansResponse, UpdateTestPlanRequestBodyContent +from ._update_test_plans_body_content import UpdateTestPlanBodyContent +from ._update_test_plans_request import UpdateTestPlansRequest +from ._update_test_plans_response import UpdateTestPlansResponse from ._workflow_definition import WorkflowDefinition # flake8: noqa diff --git a/nisystemlink/clients/test_plan/test_plans/models/_create_test_plan_body_content.py b/nisystemlink/clients/test_plan/test_plans/models/_create_test_plan_body_content.py index b616fcad..db82e889 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_create_test_plan_body_content.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_create_test_plan_body_content.py @@ -1,6 +1,7 @@ from typing import Dict, List, Optional from nisystemlink.clients.core._uplink._json_model import JsonModel + from ...models._execution_definition import ExecutionDefinition diff --git a/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans_request.py b/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans_request.py index b3341fad..099cc6a8 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans_request.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans_request.py @@ -1,6 +1,7 @@ from typing import List, Optional from nisystemlink.clients.core._uplink._json_model import JsonModel + from ._create_test_plan_body_content import CreateTestPlanBodyContent @@ -9,6 +10,6 @@ class CreateTestPlansRequest(JsonModel): testPlans: Optional[List[CreateTestPlanBodyContent]] = None """ - A list of test plan creation request bodies. Each item in the list contains + A list of test plan creation request bodies. Each item in the list contains the content required to create an individual test plan. - """ \ No newline at end of file + """ diff --git a/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans_response.py b/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans_response.py index 76bae60d..5cc5bec8 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans_response.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans_response.py @@ -2,13 +2,12 @@ from nisystemlink.clients.core._uplink._json_model import JsonModel -from ._test_plan import TestPlan from ._create_test_plan_body_content import CreateTestPlanBodyContent +from ._test_plan import TestPlan class CreateTestPlansResponse(JsonModel): - """ - Represents the response from creating test plans, including successfully created, + """Represents the response from creating test plans, including successfully created, failed test plans, and any associated errors. """ diff --git a/nisystemlink/clients/test_plan/test_plans/models/_execution_event.py b/nisystemlink/clients/test_plan/test_plans/models/_execution_event.py index 95c21e0b..d14ef731 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_execution_event.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_execution_event.py @@ -1,15 +1,16 @@ -from typing import List, Union, Optional +from typing import List, Optional, Union from nisystemlink.clients.core._uplink._json_model import JsonModel + class ExecutionEventBase(JsonModel): - action: str + action: Optional[str] = None """Base class for execution events, containing common attributes such as action.""" - triggeredAt: str + triggeredAt: Optional[str] = None """the time the event was triggered.""" - triggeredBy: str = None + triggeredBy: Optional[str] = None """and the user who triggered it.""" diff --git a/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans_request.py b/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans_request.py index 45620d11..f792829d 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans_request.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans_request.py @@ -4,8 +4,7 @@ class QueryTestPlansRequest(JsonModel): - """ - Represents the request body for querying test plans. + """Represents the request body for querying test plans. Allows filtering, sorting, and pagination of test plan results. """ diff --git a/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans_response.py b/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans_response.py index 82d964bc..13400aad 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans_response.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans_response.py @@ -1,12 +1,12 @@ from typing import List, Optional from nisystemlink.clients.core._uplink._json_model import JsonModel + from ._test_plan import TestPlan class QueryTestPlansResponse(JsonModel): - """ - Represents the response from querying test plans. + """Represents the response from querying test plans. Contains a list of test plans, a continuation token for pagination, and the total count. """ diff --git a/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans_request.py b/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans_request.py index 557bf2bb..aa62ee8a 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans_request.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans_request.py @@ -1,6 +1,7 @@ from typing import List, Optional from nisystemlink.clients.core._uplink._json_model import JsonModel + from ._schedule_test_plans_body_content import ScheduleTestPlanBodyContent diff --git a/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans_response.py b/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans_response.py index 8bfc9fc7..4bec5ca3 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans_response.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans_response.py @@ -1,8 +1,10 @@ from typing import List, Optional from nisystemlink.clients.core._uplink._json_model import JsonModel -from ._test_plan import TestPlan + from ._schedule_test_plans_body_content import ScheduleTestPlanBodyContent +from ._test_plan import TestPlan + class ScheduleTestPlansResponse(JsonModel): """Represents the response returned after attempting to schedule one or more test plans.""" diff --git a/nisystemlink/clients/test_plan/test_plans/models/_test_plan.py b/nisystemlink/clients/test_plan/test_plans/models/_test_plan.py index 68970a4b..f49ca87a 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_test_plan.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_test_plan.py @@ -1,9 +1,10 @@ -from typing import Optional, Dict, List +from typing import Dict, List, Optional from nisystemlink.clients.core._uplink._json_model import JsonModel + +from ._execution_event import ExecutionEvent from ._state import State from ._workflow_definition import WorkflowDefinition -from ._execution_event import ExecutionEvent from ...models._execution_definition import ExecutionDefinition @@ -85,16 +86,16 @@ class TestPlan(JsonModel): fileIdsFromTemplate: Optional[List[str]] = None """The list of file identifiers inherited from the template.""" - # executionActions: Optional[ExecutionDefinition] = None + executionActions: Optional[List[ExecutionDefinition]] = None """The execution actions defined for the test plan.""" - # executionHistory: Optional[ExecutionEvent] = None + executionHistory: Optional[List[ExecutionEvent]] = None """The execution history of the test plan.""" - # dashboardUrl: Optional[Dict[str, str]] = None + dashboardUrl: Optional[Dict[str, str]] = None """The URLs for dashboards related to the test plan.""" - # dashboard: Optional[Dict[str, str]] = None + dashboard: Optional[Dict[str, str]] = None """The dashboard data related to the test plan.""" workflow: Optional[WorkflowDefinition] = None diff --git a/nisystemlink/clients/test_plan/test_plans/models/_update_test_plans.py b/nisystemlink/clients/test_plan/test_plans/models/_update_test_plans_body_content.py similarity index 58% rename from nisystemlink/clients/test_plan/test_plans/models/_update_test_plans.py rename to nisystemlink/clients/test_plan/test_plans/models/_update_test_plans_body_content.py index d0ba9a92..92d8efd5 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_update_test_plans.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_update_test_plans_body_content.py @@ -1,11 +1,9 @@ -from typing import List, Optional, Dict, Union +from typing import Dict, List, Optional, Union from nisystemlink.clients.core._uplink._json_model import JsonModel -from nisystemlink.clients.core import ApiError -from . import TestPlan -class UpdateTestPlanRequestBodyContent(JsonModel): +class UpdateTestPlanBodyContent(JsonModel): """Represents the content for updating a single test plan.""" id: str @@ -43,26 +41,3 @@ class UpdateTestPlanRequestBodyContent(JsonModel): file_ids_from_template: Optional[List[str]] = None """List of file IDs from the template to associate with the test plan.""" - - -class UpdateTestPlansRequest(JsonModel): - """Represents the request body for updating multiple test plans.""" - - test_plans: List[UpdateTestPlanRequestBodyContent] - """A list of test plans to update.""" - - replace: Optional[bool] = None - """Whether to replace the existing test plans or update them.""" - - -class UpdateTestPlansResponse(JsonModel): - """Represents the response after attempting to update test plans.""" - - updated_test_plans: Optional[List[TestPlan]] = None - """List of successfully updated test plans.""" - - failed_test_plans: Optional[List[UpdateTestPlanRequestBodyContent]] = None - """List of test plans that failed to update.""" - - error: Optional[ApiError] = None - """Error information if the update operation failed.""" diff --git a/nisystemlink/clients/test_plan/test_plans/models/_update_test_plans_request.py b/nisystemlink/clients/test_plan/test_plans/models/_update_test_plans_request.py new file mode 100644 index 00000000..b9a9abf9 --- /dev/null +++ b/nisystemlink/clients/test_plan/test_plans/models/_update_test_plans_request.py @@ -0,0 +1,15 @@ +from typing import List, Optional + +from nisystemlink.clients.core._uplink._json_model import JsonModel + +from . import UpdateTestPlanBodyContent + + +class UpdateTestPlansRequest(JsonModel): + """Represents the request body for updating multiple test plans.""" + + test_plans: List[UpdateTestPlanBodyContent] + """A list of test plans to update.""" + + replace: Optional[bool] = None + """Whether to replace the existing test plans or update them.""" diff --git a/nisystemlink/clients/test_plan/test_plans/models/_update_test_plans_response.py b/nisystemlink/clients/test_plan/test_plans/models/_update_test_plans_response.py new file mode 100644 index 00000000..9b337ddc --- /dev/null +++ b/nisystemlink/clients/test_plan/test_plans/models/_update_test_plans_response.py @@ -0,0 +1,19 @@ +from typing import List, Optional + +from nisystemlink.clients.core import ApiError +from nisystemlink.clients.core._uplink._json_model import JsonModel + +from . import TestPlan, UpdateTestPlanBodyContent + + +class UpdateTestPlansResponse(JsonModel): + """Represents the response after attempting to update test plans.""" + + updated_test_plans: Optional[List[TestPlan]] = None + """List of successfully updated test plans.""" + + failed_test_plans: Optional[List[UpdateTestPlanBodyContent]] = None + """List of test plans that failed to update.""" + + error: Optional[ApiError] = None + """Error information if the update operation failed.""" diff --git a/nisystemlink/clients/test_plan/test_plans/models/_workflow_definition.py b/nisystemlink/clients/test_plan/test_plans/models/_workflow_definition.py index 0e081b0d..4952018e 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_workflow_definition.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_workflow_definition.py @@ -1,4 +1,5 @@ from nisystemlink.clients.core._uplink._json_model import JsonModel + from ._state import State from ...models._execution_definition import ExecutionDefinition diff --git a/tests/integration/test_plan/__init__.py b/tests/integration/test_plan/__init__.py index e69de29b..9c0fa90a 100644 --- a/tests/integration/test_plan/__init__.py +++ b/tests/integration/test_plan/__init__.py @@ -0,0 +1 @@ +# flake8: noqa diff --git a/tests/integration/test_plan/test_plans/test_test_plans.py b/tests/integration/test_plan/test_plans/test_test_plans.py index 486e659e..e1511251 100644 --- a/tests/integration/test_plan/test_plans/test_test_plans.py +++ b/tests/integration/test_plan/test_plans/test_test_plans.py @@ -1,6 +1,4 @@ import pytest -from typing import List - from nisystemlink.clients.core._http_configuration import HttpConfiguration from nisystemlink.clients.test_plan.test_plans import TestPlansClient from nisystemlink.clients.test_plan.test_plans.models import ( @@ -8,20 +6,19 @@ CreateTestPlansRequest, CreateTestPlansResponse, DeleteTestPlansRequest, + QueryTestPlansRequest, + ScheduleTestPlanBodyContent, + ScheduleTestPlansRequest, State, TestPlan, + UpdateTestPlanBodyContent, UpdateTestPlansRequest, - UpdateTestPlanRequestBodyContent, - ScheduleTestPlansRequest, - ScheduleTestPlanBodyContent, - QueryTestPlansRequest, ) @pytest.fixture(scope="class") def test_plan_create() -> CreateTestPlansRequest: """Fixture to create create test plan object.""" - testPlan = CreateTestPlansRequest( testPlans=[ CreateTestPlanBodyContent( @@ -45,7 +42,9 @@ class TestTestPlans: def test__create_and_delete_test_plan__returns_created_and_deleted_test_plans( self, client: TestPlansClient, test_plan_create: CreateTestPlansRequest ): - create_test_plan_response: CreateTestPlansResponse = client.create_test_plans(testplans=test_plan_create) + create_test_plan_response: CreateTestPlansResponse = client.create_test_plans( + testplans=test_plan_create + ) created_test_plan = create_test_plan_response.createdTestPlans[0] get_test_plan_response: TestPlan = client.get_test_plan(created_test_plan.id) @@ -60,16 +59,19 @@ def test__create_and_delete_test_plan__returns_created_and_deleted_test_plans( assert get_test_plan_response is not None assert get_test_plan_response.name == "Python integration test plan" - def test__get_test_plan__returns_get_test_plan( self, client: TestPlansClient, test_plan_create: CreateTestPlansRequest ): - create_test_plan_response: CreateTestPlansResponse = client.create_test_plans(testplans=test_plan_create) + create_test_plan_response: CreateTestPlansResponse = client.create_test_plans( + testplans=test_plan_create + ) created_test_plan = create_test_plan_response.createdTestPlans[0] get_test_plan_response: TestPlan = client.get_test_plan(created_test_plan.id) - delete_request = DeleteTestPlansRequest(ids=[create_test_plan_response.createdTestPlans[0].id]) + delete_request = DeleteTestPlansRequest( + ids=[create_test_plan_response.createdTestPlans[0].id] + ) client.delete_test_plans(ids=delete_request) assert get_test_plan_response is not None @@ -79,20 +81,24 @@ def test__get_test_plan__returns_get_test_plan( def test__update_test_plan__returns_updated_test_plan( self, client: TestPlansClient, test_plan_create: CreateTestPlansRequest ): - create_test_plan_response: CreateTestPlansResponse = client.create_test_plans(testplans=test_plan_create) + create_test_plan_response: CreateTestPlansResponse = client.create_test_plans( + testplans=test_plan_create + ) created_test_plan = create_test_plan_response.createdTestPlans[0] update_request = UpdateTestPlansRequest( testPlans=[ - UpdateTestPlanRequestBodyContent( + UpdateTestPlanBodyContent( id=created_test_plan.id, - name= "Updated Test Plan", + name="Updated Test Plan", ) ] ) update_test_plan_response = client.update_test_plan(test_plans=update_request) - delete_request = DeleteTestPlansRequest(ids=[create_test_plan_response.createdTestPlans[0].id]) + delete_request = DeleteTestPlansRequest( + ids=[create_test_plan_response.createdTestPlans[0].id] + ) client.delete_test_plans(ids=delete_request) assert update_test_plan_response is not None @@ -103,7 +109,9 @@ def test__update_test_plan__returns_updated_test_plan( def test__schedule_test_plan__returns_scheduled_test_plan( self, client: TestPlansClient, test_plan_create: CreateTestPlansRequest ): - create_test_plan_response: CreateTestPlansResponse = client.create_test_plans(testplans=test_plan_create) + create_test_plan_response: CreateTestPlansResponse = client.create_test_plans( + testplans=test_plan_create + ) created_test_plan = create_test_plan_response.createdTestPlans[0] schedule_request = ScheduleTestPlansRequest( @@ -112,11 +120,13 @@ def test__schedule_test_plan__returns_scheduled_test_plan( id=created_test_plan.id, planned_start_date_time="2025-05-20T15:07:42.527Z", estimated_end_date_time="2025-05-20T15:07:42.527Z", - system_id="fake-system" + system_id="fake-system", ) ] ) - schedule_test_plan_response = client.schedule_test_plan(schedule=schedule_request) + schedule_test_plan_response = client.schedule_test_plan( + schedule=schedule_request + ) delete_request = DeleteTestPlansRequest(ids=[created_test_plan.id]) client.delete_test_plans(ids=delete_request) @@ -130,14 +140,17 @@ def test__schedule_test_plan__returns_scheduled_test_plan( def test__query_test_plans__return_queried_test_plan( self, client: TestPlansClient, test_plan_create: CreateTestPlansRequest ): - create_test_plan_response: CreateTestPlansResponse = client.create_test_plans(testplans=test_plan_create) + create_test_plan_response: CreateTestPlansResponse = client.create_test_plans( + testplans=test_plan_create + ) created_test_plan = create_test_plan_response.createdTestPlans[0] query_test_plans_request = QueryTestPlansRequest( - filter = f'id = "{created_test_plan.id}"', - return_count = True + filter=f'id = "{created_test_plan.id}"', return_count=True + ) + queried_test_plans_response = client.query_test_plans( + query=query_test_plans_request ) - queried_test_plans_response = client.query_test_plans(query = query_test_plans_request) delete_request = DeleteTestPlansRequest(ids=[created_test_plan.id]) client.delete_test_plans(ids=delete_request) @@ -145,4 +158,3 @@ def test__query_test_plans__return_queried_test_plan( assert queried_test_plans_response is not None assert queried_test_plans_response.test_plans[0].id == created_test_plan.id assert queried_test_plans_response.total_count > 0 - From 3a635240b3cfa6b414d5e1beff6556be0dc0047f Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Tue, 20 May 2025 20:15:29 +0530 Subject: [PATCH 24/64] add query projection --- .../test_plan/test_plans/models/__init__.py | 2 +- .../models/_query_test_plans_request.py | 73 ++++++++++++++++++- .../test_plan/test_plans/test_test_plans.py | 44 +++++++++++ 3 files changed, 117 insertions(+), 2 deletions(-) diff --git a/nisystemlink/clients/test_plan/test_plans/models/__init__.py b/nisystemlink/clients/test_plan/test_plans/models/__init__.py index cbd08a84..b314a066 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/__init__.py +++ b/nisystemlink/clients/test_plan/test_plans/models/__init__.py @@ -5,7 +5,7 @@ from ._schedule_test_plans_response import ScheduleTestPlansResponse from ._delete_test_plans_request import DeleteTestPlansRequest from ._execution_event import ExecutionEvent -from ._query_test_plans_request import QueryTestPlansRequest +from ._query_test_plans_request import QueryTestPlansRequest, TestPlanField from ._query_test_plans_response import QueryTestPlansResponse from ._schedule_test_plans_request import ScheduleTestPlansRequest from ._state import State diff --git a/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans_request.py b/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans_request.py index f792829d..18ffef8c 100644 --- a/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans_request.py +++ b/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans_request.py @@ -1,8 +1,44 @@ -from typing import Optional +from enum import Enum +from typing import List, Optional from nisystemlink.clients.core._uplink._json_model import JsonModel +class TestPlanField(str, Enum): + """Model for an object describing an test plan with all of its properties.""" + + ID = "id" + TEMPLATE_ID = "templateId" + NAME = "name" + STATE = "state" + SUBSTATE = "substate" + DESCRIPTION = "description" + ASSIGNED_TO = "assignedTo" + WORK_ORDER_ID = "workOrderId" + WORK_ORDER_NAME = "workOrderName" + WORKSPACE = "workspace" + CREATED_BY = "createdBy" + UPDATED_BY = "updatedBy" + CREATED_AT = "createdAt" + UPDATED_AT = "updatedAt" + PROPERTIES = "properties" + PART_NUMBER = "partNumber" + DUT_ID = "dutId" + TEST_PROGRAM = "testProgram" + SYSTEM_ID = "systemId" + FIXTURE_IDS = "fixtureIds" + SYSTEM_FILTER = "systemFilter" + PLANNED_START_DATE_TIME = "plannedStartDateTime" + ESTIMATED_END_DATE_TIME = "estimatedEndDateTime" + ESTIMATED_DURATION_IN_SECONDS = "estimatedDurationInSeconds" + FILE_IDS_FROM_TEMPLATE = "fileIdsFromTemplate" + EXECUTION_ACTIONS = "executionActions" + EXECUTION_HISTORY = "executionHistory" + DASHBOARD_URL = "dashboardUrl" + DASHBOARD = "dashboard" + WORKFLOW = "workflow" + + class QueryTestPlansRequest(JsonModel): """Represents the request body for querying test plans. Allows filtering, sorting, and pagination of test plan results. @@ -25,3 +61,38 @@ class QueryTestPlansRequest(JsonModel): continuation_token: Optional[str] = None """A token to retrieve the next page of results for paginated queries.""" + + projection: List[TestPlanField] = [] + """ + Gets or sets the projection to be used when retrieving the assets. If not specified, + all properties will be returned. + """ + + +class _QueryTestPlansRequest(JsonModel): + """Represents the request body for querying test plans. + Allows filtering, sorting, and pagination of test plan results. + """ + + filter: Optional[str] = None + """A string expression to filter the test plans returned by the query.""" + + take: Optional[int] = None + """The maximum number of test plans to return in the response.""" + + order_by: Optional[str] = None + """The field name to use for sorting the test plans.""" + + descending: Optional[bool] = None + """Whether to sort the test plans in descending order.""" + + return_count: Optional[bool] = None + """Whether to include the total count of matching test plans in the response.""" + + continuation_token: Optional[str] = None + """A token to retrieve the next page of results for paginated queries.""" + + projection: Optional[str] = None + """Gets or sets the projection to be used when retrieving the assets. If not specified, + all properties will be returned. + """ diff --git a/tests/integration/test_plan/test_plans/test_test_plans.py b/tests/integration/test_plan/test_plans/test_test_plans.py index e1511251..da3fc30c 100644 --- a/tests/integration/test_plan/test_plans/test_test_plans.py +++ b/tests/integration/test_plan/test_plans/test_test_plans.py @@ -11,6 +11,7 @@ ScheduleTestPlansRequest, State, TestPlan, + TestPlanField, UpdateTestPlanBodyContent, UpdateTestPlansRequest, ) @@ -158,3 +159,46 @@ def test__query_test_plans__return_queried_test_plan( assert queried_test_plans_response is not None assert queried_test_plans_response.test_plans[0].id == created_test_plan.id assert queried_test_plans_response.total_count > 0 + + def test__query_test_plans_with_projections__returns_the_test_plans_with_projected_properties( + self, client: TestPlansClient, test_plan_create: CreateTestPlansRequest + ): + query_test_plans_request = QueryTestPlansRequest( + projection=[TestPlanField.ID, TestPlanField.NAME] + ) + response = client.query_test_plans(query=query_test_plans_request) + + assert response is not None + assert all( + test_plan.id is not None + and test_plan.name is not None + and test_plan.templateId is None + and test_plan.state is None + and test_plan.substate is None + and test_plan.description is None + and test_plan.assignedTo is None + and test_plan.workOrderId is None + and test_plan.workOrderName is None + and test_plan.workspace is None + and test_plan.createdBy is None + and test_plan.updatedBy is None + and test_plan.createdAt is None + and test_plan.updatedAt is None + and test_plan.properties is None + and test_plan.partNumber is None + and test_plan.dutId is None + and test_plan.testProgram is None + and test_plan.systemId is None + and test_plan.fixtureIds is None + and test_plan.systemFilter is None + and test_plan.plannedStartDateTime is None + and test_plan.estimatedEndDateTime is None + and test_plan.estimatedDurationInSeconds is None + and test_plan.fileIdsFromTemplate is None + and test_plan.executionActions is None + and test_plan.executionHistory is None + and test_plan.dashboardUrl is None + and test_plan.dashboard is None + and test_plan.workflow is None + for test_plan in response.test_plans + ) From 197750872ce710b6f0466b9be775bf964833cbeb Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Tue, 20 May 2025 20:20:08 +0530 Subject: [PATCH 25/64] fix lint --- nisystemlink/clients/test_plan/__init__.py | 1 + .../clients/test_plan/models/__init__.py | 4 +- .../test_plan/models/_execution_definition.py | 57 +++++++++---------- .../test_plan/test_plan_templates/__init__.py | 1 + .../test_plan_templates/models/__init__.py | 1 + tests/integration/test_plan/__init__.py | 1 + .../test_plan/test_plan_templates/__init__.py | 1 + 7 files changed, 36 insertions(+), 30 deletions(-) diff --git a/nisystemlink/clients/test_plan/__init__.py b/nisystemlink/clients/test_plan/__init__.py index e69de29b..a517c684 100644 --- a/nisystemlink/clients/test_plan/__init__.py +++ b/nisystemlink/clients/test_plan/__init__.py @@ -0,0 +1 @@ +# flake8: noqa \ No newline at end of file diff --git a/nisystemlink/clients/test_plan/models/__init__.py b/nisystemlink/clients/test_plan/models/__init__.py index a67830a7..322ab4f3 100644 --- a/nisystemlink/clients/test_plan/models/__init__.py +++ b/nisystemlink/clients/test_plan/models/__init__.py @@ -1 +1,3 @@ -from ._execution_definition import ExecutionDefinition \ No newline at end of file +from ._execution_definition import ExecutionDefinition + +# flake8: noqa \ No newline at end of file diff --git a/nisystemlink/clients/test_plan/models/_execution_definition.py b/nisystemlink/clients/test_plan/models/_execution_definition.py index 853c453f..e3b24dc7 100644 --- a/nisystemlink/clients/test_plan/models/_execution_definition.py +++ b/nisystemlink/clients/test_plan/models/_execution_definition.py @@ -1,10 +1,11 @@ from typing import Union from nisystemlink.clients.core._uplink._json_model import JsonModel + + class Job(JsonModel): - """ - Represents a job to be executed, including its functions, arguments, and metadata. - """ + """Represents a job to be executed, including its functions, arguments, and metadata.""" + functions: list[str] """List of function names to execute""" @@ -14,14 +15,14 @@ class Job(JsonModel): metadata: dict[str, object] """Additional metadata for the job""" + class NotebookExecutionDefinition(JsonModel): - """ - Defines the execution of a notebook. - """ + """Defines the execution of a notebook.""" + action: str """User defined action to perform in workflow (user defined)""" - type: str = 'NOTEBOOK' + type: str = "NOTEBOOK" """Type of execution, default is 'NOTEBOOK'""" notebookId: str @@ -29,23 +30,22 @@ class NotebookExecutionDefinition(JsonModel): class ManualExecutionDefinition(JsonModel): - """ - Represents a manual execution definition. - """ + """Represents a manual execution definition.""" + action: str """User defined action to perform in workflow (user defined)""" - type: str = 'MANUAL' + type: str = "MANUAL" """Type of execution, default is 'MANUAL'""" + class JobExecutionDefinition(JsonModel): - """ - Defines the execution of one or more jobs. - """ + """Defines the execution of one or more jobs.""" + action: str """User defined action to perform in workflow (user defined)""" - type: str = 'JOB' + type: str = "JOB" """Type of execution, default is 'JOB'""" jobs: list[Job] @@ -56,41 +56,40 @@ class JobExecutionDefinition(JsonModel): class ScheduleExecutionDefinition(JsonModel): - """ - Represents a scheduled execution definition. - """ + """Represents a scheduled execution definition.""" + action: str """User defined action to perform in workflow (user defined)""" - type: str = 'SCHEDULE' + type: str = "SCHEDULE" """Type of execution, default is 'SCHEDULE'""" class UnscheduleExecutionDefinition(JsonModel): - """ - Represents an unscheduled execution definition. - """ + """Represents an unscheduled execution definition.""" + action: str """User defined action to perform in workflow (user defined)""" - type: str = 'UNSCHEDULE' + type: str = "UNSCHEDULE" """Type of execution, default is 'UNSCHEDULE'""" + class NoneExecutionDefinition(JsonModel): - """ - Represents a definition where no execution is specified. - """ + """Represents a definition where no execution is specified.""" + action: str """User defined action to perform in workflow (user defined)""" - type: str = 'None' + type: str = "None" """Type of execution, default is 'None'""" + ExecutionDefinition = Union[ NotebookExecutionDefinition, ManualExecutionDefinition, JobExecutionDefinition, NoneExecutionDefinition, ScheduleExecutionDefinition, - UnscheduleExecutionDefinition -] \ No newline at end of file + UnscheduleExecutionDefinition, +] diff --git a/nisystemlink/clients/test_plan/test_plan_templates/__init__.py b/nisystemlink/clients/test_plan/test_plan_templates/__init__.py index e69de29b..a517c684 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/__init__.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/__init__.py @@ -0,0 +1 @@ +# flake8: noqa \ No newline at end of file diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py b/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py index e69de29b..a517c684 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py @@ -0,0 +1 @@ +# flake8: noqa \ No newline at end of file diff --git a/tests/integration/test_plan/__init__.py b/tests/integration/test_plan/__init__.py index e69de29b..a517c684 100644 --- a/tests/integration/test_plan/__init__.py +++ b/tests/integration/test_plan/__init__.py @@ -0,0 +1 @@ +# flake8: noqa \ No newline at end of file diff --git a/tests/integration/test_plan/test_plan_templates/__init__.py b/tests/integration/test_plan/test_plan_templates/__init__.py index e69de29b..a517c684 100644 --- a/tests/integration/test_plan/test_plan_templates/__init__.py +++ b/tests/integration/test_plan/test_plan_templates/__init__.py @@ -0,0 +1 @@ +# flake8: noqa \ No newline at end of file From bae388d82642b34dca42357d01b958c69536eb6f Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Tue, 20 May 2025 20:58:13 +0530 Subject: [PATCH 26/64] add query projection --- .../test_plan_templates.py | 57 +++--- nisystemlink/clients/test_plan/__init__.py | 2 +- .../clients/test_plan/models/__init__.py | 2 +- .../test_plan/models/_execution_definition.py | 17 +- .../test_plan/test_plan_templates/__init__.py | 6 +- .../_test_plan_templates_client.py | 7 +- .../test_plan_templates/models/__init__.py | 24 ++- ...plan_templates_partial_success_response.py | 7 +- ...plan_templates_partial_success_response.py | 4 +- .../_query_test_plan_templates_request.py | 120 +++++++++-- .../_query_test_plan_templates_response.py | 7 +- .../models/_test_plan_templates.py | 17 +- tests/integration/test_plan/__init__.py | 2 +- .../test_plan/test_plan_templates/__init__.py | 2 +- .../test__create_test_plan_template.py | 147 -------------- .../test_test_plan_template.py | 188 ++++++++++++++++++ 16 files changed, 394 insertions(+), 215 deletions(-) delete mode 100644 tests/integration/test_plan/test_plan_templates/test__create_test_plan_template.py create mode 100644 tests/integration/test_plan/test_plan_templates/test_test_plan_template.py diff --git a/examples/test_plan/test_plan_templates/test_plan_templates.py b/examples/test_plan/test_plan_templates/test_plan_templates.py index 9dd53fe6..7d70451e 100644 --- a/examples/test_plan/test_plan_templates/test_plan_templates.py +++ b/examples/test_plan/test_plan_templates/test_plan_templates.py @@ -1,8 +1,14 @@ from nisystemlink.clients.core._http_configuration import HttpConfiguration from nisystemlink.clients.test_plan.models._execution_definition import ManualExecution -from nisystemlink.clients.test_plan.test_plan_templates._test_plan_templates_client import TestPlanTemplateClient -from nisystemlink.clients.test_plan.test_plan_templates.models._query_test_plan_templates_request import QueryTestPlanTemplatesRequest -from nisystemlink.clients.test_plan.test_plan_templates.models._test_plan_templates import TestPlanTemplateBase +from nisystemlink.clients.test_plan.test_plan_templates._test_plan_templates_client import ( + TestPlanTemplateClient, +) +from nisystemlink.clients.test_plan.test_plan_templates.models._query_test_plan_templates_request import ( + QueryTestPlanTemplatesRequest, +) +from nisystemlink.clients.test_plan.test_plan_templates.models._test_plan_templates import ( + TestPlanTemplateBase, +) # Setup the server configuration to point to your instance of SystemLink Enterprise server_configuration = HttpConfiguration( @@ -11,37 +17,40 @@ ) client = TestPlanTemplateClient(configuration=server_configuration) -#Test plan template request metadata +# Test plan template request metadata create_test_plan_template_request = [ - TestPlanTemplateBase( - name = "Python integration test plan template", - templateGroup = "sample template group", - workspace = "33eba2fe-fe42-48a1-a47f-a6669479a8aa", - executionActions=[ - ManualExecution( - action="TEST", - type="MANUAl" - ) - ] - ) - ] + TestPlanTemplateBase( + name="Python integration test plan template", + templateGroup="sample template group", + workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", + executionActions=[ManualExecution(action="TEST", type="MANUAl")], + ) +] # Create a test plan template -create_test_plan_template_response = client.create_test_plan_templates(test_plan_templates=create_test_plan_template_request) +create_test_plan_template_response = client.create_test_plan_templates( + test_plan_templates=create_test_plan_template_request +) create_test_plan_template_id = None -if create_test_plan_template_response.created_test_plan_templates and create_test_plan_template_response.created_test_plan_templates[0].id: - create_test_plan_template_id = str(create_test_plan_template_response.created_test_plan_templates[0].id) +if ( + create_test_plan_template_response.created_test_plan_templates + and create_test_plan_template_response.created_test_plan_templates[0].id +): + create_test_plan_template_id = str( + create_test_plan_template_response.created_test_plan_templates[0].id + ) # Query test plan templates using id query_test_plan_template_request = QueryTestPlanTemplatesRequest( - filter=f'id="{create_test_plan_template_id}"', - take=1 + filter=f'id="{create_test_plan_template_id}"', take=1 ) -client.query_test_plan_templates(query_test_plan_templates=query_test_plan_template_request) +client.query_test_plan_templates( + query_test_plan_templates=query_test_plan_template_request +) -#Delete the created test plan template. +# Delete the created test plan template. if create_test_plan_template_id is not None: - client.delete_test_plan_templates(ids=[create_test_plan_template_id]) \ No newline at end of file + client.delete_test_plan_templates(ids=[create_test_plan_template_id]) diff --git a/nisystemlink/clients/test_plan/__init__.py b/nisystemlink/clients/test_plan/__init__.py index a517c684..9c0fa90a 100644 --- a/nisystemlink/clients/test_plan/__init__.py +++ b/nisystemlink/clients/test_plan/__init__.py @@ -1 +1 @@ -# flake8: noqa \ No newline at end of file +# flake8: noqa diff --git a/nisystemlink/clients/test_plan/models/__init__.py b/nisystemlink/clients/test_plan/models/__init__.py index 322ab4f3..b893eeca 100644 --- a/nisystemlink/clients/test_plan/models/__init__.py +++ b/nisystemlink/clients/test_plan/models/__init__.py @@ -1,3 +1,3 @@ from ._execution_definition import ExecutionDefinition -# flake8: noqa \ No newline at end of file +# flake8: noqa diff --git a/nisystemlink/clients/test_plan/models/_execution_definition.py b/nisystemlink/clients/test_plan/models/_execution_definition.py index 20701ad4..7f633022 100644 --- a/nisystemlink/clients/test_plan/models/_execution_definition.py +++ b/nisystemlink/clients/test_plan/models/_execution_definition.py @@ -15,13 +15,14 @@ class Job(JsonModel): metadata: dict[str, object] """Additional metadata for the job.""" + class NotebookExecution(JsonModel): """Defines the execution of a notebook.""" action: str """User defined action to perform in workflow (user defined).""" - type: str = 'NOTEBOOK' + type: str = "NOTEBOOK" """Type of execution, default is 'NOTEBOOK'.""" notebookId: str @@ -34,16 +35,17 @@ class ManualExecution(JsonModel): action: str """User defined action to perform in workflow (user defined).""" - type: str = 'MANUAL' + type: str = "MANUAL" """Type of execution, default is 'MANUAL'.""" + class JobExecution(JsonModel): """Defines the execution of one or more jobs.""" action: str """User defined action to perform in workflow (user defined).""" - type: str = 'JOB' + type: str = "JOB" """Type of execution, default is 'JOB'.""" jobs: List[Job] @@ -59,7 +61,7 @@ class ScheduleExecution(JsonModel): action: str """User defined action to perform in workflow (user defined).""" - type: str = 'SCHEDULE' + type: str = "SCHEDULE" """Type of execution, default is 'SCHEDULE'.""" @@ -69,16 +71,17 @@ class UnscheduleExecution(JsonModel): action: str """User defined action to perform in workflow (user defined).""" - type: str = 'UNSCHEDULE' + type: str = "UNSCHEDULE" """Type of execution, default is 'UNSCHEDULE'.""" + class NoneExecution(JsonModel): """Represents a definition where no execution is specified.""" action: str """User defined action to perform in workflow (user defined).""" - type: str = 'None' + type: str = "None" """Type of execution, default is 'None'.""" @@ -88,5 +91,5 @@ class NoneExecution(JsonModel): JobExecution, NoneExecution, ScheduleExecution, - UnscheduleExecution + UnscheduleExecution, ] diff --git a/nisystemlink/clients/test_plan/test_plan_templates/__init__.py b/nisystemlink/clients/test_plan/test_plan_templates/__init__.py index 47304f4a..fdbfdd30 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/__init__.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/__init__.py @@ -1,3 +1,5 @@ -from nisystemlink.clients.test_plan.test_plan_templates._test_plan_templates_client import TestPlanTemplateClient +from nisystemlink.clients.test_plan.test_plan_templates._test_plan_templates_client import ( + TestPlanTemplateClient, +) -# flake8: noqa \ No newline at end of file +# flake8: noqa diff --git a/nisystemlink/clients/test_plan/test_plan_templates/_test_plan_templates_client.py b/nisystemlink/clients/test_plan/test_plan_templates/_test_plan_templates_client.py index e0fb809a..0a312892 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/_test_plan_templates_client.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/_test_plan_templates_client.py @@ -2,14 +2,15 @@ from typing import List, Optional +from nisystemlink.clients import core from uplink import Field, retry -from nisystemlink.clients import core from nisystemlink.clients.core._uplink._base_client import BaseClient from nisystemlink.clients.core._uplink._methods import post from . import models + @retry( when=retry.when.status(408, 429, 502, 503, 504), stop=retry.stop.after_attempt(5), @@ -39,7 +40,7 @@ def create_test_plan_templates( """Creates one or more test plan template and return errors for failed creations. Args: - testPlanTempaltes: A list of test plan templates to attempt to create. + test_plan_templates: A list of test plan templates to attempt to create. Returns: A list of created test plan templates, test plan templates that failed to create, and errors for failures. @@ -75,4 +76,4 @@ def delete_test_plan_templates( Raises: ApiException: if unable to communicate with the `/niworkorder` service of provided invalid arguments. """ - ... \ No newline at end of file + ... diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py b/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py index 56119e82..3a58a9de 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py @@ -1,7 +1,19 @@ -from nisystemlink.clients.test_plan.test_plan_templates.models._create_test_plan_templates_partial_success_response import CreateTestPlanTemplatePartialSuccessResponse -from nisystemlink.clients.test_plan.test_plan_templates.models._query_test_plan_templates_request import QueryTestPlanTemplatesRequest -from nisystemlink.clients.test_plan.test_plan_templates.models._query_test_plan_templates_response import QueryTestPlanTemplatesResponse -from nisystemlink.clients.test_plan.test_plan_templates.models._delete_test_plan_templates_partial_success_response import DeleteTestPlanTemplatesPartialSuccessResponse -from nisystemlink.clients.test_plan.test_plan_templates.models._test_plan_templates import TestPlanTemplateBase +from nisystemlink.clients.test_plan.test_plan_templates.models._create_test_plan_templates_partial_success_response import ( + CreateTestPlanTemplatePartialSuccessResponse, +) +from nisystemlink.clients.test_plan.test_plan_templates.models._query_test_plan_templates_request import ( + QueryTestPlanTemplatesRequest, + TestPlanTemplateField, +) +from nisystemlink.clients.test_plan.test_plan_templates.models._query_test_plan_templates_response import ( + QueryTestPlanTemplatesResponse, +) +from nisystemlink.clients.test_plan.test_plan_templates.models._delete_test_plan_templates_partial_success_response import ( + DeleteTestPlanTemplatesPartialSuccessResponse, +) +from nisystemlink.clients.test_plan.test_plan_templates.models._test_plan_templates import ( + TestPlanTemplateBase, + TestPlanTemplateResponse, +) -# flake8: noqa \ No newline at end of file +# flake8: noqa diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_create_test_plan_templates_partial_success_response.py b/nisystemlink/clients/test_plan/test_plan_templates/models/_create_test_plan_templates_partial_success_response.py index 7735096a..d361a8c9 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/_create_test_plan_templates_partial_success_response.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/_create_test_plan_templates_partial_success_response.py @@ -1,10 +1,11 @@ - - from typing import List, Optional + from nisystemlink.clients.core._api_error import ApiError from nisystemlink.clients.core._uplink._json_model import JsonModel + from ._test_plan_templates import TestPlanTemplateBase, TestPlanTemplateResponse + class CreateTestPlanTemplatePartialSuccessResponse(JsonModel): created_test_plan_templates: Optional[List[TestPlanTemplateResponse]] = None @@ -20,4 +21,4 @@ class CreateTestPlanTemplatePartialSuccessResponse(JsonModel): """Error messages for test plan templates that were not created. If this is `None`, then all test plan templates were successfully created. - """ \ No newline at end of file + """ diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_delete_test_plan_templates_partial_success_response.py b/nisystemlink/clients/test_plan/test_plan_templates/models/_delete_test_plan_templates_partial_success_response.py index 5186f6b9..719bc1ef 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/_delete_test_plan_templates_partial_success_response.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/_delete_test_plan_templates_partial_success_response.py @@ -2,8 +2,10 @@ from nisystemlink.clients.core._api_error import ApiError from nisystemlink.clients.core._uplink._json_model import JsonModel + class DeleteTestPlanTemplatesPartialSuccessResponse(JsonModel): - """The result of deleting multiple test plan templates when one or more test plan templates could not be deleted.""" + """The result of deleting multiple test plan templates + when one or more test plan templates could not be deleted.""" deleted_test_plan_template_ids: List[str] """The IDs of the test plan template that could not be deleted.""" diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates_request.py b/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates_request.py index 7af91d0f..fdc93373 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates_request.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates_request.py @@ -1,9 +1,10 @@ -from enum import Enum import enum -from typing import Optional +from enum import Enum +from typing import List, Optional from nisystemlink.clients.core._uplink._json_model import JsonModel + class TestPlanTemplateOrderBy(str, Enum): """An enumeration by which test plan templates can be ordered/sorted.""" @@ -13,28 +14,54 @@ class TestPlanTemplateOrderBy(str, Enum): CREATED_AT = enum.auto() UPDATED_AT = enum.auto() + +class TestPlanTemplateField(str, Enum): + ID = "id" + NAME = "name" + TEMPLATE_GROUP = "templateGroup" + PRODUCT_FAMILIES = "productFamilies" + PART_NUMBERS = "partNumbers" + SUMMARY = "summary" + DESCRIPTION = "description" + TEST_PROGRAM = "testProgram" + ESTIMATED_DURATION_IN_SECONDS = "estimatedDurationInSeconds" + SYSTEM_FILTER = "systemFilter" + EXECUTION_ACTIONS = "executionActions" + FILE_IDS = "fileIds" + WORKSPACE = "workspace" + PROPERTIES = "properties" + DASHBOARD = "dashboard" + + class QueryTestPlanTemplatesRequest(JsonModel): """Request information for the query test plan templates API.""" filter: Optional[str] = None """The test plan template query filter in dynamic LINQ format. - `id`: String representing the ID of a test plan template. Field supports only equals '=' and not equal '!=' operators for filtering. - `productFamilies`: Array of strings representing the product families to which the test plan template belongs. - `partNumbers`: Array of strings representing the part numbers of the products to which the test plan template belongs. + `id`: String representing the ID of a test plan template. Field supports only equals '=' and not + equal '!=' operators for filtering. + `productFamilies`: Array of strings representing the product families to which the test plan + template belongs. + `partNumbers`: Array of strings representing the part numbers of the products to which the test + plan template belongs. `fileIds`: The array of file IDs associated with the test plan template. `name`: String representing the name of a test plan template. `summary`: String representing the summary of a test plan template. `description`: String representing description of the test plan created from this template. `templateGroup`: String representing the template group defined by the user. - `testProgram`: String representing the test program name of the test plan created from this template. - `systemFilter`: String representing the LINQ filter used to filter the potential list of systems capable of executing test plans created from this template. + `testProgram`: String representing the test program name of the test plan created from this + template. + `systemFilter`: String representing the LINQ filter used to filter the potential list of systems + capable of executing test plans created from this template. `workspace`: String representing the workspace where the test plan template belongs. `createdBy`: String representing the user who created the test plan template. `updatedBy`: String representing the user who updated the test plan template. `createdAt`: ISO-8601 formatted timestamp indicating when the test plan template was created. - `updatedAt`: ISO-8601 formatted timestamp indicating when the test plan template was most recently updated. - `properties`: Collection of key-value pairs related to a test plan created from this template. Example: properties.Any(key == "Location" & value == "Austin") + `updatedAt`: ISO-8601 formatted timestamp indicating when the test plan template was most + recently updated. + `properties`: Collection of key-value pairs related to a test plan created from this template. + Example: properties.Any(key == "Location" & value == "Austin") See [Dynamic Linq](https://github.com/ni/systemlink-OpenAPI-documents/wiki/Dynamic-Linq-Query-Language) documentation for more details. @@ -49,12 +76,81 @@ class QueryTestPlanTemplatesRequest(JsonModel): """Field by which test plan templates can be ordered/sorted.""" descending: Optional[bool] = None - """Whether to return the test plan templates in the descending order. By default, test plan templates are sorted in the ascending order.""" + """Whether to return the test plan templates in the descending order. By default, test plan + templates are sorted in the ascending order.""" continuation_token: Optional[str] = None - """Allows users to continue the query at the next test plan templates that matches the given criteria. + """Allows users to continue the query at the next test plan templates that matches the given + criteria.""" + + projection: List[TestPlanTemplateField] = [] + """ + Gets or sets the projection to be used when retrieving the assets. If not specified, + all properties will be returned. + """ + """ To retrieve the next page of test plan templates, pass the continuation token from the previous page in the next request. The service responds with the next page of data and provides a new continuation token. To paginate results, continue sending requests with the newest continuation - token provided in each response.""" + token provided in each response. + """ + + +class _QueryTestPlanTemplatesRequest(JsonModel): + """Request information for the query test plan templates API.""" + + filter: Optional[str] = None + """The test plan template query filter in dynamic LINQ format. + + `id`: String representing the ID of a test plan template. Field supports only equals '=' and not + equal '!=' operators for filtering. + `productFamilies`: Array of strings representing the product families to which the test plan + template belongs. + `partNumbers`: Array of strings representing the part numbers of the products to which the test + plan template belongs. + `fileIds`: The array of file IDs associated with the test plan template. + `name`: String representing the name of a test plan template. + `summary`: String representing the summary of a test plan template. + `description`: String representing description of the test plan created from this template. + `templateGroup`: String representing the template group defined by the user. + `testProgram`: String representing the test program name of the test plan created from this + template. + `systemFilter`: String representing the LINQ filter used to filter the potential list of systems + capable of executing test plans created from this template. + `workspace`: String representing the workspace where the test plan template belongs. + `createdBy`: String representing the user who created the test plan template. + `updatedBy`: String representing the user who updated the test plan template. + `createdAt`: ISO-8601 formatted timestamp indicating when the test plan template was created. + `updatedAt`: ISO-8601 formatted timestamp indicating when the test plan template was most + recently updated. + `properties`: Collection of key-value pairs related to a test plan created from this template. + Example: properties.Any(key == "Location" & value == "Austin") + + See + [Dynamic Linq](https://github.com/ni/systemlink-OpenAPI-documents/wiki/Dynamic-Linq-Query-Language) + documentation for more details. + + `"@0"`, `"@1"` etc. can be used in conjunction with the `substitutions` parameter to keep this + query string more simple and reusable. + """ + + take: Optional[int] = None + """The maximum number of test plan templates to return.""" + + order_by: Optional[TestPlanTemplateOrderBy] = None + """Field by which test plan templates can be ordered/sorted.""" + + descending: Optional[bool] = None + """Whether to return the test plan templates in the descending order. By default, test plan + templates are sorted in the ascending order.""" + + continuation_token: Optional[str] = None + """Allows users to continue the query at the next test plan templates that matches the given + criteria.""" + + projection: List[str] = [] + """ + Gets or sets the projection to be used when retrieving the assets. If not specified, + all properties will be returned. + """ diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates_response.py b/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates_response.py index a50d0c0e..4d4934c8 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates_response.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates_response.py @@ -1,6 +1,9 @@ from typing import List, Optional + from nisystemlink.clients.core._uplink._json_model import JsonModel -from nisystemlink.clients.test_plan.test_plan_templates.models._test_plan_templates import TestPlanTemplateResponse +from nisystemlink.clients.test_plan.test_plan_templates.models._test_plan_templates import ( + TestPlanTemplateResponse, +) class QueryTestPlanTemplatesResponse(JsonModel): @@ -15,4 +18,4 @@ class QueryTestPlanTemplatesResponse(JsonModel): To retrieve the next page of test plan templates, pass the continuation token from the previous page in the next request. The service responds with the next page of data and provides a new continuation token. To paginate results, continue sending requests with the newest continuation - token provided in each response.""" \ No newline at end of file + token provided in each response.""" diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py b/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py index 7f6dcae6..5209ce42 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py @@ -1,6 +1,9 @@ from typing import Dict, List, Optional from nisystemlink.clients.core._uplink._json_model import JsonModel -from nisystemlink.clients.test_plan.models._execution_definition import ExecutionDefinition +from nisystemlink.clients.test_plan.models._execution_definition import ( + ExecutionDefinition, +) + class Dashboard(JsonModel): """Contains information about a reference of a dashboard linked to test plan template.""" @@ -14,6 +17,7 @@ class Dashboard(JsonModel): Each key will be prefixed with "var-" and the value will be the value of the variable. """ + class TestPlanTemplateBase(JsonModel): """Contains information about a test plan template.""" @@ -42,16 +46,20 @@ class TestPlanTemplateBase(JsonModel): """The estimated time in seconds for executing the test plan created from this template.""" system_filter: Optional[str] = None - """The LINQ filter string is used to filter the potential list of systems capable of executing test plans created from this template.""" + """The LINQ filter string is used to filter the potential list of + systems capable of executing test plans created from this template.""" execution_actions: Optional[List[ExecutionDefinition]] = None - """Defines the executions that will be used for test plan actions created from this template.""" + """Defines the executions that will be used for test plan actions created from this template. + """ file_ids: Optional[List[str]] = None """Array of file IDs associated with the test plan template.""" workspace: Optional[str] = None - """ID of the workspace where the test plan template belongs. Default workspace will be taken if the value is not given.""" + """ID of the workspace where the test plan template belongs. + Default workspace will be taken if the value is not given. + """ properties: Optional[Dict[str, str]] = None """Properties of the test plan created from this template as key-value pairs.""" @@ -59,6 +67,7 @@ class TestPlanTemplateBase(JsonModel): dashboard: Optional[Dashboard] = None """Defines a dashboard reference for a test plan.""" + class TestPlanTemplateResponse(TestPlanTemplateBase): """Contains response information for test plan template.""" diff --git a/tests/integration/test_plan/__init__.py b/tests/integration/test_plan/__init__.py index a517c684..9c0fa90a 100644 --- a/tests/integration/test_plan/__init__.py +++ b/tests/integration/test_plan/__init__.py @@ -1 +1 @@ -# flake8: noqa \ No newline at end of file +# flake8: noqa diff --git a/tests/integration/test_plan/test_plan_templates/__init__.py b/tests/integration/test_plan/test_plan_templates/__init__.py index a517c684..9c0fa90a 100644 --- a/tests/integration/test_plan/test_plan_templates/__init__.py +++ b/tests/integration/test_plan/test_plan_templates/__init__.py @@ -1 +1 @@ -# flake8: noqa \ No newline at end of file +# flake8: noqa diff --git a/tests/integration/test_plan/test_plan_templates/test__create_test_plan_template.py b/tests/integration/test_plan/test_plan_templates/test__create_test_plan_template.py deleted file mode 100644 index e499d8fc..00000000 --- a/tests/integration/test_plan/test_plan_templates/test__create_test_plan_template.py +++ /dev/null @@ -1,147 +0,0 @@ -from typing import List -import pytest - -from nisystemlink.clients.core._http_configuration import HttpConfiguration -from nisystemlink.clients.test_plan.models._execution_definition import ManualExecution -from nisystemlink.clients.test_plan.test_plan_templates._test_plan_templates_client import TestPlanTemplateClient -from nisystemlink.clients.test_plan.test_plan_templates.models._create_test_plan_templates_partial_success_response import CreateTestPlanTemplatePartialSuccessResponse -from nisystemlink.clients.test_plan.test_plan_templates.models._query_test_plan_templates_request import QueryTestPlanTemplatesRequest -from nisystemlink.clients.test_plan.test_plan_templates.models._query_test_plan_templates_response import QueryTestPlanTemplatesResponse -from nisystemlink.clients.test_plan.test_plan_templates.models._test_plan_templates import TestPlanTemplateBase, TestPlanTemplateResponse - -@pytest.fixture(scope="class") -def client(enterprise_config: HttpConfiguration) -> TestPlanTemplateClient: - """Fixture to create a TestPlanTemplateClient instance.""" - - return TestPlanTemplateClient(enterprise_config) - -@pytest.fixture -def create_test_plan_templates(client: TestPlanTemplateClient): - """FIxture to return a factory that create test plan templates.""" - responses: List[CreateTestPlanTemplatePartialSuccessResponse] = [] - - def _create_test_plan_templates( - new_test_plan_templates: List[TestPlanTemplateBase], - ) -> CreateTestPlanTemplatePartialSuccessResponse: - response = client.create_test_plan_templates(test_plan_templates=new_test_plan_templates) - responses.append(response) - return response - - yield _create_test_plan_templates - - created_test_plan_templates: List[TestPlanTemplateResponse] = [] - for response in responses: - if response.created_test_plan_templates: - created_test_plan_templates = created_test_plan_templates + response.created_test_plan_templates - client.delete_test_plan_templates(ids=[test_plan_template.id for test_plan_template in created_test_plan_templates]) - -@pytest.mark.integration -@pytest.mark.enterprise -class TestPlanTemplateTest: - - def test__create_test_plan_template__returns_created_test_plan_template( - self, client: TestPlanTemplateClient, create_test_plan_templates - ): - create_test_plan_template_request: List[TestPlanTemplateBase] = [ - TestPlanTemplateBase( - name = "Python integration test plan template", - templateGroup = "sample template group", - workspace = "33eba2fe-fe42-48a1-a47f-a6669479a8aa", - executionActions=[ - ManualExecution( - action="TEST", - type="MANUAl" - ) - ] - ) - ] - create_test_plan_template_response = create_test_plan_templates(create_test_plan_template_request) - - template_id = ( - create_test_plan_template_response.created_test_plan_templates[0].id - if create_test_plan_template_response.created_test_plan_templates and create_test_plan_template_response.created_test_plan_templates[0].id - else None - ) - - assert template_id is not None - assert create_test_plan_template_response.created_test_plan_templates[0].name == create_test_plan_template_request[0].name - - def test__query_test_plan_template__returns_queried_test_plan_template( - self, client: TestPlanTemplateClient, create_test_plan_templates - ): - - create_test_plan_template_request: List[TestPlanTemplateBase] = [ - TestPlanTemplateBase( - name = "Python integration test plan template", - templateGroup = "sample template group", - workspace = "33eba2fe-fe42-48a1-a47f-a6669479a8aa", - executionActions=[ - ManualExecution( - action="TEST", - type="MANUAl" - ) - ] - ) - ] - - create_test_plan_template_response = create_test_plan_templates(create_test_plan_template_request) - - template_id = ( - create_test_plan_template_response.created_test_plan_templates[0].id - if create_test_plan_template_response.created_test_plan_templates and create_test_plan_template_response.created_test_plan_templates[0].id - else None - ) - - assert template_id is not None - - query_test_plan_template_response: QueryTestPlanTemplatesResponse = client.query_test_plan_templates( - query_test_plan_templates=QueryTestPlanTemplatesRequest( - filter=f'id="{template_id}"', - take=1 - ) - ) - - assert len(query_test_plan_template_response.test_plan_templates) == 1 - assert query_test_plan_template_response.test_plan_templates[0].id == template_id - - def test__delete_test_plan_template( - self, client: TestPlanTemplateClient - ): - - create_test_plan_template_request: List[TestPlanTemplateBase] = [ - TestPlanTemplateBase( - name = "Python integration test plan template", - templateGroup = "sample template group", - workspace = "33eba2fe-fe42-48a1-a47f-a6669479a8aa", - executionActions=[ - ManualExecution( - action="TEST", - type="MANUAl" - ) - ] - ) - ] - create_test_plan_template_response: CreateTestPlanTemplatePartialSuccessResponse = client.create_test_plan_templates( - test_plan_templates=create_test_plan_template_request - ) - - template_id = ( - create_test_plan_template_response.created_test_plan_templates[0].id - if create_test_plan_template_response.created_test_plan_templates and create_test_plan_template_response.created_test_plan_templates[0].id - else None - ) - - assert template_id is not None - - client.delete_test_plan_templates( - ids=[template_id] - ) - - query_deleted_test_plan_template_response: QueryTestPlanTemplatesResponse = client.query_test_plan_templates( - query_test_plan_templates=QueryTestPlanTemplatesRequest( - filter=f'id="{template_id}"', - take=1 - ) - ) - - assert len(query_deleted_test_plan_template_response.test_plan_templates) == 0 diff --git a/tests/integration/test_plan/test_plan_templates/test_test_plan_template.py b/tests/integration/test_plan/test_plan_templates/test_test_plan_template.py new file mode 100644 index 00000000..31a18c11 --- /dev/null +++ b/tests/integration/test_plan/test_plan_templates/test_test_plan_template.py @@ -0,0 +1,188 @@ +from typing import List + +import pytest + +from nisystemlink.clients.core._http_configuration import HttpConfiguration +from nisystemlink.clients.test_plan.models._execution_definition import ManualExecution +from nisystemlink.clients.test_plan.test_plan_templates import TestPlanTemplateClient +from nisystemlink.clients.test_plan.test_plan_templates.models import ( + CreateTestPlanTemplatePartialSuccessResponse, + QueryTestPlanTemplatesRequest, + QueryTestPlanTemplatesResponse, + TestPlanTemplateBase, + TestPlanTemplateField, + TestPlanTemplateResponse, +) + + +@pytest.fixture(scope="class") +def client(enterprise_config: HttpConfiguration) -> TestPlanTemplateClient: + """Fixture to create a TestPlanTemplateClient instance.""" + return TestPlanTemplateClient(enterprise_config) + + +@pytest.fixture +def create_test_plan_templates(client: TestPlanTemplateClient): + """Fixture to return a factory that create test plan templates.""" + responses: List[CreateTestPlanTemplatePartialSuccessResponse] = [] + + def _create_test_plan_templates( + new_test_plan_templates: List[TestPlanTemplateBase], + ) -> CreateTestPlanTemplatePartialSuccessResponse: + response = client.create_test_plan_templates( + test_plan_templates=new_test_plan_templates + ) + responses.append(response) + return response + + yield _create_test_plan_templates + + created_test_plan_templates: List[TestPlanTemplateResponse] = [] + for response in responses: + if response.created_test_plan_templates: + created_test_plan_templates = ( + created_test_plan_templates + response.created_test_plan_templates + ) + client.delete_test_plan_templates( + ids=[ + test_plan_template.id + for test_plan_template in created_test_plan_templates + ] + ) + + +@pytest.mark.integration +@pytest.mark.enterprise +class TestPlanTemplateTest: + + def test__create_test_plan_template__returns_created_test_plan_template( + self, client: TestPlanTemplateClient, create_test_plan_templates + ): + create_test_plan_template_request: List[TestPlanTemplateBase] = [ + TestPlanTemplateBase( + name="Python integration test plan template", + templateGroup="sample template group", + workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", + executionActions=[ManualExecution(action="TEST", type="MANUAl")], + ) + ] + create_test_plan_template_response = create_test_plan_templates( + create_test_plan_template_request + ) + + template_id = ( + create_test_plan_template_response.created_test_plan_templates[0].id + if create_test_plan_template_response.created_test_plan_templates + and create_test_plan_template_response.created_test_plan_templates[0].id + else None + ) + + assert template_id is not None + assert ( + create_test_plan_template_response.created_test_plan_templates[0].name + == create_test_plan_template_request[0].name + ) + + def test__query_test_plan_template__returns_queried_test_plan_template( + self, client: TestPlanTemplateClient, create_test_plan_templates + ): + + create_test_plan_template_request: List[TestPlanTemplateBase] = [ + TestPlanTemplateBase( + name="Python integration test plan template", + templateGroup="sample template group", + workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", + executionActions=[ManualExecution(action="TEST", type="MANUAl")], + ) + ] + + create_test_plan_template_response = create_test_plan_templates( + create_test_plan_template_request + ) + + template_id = ( + create_test_plan_template_response.created_test_plan_templates[0].id + if create_test_plan_template_response.created_test_plan_templates + and create_test_plan_template_response.created_test_plan_templates[0].id + else None + ) + + assert template_id is not None + + query_test_plan_template_response: QueryTestPlanTemplatesResponse = ( + client.query_test_plan_templates( + query_test_plan_templates=QueryTestPlanTemplatesRequest( + filter=f'id="{template_id}"', take=1 + ) + ) + ) + + assert len(query_test_plan_template_response.test_plan_templates) == 1 + assert ( + query_test_plan_template_response.test_plan_templates[0].id == template_id + ) + + def test__delete_test_plan_template(self, client: TestPlanTemplateClient): + + create_test_plan_template_request: List[TestPlanTemplateBase] = [ + TestPlanTemplateBase( + name="Python integration test plan template", + templateGroup="sample template group", + workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", + executionActions=[ManualExecution(action="TEST", type="MANUAl")], + ) + ] + create_test_plan_template_response: ( + CreateTestPlanTemplatePartialSuccessResponse + ) = client.create_test_plan_templates( + test_plan_templates=create_test_plan_template_request + ) + + template_id = ( + create_test_plan_template_response.created_test_plan_templates[0].id + if create_test_plan_template_response.created_test_plan_templates + and create_test_plan_template_response.created_test_plan_templates[0].id + else None + ) + + assert template_id is not None + + client.delete_test_plan_templates(ids=[template_id]) + + query_deleted_test_plan_template_response: QueryTestPlanTemplatesResponse = ( + client.query_test_plan_templates( + query_test_plan_templates=QueryTestPlanTemplatesRequest( + filter=f'id="{template_id}"', take=1 + ) + ) + ) + + assert len(query_deleted_test_plan_template_response.test_plan_templates) == 0 + + def test_query_test_plan_templates_with_projections__returns_test_plan_templates_with_projected_properties( + self, client: TestPlanTemplateClient + ): + query = QueryTestPlanTemplatesRequest( + projection=[TestPlanTemplateField.ID, TestPlanTemplateField.NAME], + ) + response = client.query_test_plan_templates(query_test_plan_templates=query) + + assert response is not None + assert all( + test_plan_template.id is not None + and test_plan_template.name is not None + and test_plan_template.template_group is None + and test_plan_template.product_families is None + and test_plan_template.part_numbers is None + and test_plan_template.summary is None + and test_plan_template.description is None + and test_plan_template.test_program is None + and test_plan_template.estimated_duration_in_seconds is None + and test_plan_template.system_filter is None + and test_plan_template.execution_actions is None + and test_plan_template.file_ids is None + and test_plan_template.workspace is None + and test_plan_template.properties is None + and test_plan_template.dashboard is None + for test_plan_template in response.test_plan_templates + ) From de1909df5fdcbbf29282bfee3a159267cf5321b0 Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Tue, 20 May 2025 21:02:27 +0530 Subject: [PATCH 27/64] lint --- nisystemlink/clients/test_plan/models/_execution_definition.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nisystemlink/clients/test_plan/models/_execution_definition.py b/nisystemlink/clients/test_plan/models/_execution_definition.py index 1271588e..ef0ee3ff 100644 --- a/nisystemlink/clients/test_plan/models/_execution_definition.py +++ b/nisystemlink/clients/test_plan/models/_execution_definition.py @@ -1,4 +1,4 @@ -from typing import Union, Optional +from typing import Optional, Union from nisystemlink.clients.core._uplink._json_model import JsonModel From f74c45447bbf6a51f850e05fd6f49c9fe1bed826 Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Tue, 20 May 2025 21:10:24 +0530 Subject: [PATCH 28/64] add docs --- docs/api_reference.rst | 1 + docs/api_reference/test_plans.rst | 19 +++++++++++++++++++ docs/getting_started.rst | 26 ++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 docs/api_reference/test_plans.rst diff --git a/docs/api_reference.rst b/docs/api_reference.rst index 5a5e1d7c..913e81cb 100644 --- a/docs/api_reference.rst +++ b/docs/api_reference.rst @@ -16,6 +16,7 @@ API Reference api_reference/file api_reference/notebook api_reference/feeds + api_reference/test_plans Indices and tables ------------------ diff --git a/docs/api_reference/test_plans.rst b/docs/api_reference/test_plans.rst new file mode 100644 index 00000000..802fd69d --- /dev/null +++ b/docs/api_reference/test_plans.rst @@ -0,0 +1,19 @@ +.. _api_tag_page: + +nisystemlink.clients.test_plan.test_plans +====================== + +.. autoclass:: nisystemlink.clients.test_plan.test_plans.TestPlansClient + :exclude-members: __init__ + + .. automethod:: __init__ + .. automethod:: create_test_plans + .. automethod:: delete_test_plans + .. automethod:: query_test_plans + .. automethod:: schedule_test_plan + .. automethod:: update_test_plan + .. automethod:: get_test_plan + +.. automodule:: nisystemlink.clients.testmonitor.models + :members: + :imported-members: \ No newline at end of file diff --git a/docs/getting_started.rst b/docs/getting_started.rst index 5e98cfe7..28654061 100644 --- a/docs/getting_started.rst +++ b/docs/getting_started.rst @@ -318,5 +318,31 @@ Create, query, update, and delete some notebooks. Create, query, retry, and cancel notebook executions. .. literalinclude:: ../examples/notebook/notebook_execution.py + :language: python + :linenos: + +TestPlans API +------- + +Overview +~~~~~~~~ + +The :class:`.TestPlansClient` class is the primary entry point of the TestPlans API. + +When constructing a :class:`.TestPlansClient`, you can pass an +:class:`.HttpConfiguration` (like one retrieved from the +:class:`.HttpConfigurationManager`), or let :class:`.TestPlansClient` use the +default connection. The default connection depends on your environment. + +With a :class:`.TestPlansClient` object, you can: + +* Create, query, get, update, schedule and delete TestPlans + +Examples +~~~~~~~~ + +Create, query, get, update, schedule and delete TestPlans + +.. literalinclude:: ../examples/test_plan/test_plans/test_plans.py :language: python :linenos: \ No newline at end of file From ac8e9a0b521c86a26ec5d7ef0069cf51ecde4fa8 Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Tue, 20 May 2025 21:14:14 +0530 Subject: [PATCH 29/64] lint --- nisystemlink/clients/test_plan/__init__.py | 2 +- .../clients/test_plan/models/_execution_definition.py | 4 ++-- .../clients/test_plan/test_plan_templates/__init__.py | 2 +- .../clients/test_plan/test_plan_templates/models/__init__.py | 2 +- tests/integration/test_plan/__init__.py | 2 +- tests/integration/test_plan/test_plan_templates/__init__.py | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/nisystemlink/clients/test_plan/__init__.py b/nisystemlink/clients/test_plan/__init__.py index a517c684..9c0fa90a 100644 --- a/nisystemlink/clients/test_plan/__init__.py +++ b/nisystemlink/clients/test_plan/__init__.py @@ -1 +1 @@ -# flake8: noqa \ No newline at end of file +# flake8: noqa diff --git a/nisystemlink/clients/test_plan/models/_execution_definition.py b/nisystemlink/clients/test_plan/models/_execution_definition.py index e3b24dc7..ef0ee3ff 100644 --- a/nisystemlink/clients/test_plan/models/_execution_definition.py +++ b/nisystemlink/clients/test_plan/models/_execution_definition.py @@ -1,4 +1,4 @@ -from typing import Union +from typing import Optional, Union from nisystemlink.clients.core._uplink._json_model import JsonModel @@ -51,7 +51,7 @@ class JobExecutionDefinition(JsonModel): jobs: list[Job] """List of jobs to execute""" - systemId: str | None = None + systemId: Optional[str] = None """Optional system ID where jobs will run""" diff --git a/nisystemlink/clients/test_plan/test_plan_templates/__init__.py b/nisystemlink/clients/test_plan/test_plan_templates/__init__.py index a517c684..9c0fa90a 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/__init__.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/__init__.py @@ -1 +1 @@ -# flake8: noqa \ No newline at end of file +# flake8: noqa diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py b/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py index a517c684..9c0fa90a 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py @@ -1 +1 @@ -# flake8: noqa \ No newline at end of file +# flake8: noqa diff --git a/tests/integration/test_plan/__init__.py b/tests/integration/test_plan/__init__.py index a517c684..9c0fa90a 100644 --- a/tests/integration/test_plan/__init__.py +++ b/tests/integration/test_plan/__init__.py @@ -1 +1 @@ -# flake8: noqa \ No newline at end of file +# flake8: noqa diff --git a/tests/integration/test_plan/test_plan_templates/__init__.py b/tests/integration/test_plan/test_plan_templates/__init__.py index a517c684..9c0fa90a 100644 --- a/tests/integration/test_plan/test_plan_templates/__init__.py +++ b/tests/integration/test_plan/test_plan_templates/__init__.py @@ -1 +1 @@ -# flake8: noqa \ No newline at end of file +# flake8: noqa From 2b2f2b99d4326634e0fc5046391059a56e2c7233 Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Tue, 20 May 2025 21:22:04 +0530 Subject: [PATCH 30/64] lint --- .../test_plan_templates/_test_plan_templates_client.py | 2 ++ .../_delete_test_plan_templates_partial_success_response.py | 4 +++- .../test_plan_templates/models/_test_plan_templates.py | 4 +++- .../test_plan/test_plan_templates/test_test_plan_template.py | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/nisystemlink/clients/test_plan/test_plan_templates/_test_plan_templates_client.py b/nisystemlink/clients/test_plan/test_plan_templates/_test_plan_templates_client.py index 0a312892..54d4c3ad 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/_test_plan_templates_client.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/_test_plan_templates_client.py @@ -3,9 +3,11 @@ from typing import List, Optional from nisystemlink.clients import core + from uplink import Field, retry from nisystemlink.clients.core._uplink._base_client import BaseClient + from nisystemlink.clients.core._uplink._methods import post from . import models diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_delete_test_plan_templates_partial_success_response.py b/nisystemlink/clients/test_plan/test_plan_templates/models/_delete_test_plan_templates_partial_success_response.py index 719bc1ef..27e192ab 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/_delete_test_plan_templates_partial_success_response.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/_delete_test_plan_templates_partial_success_response.py @@ -1,11 +1,13 @@ from typing import List, Optional + from nisystemlink.clients.core._api_error import ApiError from nisystemlink.clients.core._uplink._json_model import JsonModel class DeleteTestPlanTemplatesPartialSuccessResponse(JsonModel): """The result of deleting multiple test plan templates - when one or more test plan templates could not be deleted.""" + when one or more test plan templates could not be deleted. + """ deleted_test_plan_template_ids: List[str] """The IDs of the test plan template that could not be deleted.""" diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py b/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py index 5209ce42..3b16ad10 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py @@ -1,4 +1,5 @@ from typing import Dict, List, Optional + from nisystemlink.clients.core._uplink._json_model import JsonModel from nisystemlink.clients.test_plan.models._execution_definition import ( ExecutionDefinition, @@ -47,7 +48,8 @@ class TestPlanTemplateBase(JsonModel): system_filter: Optional[str] = None """The LINQ filter string is used to filter the potential list of - systems capable of executing test plans created from this template.""" + systems capable of executing test plans created from this template. + """ execution_actions: Optional[List[ExecutionDefinition]] = None """Defines the executions that will be used for test plan actions created from this template. diff --git a/tests/integration/test_plan/test_plan_templates/test_test_plan_template.py b/tests/integration/test_plan/test_plan_templates/test_test_plan_template.py index 31a18c11..7d132d9a 100644 --- a/tests/integration/test_plan/test_plan_templates/test_test_plan_template.py +++ b/tests/integration/test_plan/test_plan_templates/test_test_plan_template.py @@ -3,6 +3,7 @@ import pytest from nisystemlink.clients.core._http_configuration import HttpConfiguration + from nisystemlink.clients.test_plan.models._execution_definition import ManualExecution from nisystemlink.clients.test_plan.test_plan_templates import TestPlanTemplateClient from nisystemlink.clients.test_plan.test_plan_templates.models import ( From 5405c0f8043d19389d1e6b2761b133181a953b13 Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Tue, 20 May 2025 21:43:54 +0530 Subject: [PATCH 31/64] add example --- examples/test_plan/test_plans/test_plans.py | 72 +++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 examples/test_plan/test_plans/test_plans.py diff --git a/examples/test_plan/test_plans/test_plans.py b/examples/test_plan/test_plans/test_plans.py new file mode 100644 index 00000000..f36f13e6 --- /dev/null +++ b/examples/test_plan/test_plans/test_plans.py @@ -0,0 +1,72 @@ +from nisystemlink.clients.core._http_configuration import HttpConfiguration +from nisystemlink.clients.test_plan.test_plans import TestPlansClient +from nisystemlink.clients.test_plan.test_plans.models import ( + CreateTestPlanBodyContent, + CreateTestPlansRequest, + QueryTestPlansRequest, + ScheduleTestPlanBodyContent, + ScheduleTestPlansRequest, + UpdateTestPlanBodyContent, + UpdateTestPlansRequest, +) + +# Setup the server configuration to point to your instance of SystemLink Enterprise +server_configuration = HttpConfiguration( + server_uri="https://yourserver.yourcompany.com", + api_key="YourAPIKeyGeneratedFromSystemLink", +) +client = TestPlansClient(configuration=server_configuration) + +create_test_plans_request = CreateTestPlansRequest( + testPlans=[ + CreateTestPlanBodyContent( + name="Python integration test plan", state="NEW", partNumber="px40482" + ) + ] +) + +# create a test plan +created_test_plans = client.create_test_plans(testplans=create_test_plans_request) + +created_test_plan_id = created_test_plans.createdTestPlans[0].id + +# Query test plan using id. +query_asset_request = QueryTestPlansRequest( + ids=[created_test_plan_id], + skip=0, + take=1, + descending=False, + calibratable_only=False, + returnCount=False, +) +client.query_test_plans(query=query_asset_request) + +# Get test plan +get_test_plan = client.get_test_plan(test_plan_id=created_test_plan_id) + +# Update test plan +update_request = UpdateTestPlansRequest( + testPlans=[ + UpdateTestPlanBodyContent( + id=created_test_plan_id, + name="Updated Test Plan", + ) + ] +) +updated_test_plan = client.update_test_plan(test_plans=update_request) + +# Schedule the test plan +schedule_request = ScheduleTestPlansRequest( + test_plans=[ + ScheduleTestPlanBodyContent( + id=created_test_plan_id, + planned_start_date_time="2025-05-20T15:07:42.527Z", + estimated_end_date_time="2025-05-20T15:07:42.527Z", + system_id="fake-system", + ) + ] +) +schedule_test_plan_response = client.schedule_test_plan(schedule=schedule_request) + +# Delete test plan +client.delete_test_plans(ids=[created_test_plan_id]) From fdbaa5e0c919e4b2342ea91d4b6553aa31fc2cc1 Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Wed, 21 May 2025 13:28:52 +0530 Subject: [PATCH 32/64] refactor --- docs/api_reference.rst | 2 +- .../{test_plans.rst => test_plan.rst} | 10 ++-- docs/getting_started.rst | 12 ++--- .../test_plans.py => test_plan/test_plan.py} | 24 ++++----- .../clients/test_plan/test_plan/__init__.py | 3 ++ .../_test_plan_client.py} | 16 +++--- .../models/__init__.py | 0 .../models/_create_test_plan_body_content.py | 0 .../models/_create_test_plans_request.py | 0 .../models/_create_test_plans_response.py | 0 .../models/_delete_test_plans_request.py | 0 .../models/_execution_event.py | 0 .../models/_query_test_plans_request.py | 0 .../models/_query_test_plans_response.py | 0 .../_schedule_test_plans_body_content.py | 0 .../models/_schedule_test_plans_request.py | 0 .../models/_schedule_test_plans_response.py | 0 .../models/_state.py | 0 .../models/_test_plan.py | 0 .../models/_update_test_plans_body_content.py | 0 .../models/_update_test_plans_request.py | 0 .../models/_update_test_plans_response.py | 0 .../models/_workflow_definition.py | 0 .../clients/test_plan/test_plans/__init__.py | 3 -- .../test_plan/test_plans/test_test_plans.py | 54 ++++++++++--------- 25 files changed, 64 insertions(+), 60 deletions(-) rename docs/api_reference/{test_plans.rst => test_plan.rst} (52%) rename examples/test_plan/{test_plans/test_plans.py => test_plan/test_plan.py} (68%) create mode 100644 nisystemlink/clients/test_plan/test_plan/__init__.py rename nisystemlink/clients/test_plan/{test_plans/_test_plans_client.py => test_plan/_test_plan_client.py} (89%) rename nisystemlink/clients/test_plan/{test_plans => test_plan}/models/__init__.py (100%) rename nisystemlink/clients/test_plan/{test_plans => test_plan}/models/_create_test_plan_body_content.py (100%) rename nisystemlink/clients/test_plan/{test_plans => test_plan}/models/_create_test_plans_request.py (100%) rename nisystemlink/clients/test_plan/{test_plans => test_plan}/models/_create_test_plans_response.py (100%) rename nisystemlink/clients/test_plan/{test_plans => test_plan}/models/_delete_test_plans_request.py (100%) rename nisystemlink/clients/test_plan/{test_plans => test_plan}/models/_execution_event.py (100%) rename nisystemlink/clients/test_plan/{test_plans => test_plan}/models/_query_test_plans_request.py (100%) rename nisystemlink/clients/test_plan/{test_plans => test_plan}/models/_query_test_plans_response.py (100%) rename nisystemlink/clients/test_plan/{test_plans => test_plan}/models/_schedule_test_plans_body_content.py (100%) rename nisystemlink/clients/test_plan/{test_plans => test_plan}/models/_schedule_test_plans_request.py (100%) rename nisystemlink/clients/test_plan/{test_plans => test_plan}/models/_schedule_test_plans_response.py (100%) rename nisystemlink/clients/test_plan/{test_plans => test_plan}/models/_state.py (100%) rename nisystemlink/clients/test_plan/{test_plans => test_plan}/models/_test_plan.py (100%) rename nisystemlink/clients/test_plan/{test_plans => test_plan}/models/_update_test_plans_body_content.py (100%) rename nisystemlink/clients/test_plan/{test_plans => test_plan}/models/_update_test_plans_request.py (100%) rename nisystemlink/clients/test_plan/{test_plans => test_plan}/models/_update_test_plans_response.py (100%) rename nisystemlink/clients/test_plan/{test_plans => test_plan}/models/_workflow_definition.py (100%) delete mode 100644 nisystemlink/clients/test_plan/test_plans/__init__.py diff --git a/docs/api_reference.rst b/docs/api_reference.rst index 913e81cb..ac30a93c 100644 --- a/docs/api_reference.rst +++ b/docs/api_reference.rst @@ -16,7 +16,7 @@ API Reference api_reference/file api_reference/notebook api_reference/feeds - api_reference/test_plans + api_reference/test_plan Indices and tables ------------------ diff --git a/docs/api_reference/test_plans.rst b/docs/api_reference/test_plan.rst similarity index 52% rename from docs/api_reference/test_plans.rst rename to docs/api_reference/test_plan.rst index 802fd69d..62b53268 100644 --- a/docs/api_reference/test_plans.rst +++ b/docs/api_reference/test_plan.rst @@ -1,19 +1,19 @@ .. _api_tag_page: -nisystemlink.clients.test_plan.test_plans +nisystemlink.clients.test_plan.test_plan ====================== -.. autoclass:: nisystemlink.clients.test_plan.test_plans.TestPlansClient +.. autoclass:: nisystemlink.clients.test_plan.test_plan.TestPlanClient :exclude-members: __init__ .. automethod:: __init__ .. automethod:: create_test_plans .. automethod:: delete_test_plans .. automethod:: query_test_plans - .. automethod:: schedule_test_plan - .. automethod:: update_test_plan + .. automethod:: schedule_test_plans + .. automethod:: update_test_plans .. automethod:: get_test_plan -.. automodule:: nisystemlink.clients.testmonitor.models +.. automodule:: nisystemlink.clients.test_plan.test_plan.models :members: :imported-members: \ No newline at end of file diff --git a/docs/getting_started.rst b/docs/getting_started.rst index 28654061..25e39e03 100644 --- a/docs/getting_started.rst +++ b/docs/getting_started.rst @@ -321,20 +321,20 @@ Create, query, retry, and cancel notebook executions. :language: python :linenos: -TestPlans API +TestPlan API ------- Overview ~~~~~~~~ -The :class:`.TestPlansClient` class is the primary entry point of the TestPlans API. +The :class:`.TestPlanClient` class is the primary entry point of the TestPlan API. -When constructing a :class:`.TestPlansClient`, you can pass an +When constructing a :class:`.TestPlanClient`, you can pass an :class:`.HttpConfiguration` (like one retrieved from the -:class:`.HttpConfigurationManager`), or let :class:`.TestPlansClient` use the +:class:`.HttpConfigurationManager`), or let :class:`.TestPlanClient` use the default connection. The default connection depends on your environment. -With a :class:`.TestPlansClient` object, you can: +With a :class:`.TestPlanClient` object, you can: * Create, query, get, update, schedule and delete TestPlans @@ -343,6 +343,6 @@ Examples Create, query, get, update, schedule and delete TestPlans -.. literalinclude:: ../examples/test_plan/test_plans/test_plans.py +.. literalinclude:: ../examples/test_plan/test_plan/test_plans.py :language: python :linenos: \ No newline at end of file diff --git a/examples/test_plan/test_plans/test_plans.py b/examples/test_plan/test_plan/test_plan.py similarity index 68% rename from examples/test_plan/test_plans/test_plans.py rename to examples/test_plan/test_plan/test_plan.py index f36f13e6..a9da6755 100644 --- a/examples/test_plan/test_plans/test_plans.py +++ b/examples/test_plan/test_plan/test_plan.py @@ -1,6 +1,6 @@ from nisystemlink.clients.core._http_configuration import HttpConfiguration -from nisystemlink.clients.test_plan.test_plans import TestPlansClient -from nisystemlink.clients.test_plan.test_plans.models import ( +from nisystemlink.clients.test_plan.test_plan import TestPlanClient +from nisystemlink.clients.test_plan.test_plan.models import ( CreateTestPlanBodyContent, CreateTestPlansRequest, QueryTestPlansRequest, @@ -15,7 +15,7 @@ server_uri="https://yourserver.yourcompany.com", api_key="YourAPIKeyGeneratedFromSystemLink", ) -client = TestPlansClient(configuration=server_configuration) +client = TestPlanClient(configuration=server_configuration) create_test_plans_request = CreateTestPlansRequest( testPlans=[ @@ -26,26 +26,24 @@ ) # create a test plan -created_test_plans = client.create_test_plans(testplans=create_test_plans_request) +created_test_plans = client.create_test_plans(create_request=create_test_plans_request) created_test_plan_id = created_test_plans.createdTestPlans[0].id # Query test plan using id. -query_asset_request = QueryTestPlansRequest( - ids=[created_test_plan_id], +query_test_plans_request = QueryTestPlansRequest( skip=0, take=1, descending=False, - calibratable_only=False, returnCount=False, ) -client.query_test_plans(query=query_asset_request) +client.query_test_plans(query_request=query_test_plans_request) # Get test plan get_test_plan = client.get_test_plan(test_plan_id=created_test_plan_id) # Update test plan -update_request = UpdateTestPlansRequest( +update_test_plans_request = UpdateTestPlansRequest( testPlans=[ UpdateTestPlanBodyContent( id=created_test_plan_id, @@ -53,10 +51,10 @@ ) ] ) -updated_test_plan = client.update_test_plan(test_plans=update_request) +updated_test_plan = client.update_test_plan(update_request=update_test_plans_request) # Schedule the test plan -schedule_request = ScheduleTestPlansRequest( +schedule_test_plans_request = ScheduleTestPlansRequest( test_plans=[ ScheduleTestPlanBodyContent( id=created_test_plan_id, @@ -66,7 +64,9 @@ ) ] ) -schedule_test_plan_response = client.schedule_test_plan(schedule=schedule_request) +schedule_test_plan_response = client.schedule_test_plan( + schedule_request=schedule_test_plans_request +) # Delete test plan client.delete_test_plans(ids=[created_test_plan_id]) diff --git a/nisystemlink/clients/test_plan/test_plan/__init__.py b/nisystemlink/clients/test_plan/test_plan/__init__.py new file mode 100644 index 00000000..013b65cb --- /dev/null +++ b/nisystemlink/clients/test_plan/test_plan/__init__.py @@ -0,0 +1,3 @@ +from ._test_plan_client import TestPlanClient + +# flake8: noqa diff --git a/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py b/nisystemlink/clients/test_plan/test_plan/_test_plan_client.py similarity index 89% rename from nisystemlink/clients/test_plan/test_plans/_test_plans_client.py rename to nisystemlink/clients/test_plan/test_plan/_test_plan_client.py index 31b2f02b..01747a8e 100644 --- a/nisystemlink/clients/test_plan/test_plans/_test_plans_client.py +++ b/nisystemlink/clients/test_plan/test_plan/_test_plan_client.py @@ -19,7 +19,7 @@ ) -class TestPlansClient(BaseClient): +class TestPlanClient(BaseClient): def __init__(self, configuration: Optional[HttpConfiguration] = None): """Initialize an instance. @@ -51,7 +51,7 @@ def get_test_plan(self, test_plan_id) -> TestPlan: @post("testplans") def create_test_plans( - self, testplans: CreateTestPlansRequest + self, create_request: CreateTestPlansRequest ) -> CreateTestPlansResponse: """Create a new test plan. @@ -76,7 +76,9 @@ def delete_test_plans(self, ids: DeleteTestPlansRequest) -> None: ... @post("query-testplans") - def query_test_plans(self, query: QueryTestPlansRequest) -> QueryTestPlansResponse: + def query_test_plans( + self, query_request: QueryTestPlansRequest + ) -> QueryTestPlansResponse: """Query test plans. Args: @@ -88,8 +90,8 @@ def query_test_plans(self, query: QueryTestPlansRequest) -> QueryTestPlansRespon ... @post("schedule-testplans") - def schedule_test_plan( - self, schedule: ScheduleTestPlansRequest + def schedule_test_plans( + self, schedule_request: ScheduleTestPlansRequest ) -> ScheduleTestPlansResponse: """Schedule a test plan. @@ -102,8 +104,8 @@ def schedule_test_plan( ... @post("update-testplans") - def update_test_plan( - self, test_plans: UpdateTestPlansRequest + def update_test_plans( + self, update_request: UpdateTestPlansRequest ) -> UpdateTestPlansResponse: """Update a test plan. diff --git a/nisystemlink/clients/test_plan/test_plans/models/__init__.py b/nisystemlink/clients/test_plan/test_plan/models/__init__.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plans/models/__init__.py rename to nisystemlink/clients/test_plan/test_plan/models/__init__.py diff --git a/nisystemlink/clients/test_plan/test_plans/models/_create_test_plan_body_content.py b/nisystemlink/clients/test_plan/test_plan/models/_create_test_plan_body_content.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plans/models/_create_test_plan_body_content.py rename to nisystemlink/clients/test_plan/test_plan/models/_create_test_plan_body_content.py diff --git a/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans_request.py b/nisystemlink/clients/test_plan/test_plan/models/_create_test_plans_request.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plans/models/_create_test_plans_request.py rename to nisystemlink/clients/test_plan/test_plan/models/_create_test_plans_request.py diff --git a/nisystemlink/clients/test_plan/test_plans/models/_create_test_plans_response.py b/nisystemlink/clients/test_plan/test_plan/models/_create_test_plans_response.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plans/models/_create_test_plans_response.py rename to nisystemlink/clients/test_plan/test_plan/models/_create_test_plans_response.py diff --git a/nisystemlink/clients/test_plan/test_plans/models/_delete_test_plans_request.py b/nisystemlink/clients/test_plan/test_plan/models/_delete_test_plans_request.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plans/models/_delete_test_plans_request.py rename to nisystemlink/clients/test_plan/test_plan/models/_delete_test_plans_request.py diff --git a/nisystemlink/clients/test_plan/test_plans/models/_execution_event.py b/nisystemlink/clients/test_plan/test_plan/models/_execution_event.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plans/models/_execution_event.py rename to nisystemlink/clients/test_plan/test_plan/models/_execution_event.py diff --git a/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans_request.py b/nisystemlink/clients/test_plan/test_plan/models/_query_test_plans_request.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plans/models/_query_test_plans_request.py rename to nisystemlink/clients/test_plan/test_plan/models/_query_test_plans_request.py diff --git a/nisystemlink/clients/test_plan/test_plans/models/_query_test_plans_response.py b/nisystemlink/clients/test_plan/test_plan/models/_query_test_plans_response.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plans/models/_query_test_plans_response.py rename to nisystemlink/clients/test_plan/test_plan/models/_query_test_plans_response.py diff --git a/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans_body_content.py b/nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_body_content.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans_body_content.py rename to nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_body_content.py diff --git a/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans_request.py b/nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_request.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans_request.py rename to nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_request.py diff --git a/nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans_response.py b/nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_response.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plans/models/_schedule_test_plans_response.py rename to nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_response.py diff --git a/nisystemlink/clients/test_plan/test_plans/models/_state.py b/nisystemlink/clients/test_plan/test_plan/models/_state.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plans/models/_state.py rename to nisystemlink/clients/test_plan/test_plan/models/_state.py diff --git a/nisystemlink/clients/test_plan/test_plans/models/_test_plan.py b/nisystemlink/clients/test_plan/test_plan/models/_test_plan.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plans/models/_test_plan.py rename to nisystemlink/clients/test_plan/test_plan/models/_test_plan.py diff --git a/nisystemlink/clients/test_plan/test_plans/models/_update_test_plans_body_content.py b/nisystemlink/clients/test_plan/test_plan/models/_update_test_plans_body_content.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plans/models/_update_test_plans_body_content.py rename to nisystemlink/clients/test_plan/test_plan/models/_update_test_plans_body_content.py diff --git a/nisystemlink/clients/test_plan/test_plans/models/_update_test_plans_request.py b/nisystemlink/clients/test_plan/test_plan/models/_update_test_plans_request.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plans/models/_update_test_plans_request.py rename to nisystemlink/clients/test_plan/test_plan/models/_update_test_plans_request.py diff --git a/nisystemlink/clients/test_plan/test_plans/models/_update_test_plans_response.py b/nisystemlink/clients/test_plan/test_plan/models/_update_test_plans_response.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plans/models/_update_test_plans_response.py rename to nisystemlink/clients/test_plan/test_plan/models/_update_test_plans_response.py diff --git a/nisystemlink/clients/test_plan/test_plans/models/_workflow_definition.py b/nisystemlink/clients/test_plan/test_plan/models/_workflow_definition.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plans/models/_workflow_definition.py rename to nisystemlink/clients/test_plan/test_plan/models/_workflow_definition.py diff --git a/nisystemlink/clients/test_plan/test_plans/__init__.py b/nisystemlink/clients/test_plan/test_plans/__init__.py deleted file mode 100644 index fe33d7d0..00000000 --- a/nisystemlink/clients/test_plan/test_plans/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from ._test_plans_client import TestPlansClient - -# flake8: noqa diff --git a/tests/integration/test_plan/test_plans/test_test_plans.py b/tests/integration/test_plan/test_plans/test_test_plans.py index da3fc30c..0011574e 100644 --- a/tests/integration/test_plan/test_plans/test_test_plans.py +++ b/tests/integration/test_plan/test_plans/test_test_plans.py @@ -1,7 +1,7 @@ import pytest from nisystemlink.clients.core._http_configuration import HttpConfiguration -from nisystemlink.clients.test_plan.test_plans import TestPlansClient -from nisystemlink.clients.test_plan.test_plans.models import ( +from nisystemlink.clients.test_plan.test_plan import TestPlanClient +from nisystemlink.clients.test_plan.test_plan.models import ( CreateTestPlanBodyContent, CreateTestPlansRequest, CreateTestPlansResponse, @@ -32,19 +32,19 @@ def test_plan_create() -> CreateTestPlansRequest: @pytest.fixture(scope="class") -def client(enterprise_config: HttpConfiguration) -> TestPlansClient: +def client(enterprise_config: HttpConfiguration) -> TestPlanClient: """Fixture to create a TestPlansClient instance""" - return TestPlansClient(enterprise_config) + return TestPlanClient(enterprise_config) @pytest.mark.integration @pytest.mark.enterprise class TestTestPlans: def test__create_and_delete_test_plan__returns_created_and_deleted_test_plans( - self, client: TestPlansClient, test_plan_create: CreateTestPlansRequest + self, client: TestPlanClient, test_plan_create: CreateTestPlansRequest ): create_test_plan_response: CreateTestPlansResponse = client.create_test_plans( - testplans=test_plan_create + create_request=test_plan_create ) created_test_plan = create_test_plan_response.createdTestPlans[0] @@ -61,10 +61,10 @@ def test__create_and_delete_test_plan__returns_created_and_deleted_test_plans( assert get_test_plan_response.name == "Python integration test plan" def test__get_test_plan__returns_get_test_plan( - self, client: TestPlansClient, test_plan_create: CreateTestPlansRequest + self, client: TestPlanClient, test_plan_create: CreateTestPlansRequest ): create_test_plan_response: CreateTestPlansResponse = client.create_test_plans( - testplans=test_plan_create + create_request=test_plan_create ) created_test_plan = create_test_plan_response.createdTestPlans[0] @@ -80,14 +80,14 @@ def test__get_test_plan__returns_get_test_plan( assert get_test_plan_response.id == created_test_plan.id def test__update_test_plan__returns_updated_test_plan( - self, client: TestPlansClient, test_plan_create: CreateTestPlansRequest + self, client: TestPlanClient, test_plan_create: CreateTestPlansRequest ): create_test_plan_response: CreateTestPlansResponse = client.create_test_plans( - testplans=test_plan_create + create_request=test_plan_create ) created_test_plan = create_test_plan_response.createdTestPlans[0] - update_request = UpdateTestPlansRequest( + update_test_plans_request = UpdateTestPlansRequest( testPlans=[ UpdateTestPlanBodyContent( id=created_test_plan.id, @@ -95,27 +95,29 @@ def test__update_test_plan__returns_updated_test_plan( ) ] ) - update_test_plan_response = client.update_test_plan(test_plans=update_request) + update_test_plans_response = client.update_test_plans( + update_request=update_test_plans_request + ) delete_request = DeleteTestPlansRequest( ids=[create_test_plan_response.createdTestPlans[0].id] ) client.delete_test_plans(ids=delete_request) - assert update_test_plan_response is not None - updated_test_plan = update_test_plan_response.updated_test_plans[0] + assert update_test_plans_response is not None + updated_test_plan = update_test_plans_response.updated_test_plans[0] assert updated_test_plan.id == created_test_plan.id assert updated_test_plan.name == "Updated Test Plan" def test__schedule_test_plan__returns_scheduled_test_plan( - self, client: TestPlansClient, test_plan_create: CreateTestPlansRequest + self, client: TestPlanClient, test_plan_create: CreateTestPlansRequest ): create_test_plan_response: CreateTestPlansResponse = client.create_test_plans( - testplans=test_plan_create + create_request=test_plan_create ) created_test_plan = create_test_plan_response.createdTestPlans[0] - schedule_request = ScheduleTestPlansRequest( + schedule_test_plans_request = ScheduleTestPlansRequest( test_plans=[ ScheduleTestPlanBodyContent( id=created_test_plan.id, @@ -125,24 +127,24 @@ def test__schedule_test_plan__returns_scheduled_test_plan( ) ] ) - schedule_test_plan_response = client.schedule_test_plan( - schedule=schedule_request + schedule_test_plans_response = client.schedule_test_plans( + schedule_request=schedule_test_plans_request ) delete_request = DeleteTestPlansRequest(ids=[created_test_plan.id]) client.delete_test_plans(ids=delete_request) - assert schedule_test_plan_response is not None - scheduled_test_plan = schedule_test_plan_response.scheduled_test_plans[0] + assert schedule_test_plans_response is not None + scheduled_test_plan = schedule_test_plans_response.scheduled_test_plans[0] assert scheduled_test_plan.id == created_test_plan.id assert scheduled_test_plan.plannedStartDateTime == "2025-05-20T15:07:42.527Z" assert scheduled_test_plan.systemId == "fake-system" def test__query_test_plans__return_queried_test_plan( - self, client: TestPlansClient, test_plan_create: CreateTestPlansRequest + self, client: TestPlanClient, test_plan_create: CreateTestPlansRequest ): create_test_plan_response: CreateTestPlansResponse = client.create_test_plans( - testplans=test_plan_create + create_request=test_plan_create ) created_test_plan = create_test_plan_response.createdTestPlans[0] @@ -150,7 +152,7 @@ def test__query_test_plans__return_queried_test_plan( filter=f'id = "{created_test_plan.id}"', return_count=True ) queried_test_plans_response = client.query_test_plans( - query=query_test_plans_request + query_request=query_test_plans_request ) delete_request = DeleteTestPlansRequest(ids=[created_test_plan.id]) @@ -161,12 +163,12 @@ def test__query_test_plans__return_queried_test_plan( assert queried_test_plans_response.total_count > 0 def test__query_test_plans_with_projections__returns_the_test_plans_with_projected_properties( - self, client: TestPlansClient, test_plan_create: CreateTestPlansRequest + self, client: TestPlanClient, test_plan_create: CreateTestPlansRequest ): query_test_plans_request = QueryTestPlansRequest( projection=[TestPlanField.ID, TestPlanField.NAME] ) - response = client.query_test_plans(query=query_test_plans_request) + response = client.query_test_plans(query_request=query_test_plans_request) assert response is not None assert all( From 883ea0695158715205e644fe26bb5055e40d21fd Mon Sep 17 00:00:00 2001 From: Ammar Husain Mian Fazulul Date: Wed, 21 May 2025 13:36:41 +0530 Subject: [PATCH 33/64] updated implementation --- .../_test_plan_templates_client.py | 39 ++++++++++++-- .../test_plan_templates/models/__init__.py | 1 + .../_query_test_plan_templates_request.py | 52 +++++++++++++------ .../models/_test_plan_templates.py | 6 +-- .../test_test_plan_template.py | 26 +++++----- 5 files changed, 86 insertions(+), 38 deletions(-) diff --git a/nisystemlink/clients/test_plan/test_plan_templates/_test_plan_templates_client.py b/nisystemlink/clients/test_plan/test_plan_templates/_test_plan_templates_client.py index 54d4c3ad..1f5d8ab3 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/_test_plan_templates_client.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/_test_plan_templates_client.py @@ -3,12 +3,9 @@ from typing import List, Optional from nisystemlink.clients import core - -from uplink import Field, retry - from nisystemlink.clients.core._uplink._base_client import BaseClient - from nisystemlink.clients.core._uplink._methods import post +from uplink import Field, retry from . import models @@ -53,6 +50,18 @@ def create_test_plan_templates( ... @post("query-testplan-templates") + def __query_test_plan_templates( + self, query_test_plan_templates: models._QueryTestPlanTemplatesRequest + ) -> models.QueryTestPlanTemplatesResponse: + """Queries one or more test plan templates and return errors for failed queries. + + Returns: A list of test plan templates, based on the query and errors for the wrong query. + + Raises: ApiException: if unable to communicate with the `/niworkorder` service of provided invalid + arguments. + """ + ... + def query_test_plan_templates( self, query_test_plan_templates: models.QueryTestPlanTemplatesRequest ) -> models.QueryTestPlanTemplatesResponse: @@ -63,7 +72,27 @@ def query_test_plan_templates( Raises: ApiException: if unable to communicate with the `/niworkorder` service of provided invalid arguments. """ - ... + projection_str = ( + [projection.name for projection in query_test_plan_templates.projection] + if query_test_plan_templates.projection + else None + ) + query_params = { + "filter": query_test_plan_templates.filter, + "take": query_test_plan_templates.take, + "substitutions": query_test_plan_templates.substitutions, + "continuationToken": query_test_plan_templates.continuation_token, + "orderBy": query_test_plan_templates.order_by, + "descending": query_test_plan_templates.descending, + "projection": projection_str, + } + + query_params = {k: v for k, v in query_params.items() if v is not None} + + query_request = models._QueryTestPlanTemplatesRequest(**query_params) + + print(query_request) + return self.__query_test_plan_templates(query_test_plan_templates=query_request) @post("delete-testplan-templates", args=[Field("ids")]) def delete_test_plan_templates( diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py b/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py index 3a58a9de..df468051 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py @@ -3,6 +3,7 @@ ) from nisystemlink.clients.test_plan.test_plan_templates.models._query_test_plan_templates_request import ( QueryTestPlanTemplatesRequest, + _QueryTestPlanTemplatesRequest, TestPlanTemplateField, ) from nisystemlink.clients.test_plan.test_plan_templates.models._query_test_plan_templates_response import ( diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates_request.py b/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates_request.py index fdc93373..7b67ec24 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates_request.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates_request.py @@ -16,21 +16,25 @@ class TestPlanTemplateOrderBy(str, Enum): class TestPlanTemplateField(str, Enum): - ID = "id" - NAME = "name" - TEMPLATE_GROUP = "templateGroup" - PRODUCT_FAMILIES = "productFamilies" - PART_NUMBERS = "partNumbers" - SUMMARY = "summary" - DESCRIPTION = "description" - TEST_PROGRAM = "testProgram" - ESTIMATED_DURATION_IN_SECONDS = "estimatedDurationInSeconds" - SYSTEM_FILTER = "systemFilter" - EXECUTION_ACTIONS = "executionActions" - FILE_IDS = "fileIds" - WORKSPACE = "workspace" - PROPERTIES = "properties" - DASHBOARD = "dashboard" + ID = enum.auto() + NAME = enum.auto() + TEMPLATE_GROUP = enum.auto() + PRODUCT_FAMILIES = enum.auto() + PART_NUMBERS = enum.auto() + SUMMARY = enum.auto() + DESCRIPTION = enum.auto() + TEST_PROGRAM = enum.auto() + ESTIMATED_DURATION_IN_SECONDS = enum.auto() + SYSTEM_FILTER = enum.auto() + EXECUTION_ACTIONS = enum.auto() + FILE_IDS = enum.auto() + WORKSPACE = enum.auto() + PROPERTIES = enum.auto() + DASHBOARD = enum.auto() + CREATED_BY = enum.auto() + UPDATED_BY = enum.auto() + CREATED_AT = enum.auto() + UPDATED_AT = enum.auto() class QueryTestPlanTemplatesRequest(JsonModel): @@ -75,6 +79,14 @@ class QueryTestPlanTemplatesRequest(JsonModel): order_by: Optional[TestPlanTemplateOrderBy] = None """Field by which test plan templates can be ordered/sorted.""" + substitutions: Optional[List[str]] = None + """Makes substitutions in the query filter expression + using non-negative integers. These integers + use the @ symbol as a prefix. The filter + expression replaces each substitution + with the element at the corresponding + index in this list. The index is zero-based.""" + descending: Optional[bool] = None """Whether to return the test plan templates in the descending order. By default, test plan templates are sorted in the ascending order.""" @@ -141,6 +153,14 @@ class _QueryTestPlanTemplatesRequest(JsonModel): order_by: Optional[TestPlanTemplateOrderBy] = None """Field by which test plan templates can be ordered/sorted.""" + substitutions: Optional[List[str]] = None + """Makes substitutions in the query filter expression + using non-negative integers. These integers + use the @ symbol as a prefix. The filter + expression replaces each substitution + with the element at the corresponding + index in this list. The index is zero-based.""" + descending: Optional[bool] = None """Whether to return the test plan templates in the descending order. By default, test plan templates are sorted in the ascending order.""" @@ -149,7 +169,7 @@ class _QueryTestPlanTemplatesRequest(JsonModel): """Allows users to continue the query at the next test plan templates that matches the given criteria.""" - projection: List[str] = [] + projection: Optional[List[str]] = None """ Gets or sets the projection to be used when retrieving the assets. If not specified, all properties will be returned. diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py b/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py index 3b16ad10..08435673 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py @@ -22,10 +22,10 @@ class Dashboard(JsonModel): class TestPlanTemplateBase(JsonModel): """Contains information about a test plan template.""" - name: str + name: str | None """Name of the test plan template.""" - template_group: str = None + template_group: str | None = None """The template group defined by the user.""" product_families: Optional[List[str]] = None @@ -47,7 +47,7 @@ class TestPlanTemplateBase(JsonModel): """The estimated time in seconds for executing the test plan created from this template.""" system_filter: Optional[str] = None - """The LINQ filter string is used to filter the potential list of + """The LINQ filter string is used to filter the potential list of systems capable of executing test plans created from this template. """ diff --git a/tests/integration/test_plan/test_plan_templates/test_test_plan_template.py b/tests/integration/test_plan/test_plan_templates/test_test_plan_template.py index 7d132d9a..8afbe9ab 100644 --- a/tests/integration/test_plan/test_plan_templates/test_test_plan_template.py +++ b/tests/integration/test_plan/test_plan_templates/test_test_plan_template.py @@ -1,9 +1,7 @@ from typing import List import pytest - from nisystemlink.clients.core._http_configuration import HttpConfiguration - from nisystemlink.clients.test_plan.models._execution_definition import ManualExecution from nisystemlink.clients.test_plan.test_plan_templates import TestPlanTemplateClient from nisystemlink.clients.test_plan.test_plan_templates.models import ( @@ -44,12 +42,13 @@ def _create_test_plan_templates( created_test_plan_templates = ( created_test_plan_templates + response.created_test_plan_templates ) - client.delete_test_plan_templates( - ids=[ - test_plan_template.id - for test_plan_template in created_test_plan_templates - ] - ) + client.delete_test_plan_templates( + ids=[ + test_plan_template.id + for test_plan_template in created_test_plan_templates + if test_plan_template.id is not None + ] + ) @pytest.mark.integration @@ -110,15 +109,13 @@ def test__query_test_plan_template__returns_queried_test_plan_template( assert template_id is not None + query = QueryTestPlanTemplatesRequest(filter=f'id="{template_id}"', take=1) + query_test_plan_template_response: QueryTestPlanTemplatesResponse = ( - client.query_test_plan_templates( - query_test_plan_templates=QueryTestPlanTemplatesRequest( - filter=f'id="{template_id}"', take=1 - ) - ) + client.query_test_plan_templates(query_test_plan_templates=query) ) - assert len(query_test_plan_template_response.test_plan_templates) == 1 + assert len(query_test_plan_template_response.test_plan_templates) == 1, query assert ( query_test_plan_template_response.test_plan_templates[0].id == template_id ) @@ -166,6 +163,7 @@ def test_query_test_plan_templates_with_projections__returns_test_plan_templates query = QueryTestPlanTemplatesRequest( projection=[TestPlanTemplateField.ID, TestPlanTemplateField.NAME], ) + print(query) response = client.query_test_plan_templates(query_test_plan_templates=query) assert response is not None From cf34f104bc7a1c09bc168f625ac2163cd74ef2d7 Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Wed, 21 May 2025 14:42:08 +0530 Subject: [PATCH 34/64] refactor --- .../test_plan/test_plan/_test_plan_client.py | 6 ++ .../models/_create_test_plan_body_content.py | 20 +++--- .../models/_create_test_plans_request.py | 2 +- .../models/_create_test_plans_response.py | 6 +- .../test_plan/models/_execution_event.py | 8 +-- .../test_plan/test_plan/models/_test_plan.py | 42 ++++++------ .../models/_update_test_plans_response.py | 4 -- .../test_plan/models/_workflow_definition.py | 14 ++-- .../test_plan/test_plans/test_test_plans.py | 64 +++++++++---------- 9 files changed, 84 insertions(+), 82 deletions(-) diff --git a/nisystemlink/clients/test_plan/test_plan/_test_plan_client.py b/nisystemlink/clients/test_plan/test_plan/_test_plan_client.py index 01747a8e..97f6befe 100644 --- a/nisystemlink/clients/test_plan/test_plan/_test_plan_client.py +++ b/nisystemlink/clients/test_plan/test_plan/_test_plan_client.py @@ -4,6 +4,7 @@ from nisystemlink.clients.core._http_configuration import HttpConfiguration from nisystemlink.clients.core._uplink._base_client import BaseClient from nisystemlink.clients.core._uplink._methods import get, post +from uplink import retry from .models import ( CreateTestPlansRequest, @@ -19,6 +20,11 @@ ) +@retry( + when=retry.when.status(408, 429, 502, 503, 504), + stop=retry.stop.after_attempt(5), + on_exception=retry.CONNECTION_ERROR, +) class TestPlanClient(BaseClient): def __init__(self, configuration: Optional[HttpConfiguration] = None): """Initialize an instance. diff --git a/nisystemlink/clients/test_plan/test_plan/models/_create_test_plan_body_content.py b/nisystemlink/clients/test_plan/test_plan/models/_create_test_plan_body_content.py index db82e889..4b1d7629 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/_create_test_plan_body_content.py +++ b/nisystemlink/clients/test_plan/test_plan/models/_create_test_plan_body_content.py @@ -21,7 +21,7 @@ class CreateTestPlanBodyContent(JsonModel): name: Optional[str] = None """The name of the test plan.""" - templateId: Optional[str] = None + template_id: Optional[str] = None """The ID of the template to use for the test plan.""" state: Optional[str] = None @@ -30,38 +30,38 @@ class CreateTestPlanBodyContent(JsonModel): description: Optional[str] = None """A description of the test plan.""" - assignedTo: Optional[str] = None + assigned_to: Optional[str] = None """The user or group assigned to the test plan.""" - workOrderId: Optional[str] = None + work_order_id: Optional[str] = None """The work order ID associated with the test plan.""" - estimatedDurationInSeconds: Optional[int] = None + estimated_duration_in_seconds: Optional[int] = None """The estimated duration of the test plan in seconds.""" properties: Optional[Dict[str, str]] = None """Additional properties for the test plan.""" - partNumber: Optional[str] = None + part_number: Optional[str] = None """The part number associated with the test plan.""" - dutId: Optional[str] = None + dut_id: Optional[str] = None """The Device Under Test (DUT) ID.""" - testProgram: Optional[str] = None + test_program: Optional[str] = None """The test program associated with the test plan.""" - systemFilter: Optional[str] = None + systemtest_programfilter: Optional[str] = None """The system filter to apply.""" workspace: Optional[str] = None """The workspace associated with the test plan.""" - fileIdsFromTemplate: Optional[List[str]] = None + file_ids_from_template: Optional[List[str]] = None """List of file IDs from the template.""" dashboard: Optional[Dashboard] = None """The dashboard associated with the test plan.""" - executionActions: Optional[List[ExecutionDefinition]] = None + execution_actions: Optional[List[ExecutionDefinition]] = None """List of execution actions for the test plan.""" diff --git a/nisystemlink/clients/test_plan/test_plan/models/_create_test_plans_request.py b/nisystemlink/clients/test_plan/test_plan/models/_create_test_plans_request.py index 099cc6a8..a0f15257 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/_create_test_plans_request.py +++ b/nisystemlink/clients/test_plan/test_plan/models/_create_test_plans_request.py @@ -8,7 +8,7 @@ class CreateTestPlansRequest(JsonModel): """Represents the request body for creating multiple test plans.""" - testPlans: Optional[List[CreateTestPlanBodyContent]] = None + test_plans: Optional[List[CreateTestPlanBodyContent]] = None """ A list of test plan creation request bodies. Each item in the list contains the content required to create an individual test plan. diff --git a/nisystemlink/clients/test_plan/test_plan/models/_create_test_plans_response.py b/nisystemlink/clients/test_plan/test_plan/models/_create_test_plans_response.py index 5cc5bec8..92f4b952 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/_create_test_plans_response.py +++ b/nisystemlink/clients/test_plan/test_plan/models/_create_test_plans_response.py @@ -11,11 +11,11 @@ class CreateTestPlansResponse(JsonModel): failed test plans, and any associated errors. """ - testPlans: Optional[List[TestPlan]] = None + test_plans: Optional[List[TestPlan]] = None """List of all test plans involved in the operation.""" - createdTestPlans: Optional[List[TestPlan]] = None + created_test_plans: Optional[List[TestPlan]] = None """List of test plans that were successfully created.""" - failedTestPlans: Optional[List[CreateTestPlanBodyContent]] = None + failed_test_plans: Optional[List[CreateTestPlanBodyContent]] = None """List of test plans that failed to be created, with their request body content.""" diff --git a/nisystemlink/clients/test_plan/test_plan/models/_execution_event.py b/nisystemlink/clients/test_plan/test_plan/models/_execution_event.py index d14ef731..3d7c12ef 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/_execution_event.py +++ b/nisystemlink/clients/test_plan/test_plan/models/_execution_event.py @@ -7,10 +7,10 @@ class ExecutionEventBase(JsonModel): action: Optional[str] = None """Base class for execution events, containing common attributes such as action.""" - triggeredAt: Optional[str] = None + triggered_at: Optional[str] = None """the time the event was triggered.""" - triggeredBy: Optional[str] = None + triggered_by: Optional[str] = None """and the user who triggered it.""" @@ -18,7 +18,7 @@ class NotebookExecutionEvent(ExecutionEventBase): type: Optional[str] = "NOTEBOOK" """Represents an execution event triggered by a notebook.""" - executionId: Optional[str] = None + execution_id: Optional[str] = None """Includes the type identifier and the execution ID.""" @@ -26,7 +26,7 @@ class JobExecutionEvent(ExecutionEventBase): type: Optional[str] = "JOB" """Represents an execution event triggered by a job.""" - jobIds: Optional[List[str]] + job_ids: Optional[List[str]] """Includes the type identifier and a list of job IDs.""" diff --git a/nisystemlink/clients/test_plan/test_plan/models/_test_plan.py b/nisystemlink/clients/test_plan/test_plan/models/_test_plan.py index f49ca87a..1efae9df 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/_test_plan.py +++ b/nisystemlink/clients/test_plan/test_plan/models/_test_plan.py @@ -14,7 +14,7 @@ class TestPlan(JsonModel): id: str """The unique identifier of the test plan.""" - templateId: Optional[str] = None + template_id: Optional[str] = None """The identifier of the template used to create the test plan.""" name: Optional[str] = None @@ -29,70 +29,70 @@ class TestPlan(JsonModel): description: Optional[str] = None """The description of the test plan.""" - assignedTo: Optional[str] = None + assigned_to: Optional[str] = None """The user or group assigned to the test plan.""" - workOrderId: Optional[str] = None + work_order_id: Optional[str] = None """The identifier of the associated work order.""" - workOrderName: Optional[str] = None + work_order_name: Optional[str] = None """The name of the associated work order.""" workspace: Optional[str] = None """The workspace to which the test plan belongs.""" - createdBy: Optional[str] = None + created_by: Optional[str] = None """The user who created the test plan.""" - updatedBy: Optional[str] = None + updated_by: Optional[str] = None """The user who last updated the test plan.""" - createdAt: Optional[str] = None + created_At: Optional[str] = None """The date and time when the test plan was created.""" - updatedAt: Optional[str] = None + updated_at: Optional[str] = None """The date and time when the test plan was last updated.""" properties: Optional[Dict[str, str]] = None """Additional properties associated with the test plan.""" - partNumber: Optional[str] = None + part_number: Optional[str] = None """The part number associated with the test plan.""" - dutId: Optional[str] = None + dut_id: Optional[str] = None """The identifier of the device under test (DUT).""" - testProgram: Optional[str] = None + test_program: Optional[str] = None """The test program associated with the test plan.""" - systemId: Optional[str] = None + system_id: Optional[str] = None """The identifier of the system used for the test plan.""" - fixtureIds: Optional[List[str]] = None + fixture_ids: Optional[List[str]] = None """The list of fixture identifiers associated with the test plan.""" - systemFilter: Optional[str] = None + system_filter: Optional[str] = None """The filter used to select systems for the test plan.""" - plannedStartDateTime: Optional[str] = None + planned_start_date_time: Optional[str] = None """The planned start date and time for the test plan.""" - estimatedEndDateTime: Optional[str] = None + estimated_end_date_time: Optional[str] = None """The estimated end date and time for the test plan.""" - estimatedDurationInSeconds: Optional[float] = None + estimated_duration_in_seconds: Optional[float] = None """The estimated duration of the test plan in seconds.""" - fileIdsFromTemplate: Optional[List[str]] = None + file_ids_from_template: Optional[List[str]] = None """The list of file identifiers inherited from the template.""" - executionActions: Optional[List[ExecutionDefinition]] = None + execution_actions: Optional[List[ExecutionDefinition]] = None """The execution actions defined for the test plan.""" - executionHistory: Optional[List[ExecutionEvent]] = None + execution_history: Optional[List[ExecutionEvent]] = None """The execution history of the test plan.""" - dashboardUrl: Optional[Dict[str, str]] = None + dashboard_url: Optional[Dict[str, str]] = None """The URLs for dashboards related to the test plan.""" dashboard: Optional[Dict[str, str]] = None diff --git a/nisystemlink/clients/test_plan/test_plan/models/_update_test_plans_response.py b/nisystemlink/clients/test_plan/test_plan/models/_update_test_plans_response.py index 9b337ddc..a2e68c02 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/_update_test_plans_response.py +++ b/nisystemlink/clients/test_plan/test_plan/models/_update_test_plans_response.py @@ -1,6 +1,5 @@ from typing import List, Optional -from nisystemlink.clients.core import ApiError from nisystemlink.clients.core._uplink._json_model import JsonModel from . import TestPlan, UpdateTestPlanBodyContent @@ -14,6 +13,3 @@ class UpdateTestPlansResponse(JsonModel): failed_test_plans: Optional[List[UpdateTestPlanBodyContent]] = None """List of test plans that failed to update.""" - - error: Optional[ApiError] = None - """Error information if the update operation failed.""" diff --git a/nisystemlink/clients/test_plan/test_plan/models/_workflow_definition.py b/nisystemlink/clients/test_plan/test_plan/models/_workflow_definition.py index 4952018e..b3e05544 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/_workflow_definition.py +++ b/nisystemlink/clients/test_plan/test_plan/models/_workflow_definition.py @@ -10,13 +10,13 @@ class ActionTransitionDefinition(JsonModel): action: str """The name of the action that triggers the transition.""" - nextState: State + next_state: State """The state to transition to after the action is performed.""" - nextSubstate: str + next_substate: str """The substate to transition to within the next state.""" - showInUI: bool + show_in_u_i: bool """Indicates whether this transition should be visible in the user interface.""" @@ -29,7 +29,7 @@ class SubstateDefinition(JsonModel): label: str """The display label for the substate.""" - availableActions: list[ActionTransitionDefinition] + available_actions: list[ActionTransitionDefinition] """List of actions that can be performed from this substate.""" @@ -39,10 +39,10 @@ class StateDefinition(JsonModel): state: State """The state associated with this definition.""" - dashboardAvailable: bool + dashboard_available: bool """Indicates if the state is available on the dashboard.""" - defaultSubstate: str + default_substate: str """The name of the default substate for this state.""" substates: list[SubstateDefinition] @@ -58,7 +58,7 @@ class ActionDefinition(JsonModel): label: str """The display label for the action.""" - executionAction: ExecutionDefinition + execution_action: ExecutionDefinition """The execution details associated with the action.""" diff --git a/tests/integration/test_plan/test_plans/test_test_plans.py b/tests/integration/test_plan/test_plans/test_test_plans.py index 0011574e..b9c39e17 100644 --- a/tests/integration/test_plan/test_plans/test_test_plans.py +++ b/tests/integration/test_plan/test_plans/test_test_plans.py @@ -23,7 +23,7 @@ def test_plan_create() -> CreateTestPlansRequest: testPlan = CreateTestPlansRequest( testPlans=[ CreateTestPlanBodyContent( - name="Python integration test plan", state="NEW", partNumber="px40482" + name="Python integration test plan", state="NEW", part_number="px40482" ) ] ) @@ -46,7 +46,7 @@ def test__create_and_delete_test_plan__returns_created_and_deleted_test_plans( create_test_plan_response: CreateTestPlansResponse = client.create_test_plans( create_request=test_plan_create ) - created_test_plan = create_test_plan_response.createdTestPlans[0] + created_test_plan = create_test_plan_response.created_test_plans[0] get_test_plan_response: TestPlan = client.get_test_plan(created_test_plan.id) @@ -56,7 +56,7 @@ def test__create_and_delete_test_plan__returns_created_and_deleted_test_plans( assert created_test_plan is not None assert created_test_plan.name == "Python integration test plan" assert created_test_plan.state == State.New - assert created_test_plan.partNumber == "px40482" + assert created_test_plan.part_number == "px40482" assert get_test_plan_response is not None assert get_test_plan_response.name == "Python integration test plan" @@ -66,12 +66,12 @@ def test__get_test_plan__returns_get_test_plan( create_test_plan_response: CreateTestPlansResponse = client.create_test_plans( create_request=test_plan_create ) - created_test_plan = create_test_plan_response.createdTestPlans[0] + created_test_plan = create_test_plan_response.created_test_plans[0] get_test_plan_response: TestPlan = client.get_test_plan(created_test_plan.id) delete_request = DeleteTestPlansRequest( - ids=[create_test_plan_response.createdTestPlans[0].id] + ids=[create_test_plan_response.created_test_plans[0].id] ) client.delete_test_plans(ids=delete_request) @@ -85,7 +85,7 @@ def test__update_test_plan__returns_updated_test_plan( create_test_plan_response: CreateTestPlansResponse = client.create_test_plans( create_request=test_plan_create ) - created_test_plan = create_test_plan_response.createdTestPlans[0] + created_test_plan = create_test_plan_response.created_test_plans[0] update_test_plans_request = UpdateTestPlansRequest( testPlans=[ @@ -100,7 +100,7 @@ def test__update_test_plan__returns_updated_test_plan( ) delete_request = DeleteTestPlansRequest( - ids=[create_test_plan_response.createdTestPlans[0].id] + ids=[create_test_plan_response.created_test_plans[0].id] ) client.delete_test_plans(ids=delete_request) @@ -115,7 +115,7 @@ def test__schedule_test_plan__returns_scheduled_test_plan( create_test_plan_response: CreateTestPlansResponse = client.create_test_plans( create_request=test_plan_create ) - created_test_plan = create_test_plan_response.createdTestPlans[0] + created_test_plan = create_test_plan_response.created_test_plans[0] schedule_test_plans_request = ScheduleTestPlansRequest( test_plans=[ @@ -137,8 +137,8 @@ def test__schedule_test_plan__returns_scheduled_test_plan( assert schedule_test_plans_response is not None scheduled_test_plan = schedule_test_plans_response.scheduled_test_plans[0] assert scheduled_test_plan.id == created_test_plan.id - assert scheduled_test_plan.plannedStartDateTime == "2025-05-20T15:07:42.527Z" - assert scheduled_test_plan.systemId == "fake-system" + assert scheduled_test_plan.planned_start_date_time == "2025-05-20T15:07:42.527Z" + assert scheduled_test_plan.system_id == "fake-system" def test__query_test_plans__return_queried_test_plan( self, client: TestPlanClient, test_plan_create: CreateTestPlansRequest @@ -146,7 +146,7 @@ def test__query_test_plans__return_queried_test_plan( create_test_plan_response: CreateTestPlansResponse = client.create_test_plans( create_request=test_plan_create ) - created_test_plan = create_test_plan_response.createdTestPlans[0] + created_test_plan = create_test_plan_response.created_test_plans[0] query_test_plans_request = QueryTestPlansRequest( filter=f'id = "{created_test_plan.id}"', return_count=True @@ -174,32 +174,32 @@ def test__query_test_plans_with_projections__returns_the_test_plans_with_project assert all( test_plan.id is not None and test_plan.name is not None - and test_plan.templateId is None + and test_plan.template_id is None and test_plan.state is None and test_plan.substate is None and test_plan.description is None - and test_plan.assignedTo is None - and test_plan.workOrderId is None - and test_plan.workOrderName is None + and test_plan.assigned_to is None + and test_plan.work_order_id is None + and test_plan.work_order_name is None and test_plan.workspace is None - and test_plan.createdBy is None - and test_plan.updatedBy is None - and test_plan.createdAt is None - and test_plan.updatedAt is None + and test_plan.created_by is None + and test_plan.updated_at is None + and test_plan.created_At is None + and test_plan.updated_by is None and test_plan.properties is None - and test_plan.partNumber is None - and test_plan.dutId is None - and test_plan.testProgram is None - and test_plan.systemId is None - and test_plan.fixtureIds is None - and test_plan.systemFilter is None - and test_plan.plannedStartDateTime is None - and test_plan.estimatedEndDateTime is None - and test_plan.estimatedDurationInSeconds is None - and test_plan.fileIdsFromTemplate is None - and test_plan.executionActions is None - and test_plan.executionHistory is None - and test_plan.dashboardUrl is None + and test_plan.part_number is None + and test_plan.dut_id is None + and test_plan.test_program is None + and test_plan.system_filter is None + and test_plan.fixture_ids is None + and test_plan.system_id is None + and test_plan.planned_start_date_time is None + and test_plan.estimated_duration_in_seconds is None + and test_plan.estimated_end_date_time is None + and test_plan.file_ids_from_template is None + and test_plan.execution_actions is None + and test_plan.execution_history is None + and test_plan.dashboard_url is None and test_plan.dashboard is None and test_plan.workflow is None for test_plan in response.test_plans From 54445cdef3476ec0bb83b508ba74d721586a391c Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Wed, 21 May 2025 14:48:29 +0530 Subject: [PATCH 35/64] refactor --- .../test_plan/models/_schedule_test_plans_body_content.py | 5 +++-- .../clients/test_plan/test_plan/models/_test_plan.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_body_content.py b/nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_body_content.py index f744a190..b8f3a4cc 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_body_content.py +++ b/nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_body_content.py @@ -1,3 +1,4 @@ +from datetime import datetime from typing import List, Optional from nisystemlink.clients.core._uplink._json_model import JsonModel @@ -18,10 +19,10 @@ class ScheduleTestPlanBodyContent(JsonModel): system_id: Optional[str] = None """(Optional) Identifier for the system where the test plan will run.""" - planned_start_date_time: Optional[str] = None + planned_start_date_time: Optional[datetime] = None """(Optional) Planned start date and time for the test plan execution (ISO 8601 format).""" - estimated_end_date_time: Optional[str] = None + estimated_end_date_time: Optional[datetime] = None """(Optional) Estimated end date and time for the test plan execution (ISO 8601 format).""" estimated_duration_in_seconds: Optional[int] = None diff --git a/nisystemlink/clients/test_plan/test_plan/models/_test_plan.py b/nisystemlink/clients/test_plan/test_plan/models/_test_plan.py index 1efae9df..d26e80fe 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/_test_plan.py +++ b/nisystemlink/clients/test_plan/test_plan/models/_test_plan.py @@ -1,3 +1,4 @@ +from datetime import datetime from typing import Dict, List, Optional from nisystemlink.clients.core._uplink._json_model import JsonModel @@ -74,10 +75,10 @@ class TestPlan(JsonModel): system_filter: Optional[str] = None """The filter used to select systems for the test plan.""" - planned_start_date_time: Optional[str] = None + planned_start_date_time: Optional[datetime] = None """The planned start date and time for the test plan.""" - estimated_end_date_time: Optional[str] = None + estimated_end_date_time: Optional[datetime] = None """The estimated end date and time for the test plan.""" estimated_duration_in_seconds: Optional[float] = None From 585f0b9cb449c5be18324aded5f523454ae57d5e Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Wed, 21 May 2025 16:24:43 +0530 Subject: [PATCH 36/64] enum update --- .../test_plan/test_plan/_test_plan_client.py | 35 +++++++++- .../test_plan/test_plan/models/__init__.py | 6 +- .../models/_query_test_plans_request.py | 66 +++++++++---------- .../test_plan/test_plans/test_test_plans.py | 22 +++++-- 4 files changed, 87 insertions(+), 42 deletions(-) diff --git a/nisystemlink/clients/test_plan/test_plan/_test_plan_client.py b/nisystemlink/clients/test_plan/test_plan/_test_plan_client.py index 97f6befe..7e6d32f4 100644 --- a/nisystemlink/clients/test_plan/test_plan/_test_plan_client.py +++ b/nisystemlink/clients/test_plan/test_plan/_test_plan_client.py @@ -7,6 +7,7 @@ from uplink import retry from .models import ( + _QueryTestPlansRequest, CreateTestPlansRequest, CreateTestPlansResponse, DeleteTestPlansRequest, @@ -82,6 +83,19 @@ def delete_test_plans(self, ids: DeleteTestPlansRequest) -> None: ... @post("query-testplans") + def __query_test_plans( + self, query_request: _QueryTestPlansRequest + ) -> QueryTestPlansResponse: + """Query test plans. + + Args: + query: The query to execute. + + Returns: + A QueryTestPlansResponse object containing test plans that match the query. + """ + ... + def query_test_plans( self, query_request: QueryTestPlansRequest ) -> QueryTestPlansResponse: @@ -93,7 +107,26 @@ def query_test_plans( Returns: A QueryTestPlansResponse object containing test plans that match the query. """ - ... + projection_str = ( + [projection.name for projection in query_request.projection] + if query_request.projection + else None + ) + query_params = { + "filter": query_request.filter, + "take": query_request.take, + "continuationToken": query_request.continuation_token, + "orderBy": query_request.order_by, + "descending": query_request.descending, + "return_count": query_request.return_count, + "projection": projection_str, + } + + query_params = {k: v for k, v in query_params.items() if v is not None} + + query_test_plans_request = _QueryTestPlansRequest(**query_params) + + return self.__query_test_plans(query_request=query_test_plans_request) @post("schedule-testplans") def schedule_test_plans( diff --git a/nisystemlink/clients/test_plan/test_plan/models/__init__.py b/nisystemlink/clients/test_plan/test_plan/models/__init__.py index b314a066..587d78bc 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/__init__.py +++ b/nisystemlink/clients/test_plan/test_plan/models/__init__.py @@ -5,7 +5,11 @@ from ._schedule_test_plans_response import ScheduleTestPlansResponse from ._delete_test_plans_request import DeleteTestPlansRequest from ._execution_event import ExecutionEvent -from ._query_test_plans_request import QueryTestPlansRequest, TestPlanField +from ._query_test_plans_request import ( + QueryTestPlansRequest, + TestPlanField, + _QueryTestPlansRequest, +) from ._query_test_plans_response import QueryTestPlansResponse from ._schedule_test_plans_request import ScheduleTestPlansRequest from ._state import State diff --git a/nisystemlink/clients/test_plan/test_plan/models/_query_test_plans_request.py b/nisystemlink/clients/test_plan/test_plan/models/_query_test_plans_request.py index 18ffef8c..749a460c 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/_query_test_plans_request.py +++ b/nisystemlink/clients/test_plan/test_plan/models/_query_test_plans_request.py @@ -1,42 +1,42 @@ -from enum import Enum +import enum from typing import List, Optional from nisystemlink.clients.core._uplink._json_model import JsonModel -class TestPlanField(str, Enum): +class TestPlanField(enum.Enum): """Model for an object describing an test plan with all of its properties.""" - ID = "id" - TEMPLATE_ID = "templateId" - NAME = "name" - STATE = "state" - SUBSTATE = "substate" - DESCRIPTION = "description" - ASSIGNED_TO = "assignedTo" - WORK_ORDER_ID = "workOrderId" - WORK_ORDER_NAME = "workOrderName" - WORKSPACE = "workspace" - CREATED_BY = "createdBy" - UPDATED_BY = "updatedBy" - CREATED_AT = "createdAt" - UPDATED_AT = "updatedAt" - PROPERTIES = "properties" - PART_NUMBER = "partNumber" - DUT_ID = "dutId" - TEST_PROGRAM = "testProgram" - SYSTEM_ID = "systemId" - FIXTURE_IDS = "fixtureIds" - SYSTEM_FILTER = "systemFilter" - PLANNED_START_DATE_TIME = "plannedStartDateTime" - ESTIMATED_END_DATE_TIME = "estimatedEndDateTime" - ESTIMATED_DURATION_IN_SECONDS = "estimatedDurationInSeconds" - FILE_IDS_FROM_TEMPLATE = "fileIdsFromTemplate" - EXECUTION_ACTIONS = "executionActions" - EXECUTION_HISTORY = "executionHistory" - DASHBOARD_URL = "dashboardUrl" - DASHBOARD = "dashboard" - WORKFLOW = "workflow" + ID = enum.auto() + TEMPLATE_ID = enum.auto() + NAME = enum.auto() + STATE = enum.auto() + SUBSTATE = enum.auto() + DESCRIPTION = enum.auto() + ASSIGNED_TO = enum.auto() + WORK_ORDER_ID = enum.auto() + WORK_ORDER_NAME = enum.auto() + WORKSPACE = enum.auto() + CREATED_BY = enum.auto() + UPDATED_BY = enum.auto() + CREATED_AT = enum.auto() + UPDATED_AT = enum.auto() + PROPERTIES = enum.auto() + PART_NUMBER = enum.auto() + DUT_ID = enum.auto() + TEST_PROGRAM = enum.auto() + SYSTEM_ID = enum.auto() + FIXTURE_IDS = enum.auto() + SYSTEM_FILTER = enum.auto() + PLANNED_START_DATE_TIME = enum.auto() + ESTIMATED_END_DATE_TIME = enum.auto() + ESTIMATED_DURATION_IN_SECONDS = enum.auto() + FILE_IDS_FROM_TEMPLATE = enum.auto() + EXECUTION_ACTIONS = enum.auto() + EXECUTION_HISTORY = enum.auto() + DASHBOARD_URL = enum.auto() + DASHBOARD = enum.auto() + WORKFLOW = enum.auto() class QueryTestPlansRequest(JsonModel): @@ -92,7 +92,7 @@ class _QueryTestPlansRequest(JsonModel): continuation_token: Optional[str] = None """A token to retrieve the next page of results for paginated queries.""" - projection: Optional[str] = None + projection: Optional[List[str]] = None """Gets or sets the projection to be used when retrieving the assets. If not specified, all properties will be returned. """ diff --git a/tests/integration/test_plan/test_plans/test_test_plans.py b/tests/integration/test_plan/test_plans/test_test_plans.py index b9c39e17..11dd3857 100644 --- a/tests/integration/test_plan/test_plans/test_test_plans.py +++ b/tests/integration/test_plan/test_plans/test_test_plans.py @@ -1,3 +1,5 @@ +from datetime import datetime + import pytest from nisystemlink.clients.core._http_configuration import HttpConfiguration from nisystemlink.clients.test_plan.test_plan import TestPlanClient @@ -43,7 +45,7 @@ class TestTestPlans: def test__create_and_delete_test_plan__returns_created_and_deleted_test_plans( self, client: TestPlanClient, test_plan_create: CreateTestPlansRequest ): - create_test_plan_response: CreateTestPlansResponse = client.create_test_plans( + create_test_plan_response = client.create_test_plans( create_request=test_plan_create ) created_test_plan = create_test_plan_response.created_test_plans[0] @@ -63,7 +65,7 @@ def test__create_and_delete_test_plan__returns_created_and_deleted_test_plans( def test__get_test_plan__returns_get_test_plan( self, client: TestPlanClient, test_plan_create: CreateTestPlansRequest ): - create_test_plan_response: CreateTestPlansResponse = client.create_test_plans( + create_test_plan_response = client.create_test_plans( create_request=test_plan_create ) created_test_plan = create_test_plan_response.created_test_plans[0] @@ -82,7 +84,7 @@ def test__get_test_plan__returns_get_test_plan( def test__update_test_plan__returns_updated_test_plan( self, client: TestPlanClient, test_plan_create: CreateTestPlansRequest ): - create_test_plan_response: CreateTestPlansResponse = client.create_test_plans( + create_test_plan_response = client.create_test_plans( create_request=test_plan_create ) created_test_plan = create_test_plan_response.created_test_plans[0] @@ -112,7 +114,7 @@ def test__update_test_plan__returns_updated_test_plan( def test__schedule_test_plan__returns_scheduled_test_plan( self, client: TestPlanClient, test_plan_create: CreateTestPlansRequest ): - create_test_plan_response: CreateTestPlansResponse = client.create_test_plans( + create_test_plan_response = client.create_test_plans( create_request=test_plan_create ) created_test_plan = create_test_plan_response.created_test_plans[0] @@ -121,8 +123,12 @@ def test__schedule_test_plan__returns_scheduled_test_plan( test_plans=[ ScheduleTestPlanBodyContent( id=created_test_plan.id, - planned_start_date_time="2025-05-20T15:07:42.527Z", - estimated_end_date_time="2025-05-20T15:07:42.527Z", + planned_start_date_time=datetime.strptime( + "2025-05-20T15:07:42.527Z", "%Y-%m-%dT%H:%M:%S.%fZ" + ), + estimated_end_date_time=datetime.strptime( + "2025-05-22T15:07:42.527Z", "%Y-%m-%dT%H:%M:%S.%fZ" + ), system_id="fake-system", ) ] @@ -137,7 +143,9 @@ def test__schedule_test_plan__returns_scheduled_test_plan( assert schedule_test_plans_response is not None scheduled_test_plan = schedule_test_plans_response.scheduled_test_plans[0] assert scheduled_test_plan.id == created_test_plan.id - assert scheduled_test_plan.planned_start_date_time == "2025-05-20T15:07:42.527Z" + assert scheduled_test_plan.planned_start_date_time == datetime.strptime( + "2025-05-20T15:07:42.527Z", "%Y-%m-%dT%H:%M:%S.%fZ" + ) assert scheduled_test_plan.system_id == "fake-system" def test__query_test_plans__return_queried_test_plan( From 3ee9e7ab067539a8a99df0fa8df4ae1dba4528a0 Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Wed, 21 May 2025 16:45:26 +0530 Subject: [PATCH 37/64] query request refactor --- nisystemlink/clients/test_plan/test_plan/_test_plan_client.py | 4 ++-- .../test_plan/{test_plans => test_plan}/__init__.py | 0 .../test_plan/{test_plans => test_plan}/test_test_plans.py | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename tests/integration/test_plan/{test_plans => test_plan}/__init__.py (100%) rename tests/integration/test_plan/{test_plans => test_plan}/test_test_plans.py (100%) diff --git a/nisystemlink/clients/test_plan/test_plan/_test_plan_client.py b/nisystemlink/clients/test_plan/test_plan/_test_plan_client.py index 7e6d32f4..9af5feb2 100644 --- a/nisystemlink/clients/test_plan/test_plan/_test_plan_client.py +++ b/nisystemlink/clients/test_plan/test_plan/_test_plan_client.py @@ -115,8 +115,8 @@ def query_test_plans( query_params = { "filter": query_request.filter, "take": query_request.take, - "continuationToken": query_request.continuation_token, - "orderBy": query_request.order_by, + "continuation_token": query_request.continuation_token, + "order_by": query_request.order_by, "descending": query_request.descending, "return_count": query_request.return_count, "projection": projection_str, diff --git a/tests/integration/test_plan/test_plans/__init__.py b/tests/integration/test_plan/test_plan/__init__.py similarity index 100% rename from tests/integration/test_plan/test_plans/__init__.py rename to tests/integration/test_plan/test_plan/__init__.py diff --git a/tests/integration/test_plan/test_plans/test_test_plans.py b/tests/integration/test_plan/test_plan/test_test_plans.py similarity index 100% rename from tests/integration/test_plan/test_plans/test_test_plans.py rename to tests/integration/test_plan/test_plan/test_test_plans.py From 7c77939a179f53df506969bff4be1974e86ac6c0 Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Wed, 21 May 2025 20:39:14 +0530 Subject: [PATCH 38/64] test constant update --- .../test_plan/test_plan/test_test_plans.py | 52 ++++++++----------- 1 file changed, 21 insertions(+), 31 deletions(-) diff --git a/tests/integration/test_plan/test_plan/test_test_plans.py b/tests/integration/test_plan/test_plan/test_test_plans.py index 11dd3857..117d2a26 100644 --- a/tests/integration/test_plan/test_plan/test_test_plans.py +++ b/tests/integration/test_plan/test_plan/test_test_plans.py @@ -19,20 +19,6 @@ ) -@pytest.fixture(scope="class") -def test_plan_create() -> CreateTestPlansRequest: - """Fixture to create create test plan object.""" - testPlan = CreateTestPlansRequest( - testPlans=[ - CreateTestPlanBodyContent( - name="Python integration test plan", state="NEW", part_number="px40482" - ) - ] - ) - - return testPlan - - @pytest.fixture(scope="class") def client(enterprise_config: HttpConfiguration) -> TestPlanClient: """Fixture to create a TestPlansClient instance""" @@ -42,11 +28,21 @@ def client(enterprise_config: HttpConfiguration) -> TestPlanClient: @pytest.mark.integration @pytest.mark.enterprise class TestTestPlans: + + _test_plan_create = CreateTestPlansRequest( + testPlans=[ + CreateTestPlanBodyContent( + name="Python integration test plan", state="NEW", part_number="px40482" + ) + ] + ) + """create test plan object.""" + def test__create_and_delete_test_plan__returns_created_and_deleted_test_plans( - self, client: TestPlanClient, test_plan_create: CreateTestPlansRequest + self, client: TestPlanClient ): create_test_plan_response = client.create_test_plans( - create_request=test_plan_create + create_request=self._test_plan_create ) created_test_plan = create_test_plan_response.created_test_plans[0] @@ -62,11 +58,9 @@ def test__create_and_delete_test_plan__returns_created_and_deleted_test_plans( assert get_test_plan_response is not None assert get_test_plan_response.name == "Python integration test plan" - def test__get_test_plan__returns_get_test_plan( - self, client: TestPlanClient, test_plan_create: CreateTestPlansRequest - ): + def test__get_test_plan__returns_get_test_plan(self, client: TestPlanClient): create_test_plan_response = client.create_test_plans( - create_request=test_plan_create + create_request=self._test_plan_create ) created_test_plan = create_test_plan_response.created_test_plans[0] @@ -81,11 +75,9 @@ def test__get_test_plan__returns_get_test_plan( assert isinstance(get_test_plan_response, TestPlan) assert get_test_plan_response.id == created_test_plan.id - def test__update_test_plan__returns_updated_test_plan( - self, client: TestPlanClient, test_plan_create: CreateTestPlansRequest - ): + def test__update_test_plan__returns_updated_test_plan(self, client: TestPlanClient): create_test_plan_response = client.create_test_plans( - create_request=test_plan_create + create_request=self._test_plan_create ) created_test_plan = create_test_plan_response.created_test_plans[0] @@ -112,10 +104,10 @@ def test__update_test_plan__returns_updated_test_plan( assert updated_test_plan.name == "Updated Test Plan" def test__schedule_test_plan__returns_scheduled_test_plan( - self, client: TestPlanClient, test_plan_create: CreateTestPlansRequest + self, client: TestPlanClient ): create_test_plan_response = client.create_test_plans( - create_request=test_plan_create + create_request=self._test_plan_create ) created_test_plan = create_test_plan_response.created_test_plans[0] @@ -148,11 +140,9 @@ def test__schedule_test_plan__returns_scheduled_test_plan( ) assert scheduled_test_plan.system_id == "fake-system" - def test__query_test_plans__return_queried_test_plan( - self, client: TestPlanClient, test_plan_create: CreateTestPlansRequest - ): + def test__query_test_plans__return_queried_test_plan(self, client: TestPlanClient): create_test_plan_response: CreateTestPlansResponse = client.create_test_plans( - create_request=test_plan_create + create_request=self._test_plan_create ) created_test_plan = create_test_plan_response.created_test_plans[0] @@ -171,7 +161,7 @@ def test__query_test_plans__return_queried_test_plan( assert queried_test_plans_response.total_count > 0 def test__query_test_plans_with_projections__returns_the_test_plans_with_projected_properties( - self, client: TestPlanClient, test_plan_create: CreateTestPlansRequest + self, client: TestPlanClient ): query_test_plans_request = QueryTestPlansRequest( projection=[TestPlanField.ID, TestPlanField.NAME] From 32f6f8a4da5d0e653804963951a9a37da80492a8 Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Thu, 22 May 2025 11:15:40 +0530 Subject: [PATCH 39/64] resolving PR comments --- examples/test_plan/test_plan/test_plan.py | 18 +++++++++--------- .../test_plan/test_plan/models/__init__.py | 7 ++++--- ...content.py => _create_test_plan_request.py} | 2 +- .../models/_create_test_plans_request.py | 4 ++-- .../models/_create_test_plans_response.py | 4 ++-- .../test_plan/models/_execution_event.py | 14 +++++++++++--- .../test_plan/test_plan/models/_order_by.py | 8 ++++++++ .../models/_query_test_plans_request.py | 6 ++++-- ...ntent.py => _schedule_test_plan_request.py} | 2 +- .../models/_schedule_test_plans_request.py | 4 ++-- .../models/_schedule_test_plans_response.py | 4 ++-- .../test_plan/test_plan/models/_state.py | 16 ++++++++-------- ...content.py => _update_test_plan_request.py} | 2 +- .../models/_update_test_plans_request.py | 4 ++-- .../models/_update_test_plans_response.py | 5 +++-- .../test_plan/test_plan/test_test_plans.py | 14 +++++++------- 16 files changed, 67 insertions(+), 47 deletions(-) rename nisystemlink/clients/test_plan/test_plan/models/{_create_test_plan_body_content.py => _create_test_plan_request.py} (97%) create mode 100644 nisystemlink/clients/test_plan/test_plan/models/_order_by.py rename nisystemlink/clients/test_plan/test_plan/models/{_schedule_test_plans_body_content.py => _schedule_test_plan_request.py} (96%) rename nisystemlink/clients/test_plan/test_plan/models/{_update_test_plans_body_content.py => _update_test_plan_request.py} (96%) diff --git a/examples/test_plan/test_plan/test_plan.py b/examples/test_plan/test_plan/test_plan.py index a9da6755..c2987ae6 100644 --- a/examples/test_plan/test_plan/test_plan.py +++ b/examples/test_plan/test_plan/test_plan.py @@ -1,12 +1,12 @@ from nisystemlink.clients.core._http_configuration import HttpConfiguration from nisystemlink.clients.test_plan.test_plan import TestPlanClient from nisystemlink.clients.test_plan.test_plan.models import ( - CreateTestPlanBodyContent, + CreateTestPlanRequest, CreateTestPlansRequest, QueryTestPlansRequest, - ScheduleTestPlanBodyContent, + ScheduleTestPlanRequest, ScheduleTestPlansRequest, - UpdateTestPlanBodyContent, + UpdateTestPlanRequest, UpdateTestPlansRequest, ) @@ -19,7 +19,7 @@ create_test_plans_request = CreateTestPlansRequest( testPlans=[ - CreateTestPlanBodyContent( + CreateTestPlanRequest( name="Python integration test plan", state="NEW", partNumber="px40482" ) ] @@ -28,7 +28,7 @@ # create a test plan created_test_plans = client.create_test_plans(create_request=create_test_plans_request) -created_test_plan_id = created_test_plans.createdTestPlans[0].id +created_test_plan_id = created_test_plans.created_test_plans[0].id # Query test plan using id. query_test_plans_request = QueryTestPlansRequest( @@ -45,18 +45,18 @@ # Update test plan update_test_plans_request = UpdateTestPlansRequest( testPlans=[ - UpdateTestPlanBodyContent( + UpdateTestPlanRequest( id=created_test_plan_id, name="Updated Test Plan", ) ] ) -updated_test_plan = client.update_test_plan(update_request=update_test_plans_request) +updated_test_plan = client.update_test_plans(update_request=update_test_plans_request) # Schedule the test plan schedule_test_plans_request = ScheduleTestPlansRequest( test_plans=[ - ScheduleTestPlanBodyContent( + ScheduleTestPlanRequest( id=created_test_plan_id, planned_start_date_time="2025-05-20T15:07:42.527Z", estimated_end_date_time="2025-05-20T15:07:42.527Z", @@ -64,7 +64,7 @@ ) ] ) -schedule_test_plan_response = client.schedule_test_plan( +schedule_test_plan_response = client.schedule_test_plans( schedule_request=schedule_test_plans_request ) diff --git a/nisystemlink/clients/test_plan/test_plan/models/__init__.py b/nisystemlink/clients/test_plan/test_plan/models/__init__.py index 587d78bc..7f14d920 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/__init__.py +++ b/nisystemlink/clients/test_plan/test_plan/models/__init__.py @@ -1,7 +1,7 @@ from ._create_test_plans_request import CreateTestPlansRequest -from ._create_test_plan_body_content import CreateTestPlanBodyContent +from ._create_test_plan_request import CreateTestPlanRequest from ._create_test_plans_response import CreateTestPlansResponse -from ._schedule_test_plans_body_content import ScheduleTestPlanBodyContent +from ._schedule_test_plan_request import ScheduleTestPlanRequest from ._schedule_test_plans_response import ScheduleTestPlansResponse from ._delete_test_plans_request import DeleteTestPlansRequest from ._execution_event import ExecutionEvent @@ -14,9 +14,10 @@ from ._schedule_test_plans_request import ScheduleTestPlansRequest from ._state import State from ._test_plan import TestPlan -from ._update_test_plans_body_content import UpdateTestPlanBodyContent +from ._update_test_plan_request import UpdateTestPlanRequest from ._update_test_plans_request import UpdateTestPlansRequest from ._update_test_plans_response import UpdateTestPlansResponse from ._workflow_definition import WorkflowDefinition +from ._order_by import OrderBy # flake8: noqa diff --git a/nisystemlink/clients/test_plan/test_plan/models/_create_test_plan_body_content.py b/nisystemlink/clients/test_plan/test_plan/models/_create_test_plan_request.py similarity index 97% rename from nisystemlink/clients/test_plan/test_plan/models/_create_test_plan_body_content.py rename to nisystemlink/clients/test_plan/test_plan/models/_create_test_plan_request.py index 4b1d7629..5de730a6 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/_create_test_plan_body_content.py +++ b/nisystemlink/clients/test_plan/test_plan/models/_create_test_plan_request.py @@ -15,7 +15,7 @@ class Dashboard(JsonModel): """Variables for the dashboard""" -class CreateTestPlanBodyContent(JsonModel): +class CreateTestPlanRequest(JsonModel): """Represents the request body content for creating a test plan.""" name: Optional[str] = None diff --git a/nisystemlink/clients/test_plan/test_plan/models/_create_test_plans_request.py b/nisystemlink/clients/test_plan/test_plan/models/_create_test_plans_request.py index a0f15257..db0edbaf 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/_create_test_plans_request.py +++ b/nisystemlink/clients/test_plan/test_plan/models/_create_test_plans_request.py @@ -2,13 +2,13 @@ from nisystemlink.clients.core._uplink._json_model import JsonModel -from ._create_test_plan_body_content import CreateTestPlanBodyContent +from ._create_test_plan_request import CreateTestPlanRequest class CreateTestPlansRequest(JsonModel): """Represents the request body for creating multiple test plans.""" - test_plans: Optional[List[CreateTestPlanBodyContent]] = None + test_plans: Optional[List[CreateTestPlanRequest]] = None """ A list of test plan creation request bodies. Each item in the list contains the content required to create an individual test plan. diff --git a/nisystemlink/clients/test_plan/test_plan/models/_create_test_plans_response.py b/nisystemlink/clients/test_plan/test_plan/models/_create_test_plans_response.py index 92f4b952..ff5afaef 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/_create_test_plans_response.py +++ b/nisystemlink/clients/test_plan/test_plan/models/_create_test_plans_response.py @@ -2,7 +2,7 @@ from nisystemlink.clients.core._uplink._json_model import JsonModel -from ._create_test_plan_body_content import CreateTestPlanBodyContent +from ._create_test_plan_request import CreateTestPlanRequest from ._test_plan import TestPlan @@ -17,5 +17,5 @@ class CreateTestPlansResponse(JsonModel): created_test_plans: Optional[List[TestPlan]] = None """List of test plans that were successfully created.""" - failed_test_plans: Optional[List[CreateTestPlanBodyContent]] = None + failed_test_plans: Optional[List[CreateTestPlanRequest]] = None """List of test plans that failed to be created, with their request body content.""" diff --git a/nisystemlink/clients/test_plan/test_plan/models/_execution_event.py b/nisystemlink/clients/test_plan/test_plan/models/_execution_event.py index 3d7c12ef..2b1d7808 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/_execution_event.py +++ b/nisystemlink/clients/test_plan/test_plan/models/_execution_event.py @@ -4,17 +4,21 @@ class ExecutionEventBase(JsonModel): - action: Optional[str] = None """Base class for execution events, containing common attributes such as action.""" + action: Optional[str] = None + """The user-defined action that initiated the event.""" + triggered_at: Optional[str] = None - """the time the event was triggered.""" + """The time the event was triggered.""" triggered_by: Optional[str] = None - """and the user who triggered it.""" + """The user who triggered the event.""" class NotebookExecutionEvent(ExecutionEventBase): + """Represents an execution event that was triggered by a notebook execution.""" + type: Optional[str] = "NOTEBOOK" """Represents an execution event triggered by a notebook.""" @@ -23,6 +27,8 @@ class NotebookExecutionEvent(ExecutionEventBase): class JobExecutionEvent(ExecutionEventBase): + """A concrete execution event that represents an event triggered by a job.""" + type: Optional[str] = "JOB" """Represents an execution event triggered by a job.""" @@ -31,6 +37,8 @@ class JobExecutionEvent(ExecutionEventBase): class ManualExecutionEvent(ExecutionEventBase): + """A concrete execution event that represents an event triggered manually.""" + type: Optional[str] = "MANUAL" """Represents an execution event triggered manually. Includes only the type identifier.""" diff --git a/nisystemlink/clients/test_plan/test_plan/models/_order_by.py b/nisystemlink/clients/test_plan/test_plan/models/_order_by.py new file mode 100644 index 00000000..546aeafd --- /dev/null +++ b/nisystemlink/clients/test_plan/test_plan/models/_order_by.py @@ -0,0 +1,8 @@ +from enum import Enum + + +class OrderBy(Enum): + """The state of the test plan.""" + + ID = "ID" + UPDATE_AT = "UPDATE_AT" diff --git a/nisystemlink/clients/test_plan/test_plan/models/_query_test_plans_request.py b/nisystemlink/clients/test_plan/test_plan/models/_query_test_plans_request.py index 749a460c..e94411a1 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/_query_test_plans_request.py +++ b/nisystemlink/clients/test_plan/test_plan/models/_query_test_plans_request.py @@ -3,6 +3,8 @@ from nisystemlink.clients.core._uplink._json_model import JsonModel +from ._order_by import OrderBy + class TestPlanField(enum.Enum): """Model for an object describing an test plan with all of its properties.""" @@ -50,7 +52,7 @@ class QueryTestPlansRequest(JsonModel): take: Optional[int] = None """The maximum number of test plans to return in the response.""" - order_by: Optional[str] = None + order_by: Optional[OrderBy] = None """The field name to use for sorting the test plans.""" descending: Optional[bool] = None @@ -62,7 +64,7 @@ class QueryTestPlansRequest(JsonModel): continuation_token: Optional[str] = None """A token to retrieve the next page of results for paginated queries.""" - projection: List[TestPlanField] = [] + projection: Optional[List[TestPlanField]] = None """ Gets or sets the projection to be used when retrieving the assets. If not specified, all properties will be returned. diff --git a/nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_body_content.py b/nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plan_request.py similarity index 96% rename from nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_body_content.py rename to nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plan_request.py index b8f3a4cc..0c65bd46 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_body_content.py +++ b/nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plan_request.py @@ -4,7 +4,7 @@ from nisystemlink.clients.core._uplink._json_model import JsonModel -class ScheduleTestPlanBodyContent(JsonModel): +class ScheduleTestPlanRequest(JsonModel): """Represents the request body content for scheduling a test plan.""" id: str diff --git a/nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_request.py b/nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_request.py index aa62ee8a..eaff40d4 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_request.py +++ b/nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_request.py @@ -2,13 +2,13 @@ from nisystemlink.clients.core._uplink._json_model import JsonModel -from ._schedule_test_plans_body_content import ScheduleTestPlanBodyContent +from ._schedule_test_plan_request import ScheduleTestPlanRequest class ScheduleTestPlansRequest(JsonModel): """Represents the request body for scheduling multiple test plans.""" - test_plans: Optional[List[ScheduleTestPlanBodyContent]] + test_plans: Optional[List[ScheduleTestPlanRequest]] """List of test plan scheduling content objects.""" replace: Optional[bool] = None diff --git a/nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_response.py b/nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_response.py index 4bec5ca3..ee113a1d 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_response.py +++ b/nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_response.py @@ -2,7 +2,7 @@ from nisystemlink.clients.core._uplink._json_model import JsonModel -from ._schedule_test_plans_body_content import ScheduleTestPlanBodyContent +from ._schedule_test_plan_request import ScheduleTestPlanRequest from ._test_plan import TestPlan @@ -12,5 +12,5 @@ class ScheduleTestPlansResponse(JsonModel): scheduled_test_plans: Optional[List[TestPlan]] = None """(Optional) List of successfully scheduled test plans.""" - failed_test_plans: Optional[List[ScheduleTestPlanBodyContent]] = None + failed_test_plans: Optional[List[ScheduleTestPlanRequest]] = None """(Optional) List of test plan requests that failed to schedule.""" diff --git a/nisystemlink/clients/test_plan/test_plan/models/_state.py b/nisystemlink/clients/test_plan/test_plan/models/_state.py index ecc6f03d..cd727442 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/_state.py +++ b/nisystemlink/clients/test_plan/test_plan/models/_state.py @@ -4,11 +4,11 @@ class State(Enum): """The state of the test plan.""" - New = "NEW" - Defined = "DEFINED" - Reviewed = "REVIEWED" - Scheduled = "SCHEDULED" - InProgress = "IN_PROGRESS" - PendingApproval = "PENDING_APPROVAL" - Closed = "CLOSED" - Canceled = "CANCELED" + NEW = "NEW" + DEFINED = "DEFINED" + REVIEWED = "REVIEWED" + SCHEDULED = "SCHEDULED" + IN_PROGRESS = "IN_PROGRESS" + PENDING_APPROVAL = "PENDING_APPROVAL" + CLOSED = "CLOSED" + CANCELED = "CANCELED" diff --git a/nisystemlink/clients/test_plan/test_plan/models/_update_test_plans_body_content.py b/nisystemlink/clients/test_plan/test_plan/models/_update_test_plan_request.py similarity index 96% rename from nisystemlink/clients/test_plan/test_plan/models/_update_test_plans_body_content.py rename to nisystemlink/clients/test_plan/test_plan/models/_update_test_plan_request.py index 92d8efd5..da765047 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/_update_test_plans_body_content.py +++ b/nisystemlink/clients/test_plan/test_plan/models/_update_test_plan_request.py @@ -3,7 +3,7 @@ from nisystemlink.clients.core._uplink._json_model import JsonModel -class UpdateTestPlanBodyContent(JsonModel): +class UpdateTestPlanRequest(JsonModel): """Represents the content for updating a single test plan.""" id: str diff --git a/nisystemlink/clients/test_plan/test_plan/models/_update_test_plans_request.py b/nisystemlink/clients/test_plan/test_plan/models/_update_test_plans_request.py index b9a9abf9..ff4c820f 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/_update_test_plans_request.py +++ b/nisystemlink/clients/test_plan/test_plan/models/_update_test_plans_request.py @@ -2,13 +2,13 @@ from nisystemlink.clients.core._uplink._json_model import JsonModel -from . import UpdateTestPlanBodyContent +from ._update_test_plan_request import UpdateTestPlanRequest class UpdateTestPlansRequest(JsonModel): """Represents the request body for updating multiple test plans.""" - test_plans: List[UpdateTestPlanBodyContent] + test_plans: List[UpdateTestPlanRequest] """A list of test plans to update.""" replace: Optional[bool] = None diff --git a/nisystemlink/clients/test_plan/test_plan/models/_update_test_plans_response.py b/nisystemlink/clients/test_plan/test_plan/models/_update_test_plans_response.py index a2e68c02..aa767c09 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/_update_test_plans_response.py +++ b/nisystemlink/clients/test_plan/test_plan/models/_update_test_plans_response.py @@ -2,7 +2,8 @@ from nisystemlink.clients.core._uplink._json_model import JsonModel -from . import TestPlan, UpdateTestPlanBodyContent +from ._test_plan import TestPlan +from ._update_test_plan_request import UpdateTestPlanRequest class UpdateTestPlansResponse(JsonModel): @@ -11,5 +12,5 @@ class UpdateTestPlansResponse(JsonModel): updated_test_plans: Optional[List[TestPlan]] = None """List of successfully updated test plans.""" - failed_test_plans: Optional[List[UpdateTestPlanBodyContent]] = None + failed_test_plans: Optional[List[UpdateTestPlanRequest]] = None """List of test plans that failed to update.""" diff --git a/tests/integration/test_plan/test_plan/test_test_plans.py b/tests/integration/test_plan/test_plan/test_test_plans.py index 117d2a26..0b3c2fca 100644 --- a/tests/integration/test_plan/test_plan/test_test_plans.py +++ b/tests/integration/test_plan/test_plan/test_test_plans.py @@ -4,17 +4,17 @@ from nisystemlink.clients.core._http_configuration import HttpConfiguration from nisystemlink.clients.test_plan.test_plan import TestPlanClient from nisystemlink.clients.test_plan.test_plan.models import ( - CreateTestPlanBodyContent, + CreateTestPlanRequest, CreateTestPlansRequest, CreateTestPlansResponse, DeleteTestPlansRequest, QueryTestPlansRequest, - ScheduleTestPlanBodyContent, + ScheduleTestPlanRequest, ScheduleTestPlansRequest, State, TestPlan, TestPlanField, - UpdateTestPlanBodyContent, + UpdateTestPlanRequest, UpdateTestPlansRequest, ) @@ -31,7 +31,7 @@ class TestTestPlans: _test_plan_create = CreateTestPlansRequest( testPlans=[ - CreateTestPlanBodyContent( + CreateTestPlanRequest( name="Python integration test plan", state="NEW", part_number="px40482" ) ] @@ -53,7 +53,7 @@ def test__create_and_delete_test_plan__returns_created_and_deleted_test_plans( assert created_test_plan is not None assert created_test_plan.name == "Python integration test plan" - assert created_test_plan.state == State.New + assert created_test_plan.state == State.NEW assert created_test_plan.part_number == "px40482" assert get_test_plan_response is not None assert get_test_plan_response.name == "Python integration test plan" @@ -83,7 +83,7 @@ def test__update_test_plan__returns_updated_test_plan(self, client: TestPlanClie update_test_plans_request = UpdateTestPlansRequest( testPlans=[ - UpdateTestPlanBodyContent( + UpdateTestPlanRequest( id=created_test_plan.id, name="Updated Test Plan", ) @@ -113,7 +113,7 @@ def test__schedule_test_plan__returns_scheduled_test_plan( schedule_test_plans_request = ScheduleTestPlansRequest( test_plans=[ - ScheduleTestPlanBodyContent( + ScheduleTestPlanRequest( id=created_test_plan.id, planned_start_date_time=datetime.strptime( "2025-05-20T15:07:42.527Z", "%Y-%m-%dT%H:%M:%S.%fZ" From aca8441da3b01702dfbf1d95d147d2bec86ac039 Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Thu, 22 May 2025 11:45:43 +0530 Subject: [PATCH 40/64] add api errors --- .../test_plan/models/_create_test_plans_response.py | 4 ++++ .../test_plan/models/_schedule_test_plans_response.py | 5 +++++ .../test_plan/models/_update_test_plans_response.py | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/nisystemlink/clients/test_plan/test_plan/models/_create_test_plans_response.py b/nisystemlink/clients/test_plan/test_plan/models/_create_test_plans_response.py index ff5afaef..4c900278 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/_create_test_plans_response.py +++ b/nisystemlink/clients/test_plan/test_plan/models/_create_test_plans_response.py @@ -1,5 +1,6 @@ from typing import List, Optional +from nisystemlink.clients.core._api_error import ApiError from nisystemlink.clients.core._uplink._json_model import JsonModel from ._create_test_plan_request import CreateTestPlanRequest @@ -19,3 +20,6 @@ class CreateTestPlansResponse(JsonModel): failed_test_plans: Optional[List[CreateTestPlanRequest]] = None """List of test plans that failed to be created, with their request body content.""" + + error: Optional[ApiError] = None + """The error that occurred when creating the test plans.""" diff --git a/nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_response.py b/nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_response.py index ee113a1d..f39a780f 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_response.py +++ b/nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_response.py @@ -1,5 +1,6 @@ from typing import List, Optional +from nisystemlink.clients.core._api_error import ApiError from nisystemlink.clients.core._uplink._json_model import JsonModel from ._schedule_test_plan_request import ScheduleTestPlanRequest @@ -14,3 +15,7 @@ class ScheduleTestPlansResponse(JsonModel): failed_test_plans: Optional[List[ScheduleTestPlanRequest]] = None """(Optional) List of test plan requests that failed to schedule.""" + + error: Optional[ApiError] = None + """The error that occurred when scheduling the test plans.""" + \ No newline at end of file diff --git a/nisystemlink/clients/test_plan/test_plan/models/_update_test_plans_response.py b/nisystemlink/clients/test_plan/test_plan/models/_update_test_plans_response.py index aa767c09..162fe9a6 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/_update_test_plans_response.py +++ b/nisystemlink/clients/test_plan/test_plan/models/_update_test_plans_response.py @@ -1,5 +1,6 @@ from typing import List, Optional +from nisystemlink.clients.core._api_error import ApiError from nisystemlink.clients.core._uplink._json_model import JsonModel from ._test_plan import TestPlan @@ -14,3 +15,6 @@ class UpdateTestPlansResponse(JsonModel): failed_test_plans: Optional[List[UpdateTestPlanRequest]] = None """List of test plans that failed to update.""" + + error: Optional[ApiError] = None + """The error that occurred when updating the test plans.""" From a62104c70ba8da218e2b5c4184d83117e0f6cbe2 Mon Sep 17 00:00:00 2001 From: Ammar Husain Mian Fazulul Date: Thu, 22 May 2025 13:06:52 +0530 Subject: [PATCH 41/64] update as per comment --- .../test_plan/models/_execution_definition.py | 38 ++++++++++--------- .../_test_plan_templates_client.py | 5 +-- .../test_plan_templates/models/__init__.py | 8 ++-- ...plan_templates_partial_success_response.py | 4 +- .../models/_paged_test_plan_templates.py | 18 +++++++++ .../_query_test_plan_templates_request.py | 9 +---- .../_query_test_plan_templates_response.py | 21 ---------- .../models/_test_plan_templates.py | 26 ++++++++++--- .../test_test_plan_template.py | 14 +++---- 9 files changed, 74 insertions(+), 69 deletions(-) create mode 100644 nisystemlink/clients/test_plan/test_plan_templates/models/_paged_test_plan_templates.py delete mode 100644 nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates_response.py diff --git a/nisystemlink/clients/test_plan/models/_execution_definition.py b/nisystemlink/clients/test_plan/models/_execution_definition.py index 7f633022..52520146 100644 --- a/nisystemlink/clients/test_plan/models/_execution_definition.py +++ b/nisystemlink/clients/test_plan/models/_execution_definition.py @@ -1,6 +1,7 @@ -from typing import List, Union +from typing import Annotated, Any, List, Literal, Optional, Union from nisystemlink.clients.core._uplink._json_model import JsonModel +from pydantic import Field class Job(JsonModel): @@ -9,10 +10,10 @@ class Job(JsonModel): functions: List[str] """List of function names to execute.""" - arguments: List[List[object]] + arguments: List[List[Any]] """List of argument lists for each function.""" - metadata: dict[str, object] + metadata: dict[str, Any] """Additional metadata for the job.""" @@ -22,7 +23,7 @@ class NotebookExecution(JsonModel): action: str """User defined action to perform in workflow (user defined).""" - type: str = "NOTEBOOK" + type: Literal["NOTEBOOK"] = Field(default="NOTEBOOK") """Type of execution, default is 'NOTEBOOK'.""" notebookId: str @@ -35,7 +36,7 @@ class ManualExecution(JsonModel): action: str """User defined action to perform in workflow (user defined).""" - type: str = "MANUAL" + type: Literal["MANUAL"] = Field(default="MANUAL") """Type of execution, default is 'MANUAL'.""" @@ -45,13 +46,13 @@ class JobExecution(JsonModel): action: str """User defined action to perform in workflow (user defined).""" - type: str = "JOB" + type: Literal["JOB"] = Field(default="JOB") """Type of execution, default is 'JOB'.""" jobs: List[Job] """List of jobs to execute.""" - systemId: str | None = None + systemId: Optional[str] = None """Optional system ID where jobs will run.""" @@ -61,7 +62,7 @@ class ScheduleExecution(JsonModel): action: str """User defined action to perform in workflow (user defined).""" - type: str = "SCHEDULE" + type: Literal["SCHEDULE"] = Field(default="SCHEDULE") """Type of execution, default is 'SCHEDULE'.""" @@ -71,7 +72,7 @@ class UnscheduleExecution(JsonModel): action: str """User defined action to perform in workflow (user defined).""" - type: str = "UNSCHEDULE" + type: Literal["UNSCHEDULE"] = Field(default="UNSCHEDULE") """Type of execution, default is 'UNSCHEDULE'.""" @@ -81,15 +82,18 @@ class NoneExecution(JsonModel): action: str """User defined action to perform in workflow (user defined).""" - type: str = "None" + type: Literal["None"] = Field(default="None") """Type of execution, default is 'None'.""" -ExecutionDefinition = Union[ - NotebookExecution, - ManualExecution, - JobExecution, - NoneExecution, - ScheduleExecution, - UnscheduleExecution, +ExecutionDefinition = Annotated[ + Union[ + NotebookExecution, + ManualExecution, + JobExecution, + ScheduleExecution, + UnscheduleExecution, + NoneExecution, + ], + Field(discriminator="type"), ] diff --git a/nisystemlink/clients/test_plan/test_plan_templates/_test_plan_templates_client.py b/nisystemlink/clients/test_plan/test_plan_templates/_test_plan_templates_client.py index 1f5d8ab3..65f9a3c6 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/_test_plan_templates_client.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/_test_plan_templates_client.py @@ -52,7 +52,7 @@ def create_test_plan_templates( @post("query-testplan-templates") def __query_test_plan_templates( self, query_test_plan_templates: models._QueryTestPlanTemplatesRequest - ) -> models.QueryTestPlanTemplatesResponse: + ) -> models.PagedTestPlanTemplates: """Queries one or more test plan templates and return errors for failed queries. Returns: A list of test plan templates, based on the query and errors for the wrong query. @@ -64,7 +64,7 @@ def __query_test_plan_templates( def query_test_plan_templates( self, query_test_plan_templates: models.QueryTestPlanTemplatesRequest - ) -> models.QueryTestPlanTemplatesResponse: + ) -> models.PagedTestPlanTemplates: """Queries one or more test plan templates and return errors for failed queries. Returns: A list of test plan templates, based on the query and errors for the wrong query. @@ -91,7 +91,6 @@ def query_test_plan_templates( query_request = models._QueryTestPlanTemplatesRequest(**query_params) - print(query_request) return self.__query_test_plan_templates(query_test_plan_templates=query_request) @post("delete-testplan-templates", args=[Field("ids")]) diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py b/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py index df468051..ee122be3 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py @@ -6,15 +6,15 @@ _QueryTestPlanTemplatesRequest, TestPlanTemplateField, ) -from nisystemlink.clients.test_plan.test_plan_templates.models._query_test_plan_templates_response import ( - QueryTestPlanTemplatesResponse, -) from nisystemlink.clients.test_plan.test_plan_templates.models._delete_test_plan_templates_partial_success_response import ( DeleteTestPlanTemplatesPartialSuccessResponse, ) from nisystemlink.clients.test_plan.test_plan_templates.models._test_plan_templates import ( TestPlanTemplateBase, - TestPlanTemplateResponse, + TestPlanTemplate, +) +from nisystemlink.clients.test_plan.test_plan_templates.models._paged_test_plan_templates import ( + PagedTestPlanTemplates, ) # flake8: noqa diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_create_test_plan_templates_partial_success_response.py b/nisystemlink/clients/test_plan/test_plan_templates/models/_create_test_plan_templates_partial_success_response.py index d361a8c9..c43be005 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/_create_test_plan_templates_partial_success_response.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/_create_test_plan_templates_partial_success_response.py @@ -3,12 +3,12 @@ from nisystemlink.clients.core._api_error import ApiError from nisystemlink.clients.core._uplink._json_model import JsonModel -from ._test_plan_templates import TestPlanTemplateBase, TestPlanTemplateResponse +from ._test_plan_templates import TestPlanTemplate, TestPlanTemplateBase class CreateTestPlanTemplatePartialSuccessResponse(JsonModel): - created_test_plan_templates: Optional[List[TestPlanTemplateResponse]] = None + created_test_plan_templates: Optional[List[TestPlanTemplate]] = None """The list of test plan templates that were successfully created.""" failed_test_plan_templates: Optional[List[TestPlanTemplateBase]] = None diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_paged_test_plan_templates.py b/nisystemlink/clients/test_plan/test_plan_templates/models/_paged_test_plan_templates.py new file mode 100644 index 00000000..0c3eb4e1 --- /dev/null +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/_paged_test_plan_templates.py @@ -0,0 +1,18 @@ +from typing import List, Optional + +from nisystemlink.clients.core._uplink._with_paging import WithPaging +from nisystemlink.clients.test_plan.test_plan_templates.models._test_plan_templates import ( + TestPlanTemplate, +) + + +class PagedTestPlanTemplates(WithPaging): + """The response containing the list of products, total count of products and the continuation + token if applicable. + """ + + test_plan_templates: List[TestPlanTemplate] + """A list of all the products in this page.""" + + total_count: Optional[int] = None + """The total number of products that match the query.""" diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates_request.py b/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates_request.py index 7b67ec24..c54552fe 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates_request.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates_request.py @@ -95,19 +95,12 @@ class QueryTestPlanTemplatesRequest(JsonModel): """Allows users to continue the query at the next test plan templates that matches the given criteria.""" - projection: List[TestPlanTemplateField] = [] + projection: Optional[List[TestPlanTemplateField]] = None """ Gets or sets the projection to be used when retrieving the assets. If not specified, all properties will be returned. """ - """ - To retrieve the next page of test plan templates, pass the continuation token from the previous - page in the next request. The service responds with the next page of data and provides a new - continuation token. To paginate results, continue sending requests with the newest continuation - token provided in each response. - """ - class _QueryTestPlanTemplatesRequest(JsonModel): """Request information for the query test plan templates API.""" diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates_response.py b/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates_response.py deleted file mode 100644 index 4d4934c8..00000000 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates_response.py +++ /dev/null @@ -1,21 +0,0 @@ -from typing import List, Optional - -from nisystemlink.clients.core._uplink._json_model import JsonModel -from nisystemlink.clients.test_plan.test_plan_templates.models._test_plan_templates import ( - TestPlanTemplateResponse, -) - - -class QueryTestPlanTemplatesResponse(JsonModel): - """Response information for the query test plan templates API.""" - - test_plan_templates: List[TestPlanTemplateResponse] - """Queried test plan templates.""" - - continuation_token: Optional[str] = None - """Allows users to continue the query at the next test plan templates that matches the given criteria. - - To retrieve the next page of test plan templates, pass the continuation token from the previous - page in the next request. The service responds with the next page of data and provides a new - continuation token. To paginate results, continue sending requests with the newest continuation - token provided in each response.""" diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py b/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py index 08435673..3a3d6a50 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py +++ b/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py @@ -1,3 +1,4 @@ +from datetime import datetime from typing import Dict, List, Optional from nisystemlink.clients.core._uplink._json_model import JsonModel @@ -12,7 +13,7 @@ class Dashboard(JsonModel): id: Optional[str] = None """The globally unique id of the dashboard.""" - variables: Dict[str, str] + variables: Optional[Dict[str, str]] = None """Dictionary of variables set on the dashboard. These will be appended to the URL as query parameters. Each key will be prefixed with "var-" and the value will be the value of the variable. @@ -22,10 +23,10 @@ class Dashboard(JsonModel): class TestPlanTemplateBase(JsonModel): """Contains information about a test plan template.""" - name: str | None + name: Optional[str] = None """Name of the test plan template.""" - template_group: str | None = None + template_group: Optional[str] = None """The template group defined by the user.""" product_families: Optional[List[str]] = None @@ -52,7 +53,8 @@ class TestPlanTemplateBase(JsonModel): """ execution_actions: Optional[List[ExecutionDefinition]] = None - """Defines the executions that will be used for test plan actions created from this template. + """Defines the executions that will be used for test plan actions + created from this template. """ file_ids: Optional[List[str]] = None @@ -70,7 +72,7 @@ class TestPlanTemplateBase(JsonModel): """Defines a dashboard reference for a test plan.""" -class TestPlanTemplateResponse(TestPlanTemplateBase): +class TestPlanTemplate(TestPlanTemplateBase): """Contains response information for test plan template.""" id: Optional[str] = None @@ -78,3 +80,17 @@ class TestPlanTemplateResponse(TestPlanTemplateBase): name: Optional[str] = None """Name of the test plan template.""" + + created_by: Optional[str] = None + """ID of the user who created the test plan template.""" + + updated_by: Optional[str] = None + """ID of the user who most recently updated the test plan template.""" + + created_at: Optional[datetime] = None + """ISO-8601 formatted timestamp indicating when the + test plan template was created.""" + + updated_at: Optional[datetime] = None + """ISO-8601 formatted timestamp indicating when the + test plan template was most recently updated.""" diff --git a/tests/integration/test_plan/test_plan_templates/test_test_plan_template.py b/tests/integration/test_plan/test_plan_templates/test_test_plan_template.py index 8afbe9ab..f550caee 100644 --- a/tests/integration/test_plan/test_plan_templates/test_test_plan_template.py +++ b/tests/integration/test_plan/test_plan_templates/test_test_plan_template.py @@ -2,15 +2,14 @@ import pytest from nisystemlink.clients.core._http_configuration import HttpConfiguration -from nisystemlink.clients.test_plan.models._execution_definition import ManualExecution from nisystemlink.clients.test_plan.test_plan_templates import TestPlanTemplateClient from nisystemlink.clients.test_plan.test_plan_templates.models import ( CreateTestPlanTemplatePartialSuccessResponse, + PagedTestPlanTemplates, QueryTestPlanTemplatesRequest, - QueryTestPlanTemplatesResponse, + TestPlanTemplate, TestPlanTemplateBase, TestPlanTemplateField, - TestPlanTemplateResponse, ) @@ -36,7 +35,7 @@ def _create_test_plan_templates( yield _create_test_plan_templates - created_test_plan_templates: List[TestPlanTemplateResponse] = [] + created_test_plan_templates: List[TestPlanTemplate] = [] for response in responses: if response.created_test_plan_templates: created_test_plan_templates = ( @@ -63,7 +62,6 @@ def test__create_test_plan_template__returns_created_test_plan_template( name="Python integration test plan template", templateGroup="sample template group", workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", - executionActions=[ManualExecution(action="TEST", type="MANUAl")], ) ] create_test_plan_template_response = create_test_plan_templates( @@ -92,7 +90,6 @@ def test__query_test_plan_template__returns_queried_test_plan_template( name="Python integration test plan template", templateGroup="sample template group", workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", - executionActions=[ManualExecution(action="TEST", type="MANUAl")], ) ] @@ -111,7 +108,7 @@ def test__query_test_plan_template__returns_queried_test_plan_template( query = QueryTestPlanTemplatesRequest(filter=f'id="{template_id}"', take=1) - query_test_plan_template_response: QueryTestPlanTemplatesResponse = ( + query_test_plan_template_response: PagedTestPlanTemplates = ( client.query_test_plan_templates(query_test_plan_templates=query) ) @@ -127,7 +124,6 @@ def test__delete_test_plan_template(self, client: TestPlanTemplateClient): name="Python integration test plan template", templateGroup="sample template group", workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", - executionActions=[ManualExecution(action="TEST", type="MANUAl")], ) ] create_test_plan_template_response: ( @@ -147,7 +143,7 @@ def test__delete_test_plan_template(self, client: TestPlanTemplateClient): client.delete_test_plan_templates(ids=[template_id]) - query_deleted_test_plan_template_response: QueryTestPlanTemplatesResponse = ( + query_deleted_test_plan_template_response: PagedTestPlanTemplates = ( client.query_test_plan_templates( query_test_plan_templates=QueryTestPlanTemplatesRequest( filter=f'id="{template_id}"', take=1 From 89aa933983605048a49d4087f5e4831ff06f66fd Mon Sep 17 00:00:00 2001 From: Ammar Husain Mian Fazulul Date: Thu, 22 May 2025 13:38:50 +0530 Subject: [PATCH 42/64] added test plan module --- .../test_plan/models/_execution_definition.py | 4 ++-- .../test_plan/test_plan/_test_plan_client.py | 15 +++++++------- .../test_plan/test_plan/models/__init__.py | 2 +- .../test_plan/models/_paged_test_plans.py | 16 +++++++++++++++ .../models/_query_test_plans_response.py | 20 ------------------- .../models/_schedule_test_plans_response.py | 1 - 6 files changed, 27 insertions(+), 31 deletions(-) create mode 100644 nisystemlink/clients/test_plan/test_plan/models/_paged_test_plans.py delete mode 100644 nisystemlink/clients/test_plan/test_plan/models/_query_test_plans_response.py diff --git a/nisystemlink/clients/test_plan/models/_execution_definition.py b/nisystemlink/clients/test_plan/models/_execution_definition.py index 52520146..6e9d8097 100644 --- a/nisystemlink/clients/test_plan/models/_execution_definition.py +++ b/nisystemlink/clients/test_plan/models/_execution_definition.py @@ -82,8 +82,8 @@ class NoneExecution(JsonModel): action: str """User defined action to perform in workflow (user defined).""" - type: Literal["None"] = Field(default="None") - """Type of execution, default is 'None'.""" + type: Literal["NONE"] = Field(default="NONE") + """Type of execution, default is 'NONE'.""" ExecutionDefinition = Annotated[ diff --git a/nisystemlink/clients/test_plan/test_plan/_test_plan_client.py b/nisystemlink/clients/test_plan/test_plan/_test_plan_client.py index 9af5feb2..3599e44c 100644 --- a/nisystemlink/clients/test_plan/test_plan/_test_plan_client.py +++ b/nisystemlink/clients/test_plan/test_plan/_test_plan_client.py @@ -4,15 +4,18 @@ from nisystemlink.clients.core._http_configuration import HttpConfiguration from nisystemlink.clients.core._uplink._base_client import BaseClient from nisystemlink.clients.core._uplink._methods import get, post +from nisystemlink.clients.test_plan.test_plan.models._paged_test_plans import ( + PagedTestPlans, +) from uplink import retry + from .models import ( _QueryTestPlansRequest, CreateTestPlansRequest, CreateTestPlansResponse, DeleteTestPlansRequest, QueryTestPlansRequest, - QueryTestPlansResponse, ScheduleTestPlansRequest, ScheduleTestPlansResponse, TestPlan, @@ -85,27 +88,25 @@ def delete_test_plans(self, ids: DeleteTestPlansRequest) -> None: @post("query-testplans") def __query_test_plans( self, query_request: _QueryTestPlansRequest - ) -> QueryTestPlansResponse: + ) -> PagedTestPlans: """Query test plans. Args: query: The query to execute. Returns: - A QueryTestPlansResponse object containing test plans that match the query. + A PagedTestPlans object containing test plans that match the query. """ ... - def query_test_plans( - self, query_request: QueryTestPlansRequest - ) -> QueryTestPlansResponse: + def query_test_plans(self, query_request: QueryTestPlansRequest) -> PagedTestPlans: """Query test plans. Args: query: The query to execute. Returns: - A QueryTestPlansResponse object containing test plans that match the query. + A PagedTestPlans object containing test plans that match the query. """ projection_str = ( [projection.name for projection in query_request.projection] diff --git a/nisystemlink/clients/test_plan/test_plan/models/__init__.py b/nisystemlink/clients/test_plan/test_plan/models/__init__.py index 7f14d920..53d40e2c 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/__init__.py +++ b/nisystemlink/clients/test_plan/test_plan/models/__init__.py @@ -10,7 +10,6 @@ TestPlanField, _QueryTestPlansRequest, ) -from ._query_test_plans_response import QueryTestPlansResponse from ._schedule_test_plans_request import ScheduleTestPlansRequest from ._state import State from ._test_plan import TestPlan @@ -19,5 +18,6 @@ from ._update_test_plans_response import UpdateTestPlansResponse from ._workflow_definition import WorkflowDefinition from ._order_by import OrderBy +from ._paged_test_plans import PagedTestPlans # flake8: noqa diff --git a/nisystemlink/clients/test_plan/test_plan/models/_paged_test_plans.py b/nisystemlink/clients/test_plan/test_plan/models/_paged_test_plans.py new file mode 100644 index 00000000..e17e2cf9 --- /dev/null +++ b/nisystemlink/clients/test_plan/test_plan/models/_paged_test_plans.py @@ -0,0 +1,16 @@ +from typing import List, Optional + +from nisystemlink.clients.core._uplink._with_paging import WithPaging +from nisystemlink.clients.test_plan.test_plan.models._test_plan import TestPlan + + +class PagedTestPlans(WithPaging): + """The response containing the list of products, total count of products and the continuation + token if applicable. + """ + + test_plans: List[TestPlan] + """A list of all the products in this page.""" + + total_count: Optional[int] = None + """The total number of products that match the query.""" diff --git a/nisystemlink/clients/test_plan/test_plan/models/_query_test_plans_response.py b/nisystemlink/clients/test_plan/test_plan/models/_query_test_plans_response.py deleted file mode 100644 index 13400aad..00000000 --- a/nisystemlink/clients/test_plan/test_plan/models/_query_test_plans_response.py +++ /dev/null @@ -1,20 +0,0 @@ -from typing import List, Optional - -from nisystemlink.clients.core._uplink._json_model import JsonModel - -from ._test_plan import TestPlan - - -class QueryTestPlansResponse(JsonModel): - """Represents the response from querying test plans. - Contains a list of test plans, a continuation token for pagination, and the total count. - """ - - test_plans: Optional[List[TestPlan]] - """A list of test plans returned by the query.""" - - continuation_token: Optional[str] = None - """A token to retrieve the next page of results for paginated queries.""" - - total_count: Optional[int] = None - """The total number of test plans matching the query filter.""" diff --git a/nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_response.py b/nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_response.py index f39a780f..b28e6edb 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_response.py +++ b/nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_response.py @@ -18,4 +18,3 @@ class ScheduleTestPlansResponse(JsonModel): error: Optional[ApiError] = None """The error that occurred when scheduling the test plans.""" - \ No newline at end of file From 56976440832bcd48a35d8212e010190aa5c31f2a Mon Sep 17 00:00:00 2001 From: Ammar Husain Mian Fazulul Date: Thu, 22 May 2025 23:18:09 +0530 Subject: [PATCH 43/64] refactor test plan api --- docs/api_reference.rst | 1 - docs/api_reference/test_plan.rst | 7 +- docs/api_reference/test_plan_templates.rst | 16 - docs/getting_started.rst | 26 +- .../test_plan/{test_plan => }/test_plan.py | 18 +- .../test_plan_templates.py | 13 +- nisystemlink/clients/test_plan/__init__.py | 2 + ...mplates_client.py => _test_plan_client.py} | 127 +++++- .../clients/test_plan/models/__init__.py | 63 ++- .../models/_create_test_plan_request.py | 2 +- ...plan_templates_partial_success_response.py | 0 .../models/_create_test_plans_request.py | 0 .../models/_create_test_plans_response.py | 0 ...plan_templates_partial_success_response.py | 0 .../models/_delete_test_plans_request.py | 0 .../models/_execution_event.py | 0 .../{test_plan => }/models/_order_by.py | 0 .../models/_paged_test_plan_templates.py | 5 +- .../models/_paged_test_plans.py | 3 +- .../_query_test_plan_templates_request.py | 0 .../models/_query_test_plans_request.py | 0 .../models/_schedule_test_plan_request.py | 0 .../models/_schedule_test_plans_request.py | 0 .../models/_schedule_test_plans_response.py | 0 .../{test_plan => }/models/_state.py | 0 .../{test_plan => }/models/_test_plan.py | 2 +- .../models/_test_plan_templates.py | 5 +- .../models/_update_test_plan_request.py | 0 .../models/_update_test_plans_request.py | 0 .../models/_update_test_plans_response.py | 0 .../models/_workflow_definition.py | 2 +- .../clients/test_plan/test_plan/__init__.py | 3 - .../test_plan/test_plan/_test_plan_client.py | 158 ------- .../test_plan/test_plan/models/__init__.py | 23 - .../test_plan/test_plan_templates/__init__.py | 5 - .../test_plan_templates/models/__init__.py | 20 - tests/integration/test_plan/__init__.py | 1 - .../test_plan/test_plan/__init__.py | 1 - .../test_plan/test_plan/test_test_plans.py | 204 --------- .../test_plan/test_plan_templates/__init__.py | 1 - .../test_test_plan_template.py | 183 -------- .../integration/test_plan/test_test_plans.py | 412 ++++++++++++++++++ 42 files changed, 627 insertions(+), 676 deletions(-) delete mode 100644 docs/api_reference/test_plan_templates.rst rename examples/test_plan/{test_plan => }/test_plan.py (79%) rename examples/test_plan/{test_plan_templates => }/test_plan_templates.py (73%) rename nisystemlink/clients/test_plan/{test_plan_templates/_test_plan_templates_client.py => _test_plan_client.py} (54%) rename nisystemlink/clients/test_plan/{test_plan => }/models/_create_test_plan_request.py (96%) rename nisystemlink/clients/test_plan/{test_plan_templates => }/models/_create_test_plan_templates_partial_success_response.py (100%) rename nisystemlink/clients/test_plan/{test_plan => }/models/_create_test_plans_request.py (100%) rename nisystemlink/clients/test_plan/{test_plan => }/models/_create_test_plans_response.py (100%) rename nisystemlink/clients/test_plan/{test_plan_templates => }/models/_delete_test_plan_templates_partial_success_response.py (100%) rename nisystemlink/clients/test_plan/{test_plan => }/models/_delete_test_plans_request.py (100%) rename nisystemlink/clients/test_plan/{test_plan => }/models/_execution_event.py (100%) rename nisystemlink/clients/test_plan/{test_plan => }/models/_order_by.py (100%) rename nisystemlink/clients/test_plan/{test_plan_templates => }/models/_paged_test_plan_templates.py (80%) rename nisystemlink/clients/test_plan/{test_plan => }/models/_paged_test_plans.py (85%) rename nisystemlink/clients/test_plan/{test_plan_templates => }/models/_query_test_plan_templates_request.py (100%) rename nisystemlink/clients/test_plan/{test_plan => }/models/_query_test_plans_request.py (100%) rename nisystemlink/clients/test_plan/{test_plan => }/models/_schedule_test_plan_request.py (100%) rename nisystemlink/clients/test_plan/{test_plan => }/models/_schedule_test_plans_request.py (100%) rename nisystemlink/clients/test_plan/{test_plan => }/models/_schedule_test_plans_response.py (100%) rename nisystemlink/clients/test_plan/{test_plan => }/models/_state.py (100%) rename nisystemlink/clients/test_plan/{test_plan => }/models/_test_plan.py (98%) rename nisystemlink/clients/test_plan/{test_plan_templates => }/models/_test_plan_templates.py (96%) rename nisystemlink/clients/test_plan/{test_plan => }/models/_update_test_plan_request.py (100%) rename nisystemlink/clients/test_plan/{test_plan => }/models/_update_test_plans_request.py (100%) rename nisystemlink/clients/test_plan/{test_plan => }/models/_update_test_plans_response.py (100%) rename nisystemlink/clients/test_plan/{test_plan => }/models/_workflow_definition.py (96%) delete mode 100644 nisystemlink/clients/test_plan/test_plan/__init__.py delete mode 100644 nisystemlink/clients/test_plan/test_plan/_test_plan_client.py delete mode 100644 nisystemlink/clients/test_plan/test_plan/models/__init__.py delete mode 100644 nisystemlink/clients/test_plan/test_plan_templates/__init__.py delete mode 100644 nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py delete mode 100644 tests/integration/test_plan/__init__.py delete mode 100644 tests/integration/test_plan/test_plan/__init__.py delete mode 100644 tests/integration/test_plan/test_plan/test_test_plans.py delete mode 100644 tests/integration/test_plan/test_plan_templates/__init__.py delete mode 100644 tests/integration/test_plan/test_plan_templates/test_test_plan_template.py create mode 100644 tests/integration/test_plan/test_test_plans.py diff --git a/docs/api_reference.rst b/docs/api_reference.rst index 90951665..ac30a93c 100644 --- a/docs/api_reference.rst +++ b/docs/api_reference.rst @@ -17,7 +17,6 @@ API Reference api_reference/notebook api_reference/feeds api_reference/test_plan - api_reference/test_plan_templates Indices and tables ------------------ diff --git a/docs/api_reference/test_plan.rst b/docs/api_reference/test_plan.rst index 62b53268..43881177 100644 --- a/docs/api_reference/test_plan.rst +++ b/docs/api_reference/test_plan.rst @@ -1,6 +1,6 @@ .. _api_tag_page: -nisystemlink.clients.test_plan.test_plan +nisystemlink.clients.test_plan ====================== .. autoclass:: nisystemlink.clients.test_plan.test_plan.TestPlanClient @@ -13,7 +13,10 @@ nisystemlink.clients.test_plan.test_plan .. automethod:: schedule_test_plans .. automethod:: update_test_plans .. automethod:: get_test_plan + .. automethod:: create_test_plan_templates + .. automethod:: query_test_plan_templates + .. automethod:: delete_test_plan_templates -.. automodule:: nisystemlink.clients.test_plan.test_plan.models +.. automodule:: nisystemlink.clients.test_plan.models :members: :imported-members: \ No newline at end of file diff --git a/docs/api_reference/test_plan_templates.rst b/docs/api_reference/test_plan_templates.rst deleted file mode 100644 index b35ddeaa..00000000 --- a/docs/api_reference/test_plan_templates.rst +++ /dev/null @@ -1,16 +0,0 @@ -.. _api_tag_page: - -nisystemlink.clients.test_plan.test_plan_templates -====================== - -.. autoclass:: nisystemlink.clients.test_plan.test_plan_templates.TestPlanTemplateClient - :exclude-members: __init__ - - .. automethod:: __init__ - .. automethod:: create_test_plan_templates - .. automethod:: query_test_plan_templates - .. automethod:: delete_test_plan_templates - -.. automodule:: nisystemlink.clients.test_plan.test_plan_templates.models - :members: - :imported-members: \ No newline at end of file diff --git a/docs/getting_started.rst b/docs/getting_started.rst index 8624995e..d2e6f530 100644 --- a/docs/getting_started.rst +++ b/docs/getting_started.rst @@ -343,32 +343,12 @@ Examples Create, query, get, update, schedule and delete TestPlans -.. literalinclude:: ../examples/test_plan/test_plan/test_plans.py +.. literalinclude:: ../examples/test_plan/test_plans.py :language: python :linenos: -TestPlanTemplate API -------- - -Overview -~~~~~~~~ - -The :class:`.TestPlanTemplateClient` class is the primary entry point of the TestPlanTemplate API. - -When constructing a :class:`.TestPlanTemplateClient`, you can pass an -:class:`.HttpConfiguration` (like one retrieved from the -:class:`.HttpConfigurationManager`), or let :class:`.TestPlanTemplateClient` use the -default connection. The default connection depends on your environment. - -With a :class:`.TestPlanTemplateClient` object, you can: - -* Create, query, and delete TestPlanTemplate - -Examples -~~~~~~~~ - Create, query and delete test plan templates. -.. literalinclude:: ../examples/test_plan/test_plan_templates/test_plan_templates.py +.. literalinclude:: ../examples/test_plan/test_plan_templates.py :language: python - :linenos: \ No newline at end of file + :linenos: diff --git a/examples/test_plan/test_plan/test_plan.py b/examples/test_plan/test_plan.py similarity index 79% rename from examples/test_plan/test_plan/test_plan.py rename to examples/test_plan/test_plan.py index c2987ae6..d5796bbb 100644 --- a/examples/test_plan/test_plan/test_plan.py +++ b/examples/test_plan/test_plan.py @@ -1,8 +1,9 @@ from nisystemlink.clients.core._http_configuration import HttpConfiguration -from nisystemlink.clients.test_plan.test_plan import TestPlanClient -from nisystemlink.clients.test_plan.test_plan.models import ( +from nisystemlink.clients.test_plan import TestPlanClient +from nisystemlink.clients.test_plan.models import ( CreateTestPlanRequest, CreateTestPlansRequest, + DeleteTestPlansRequest, QueryTestPlansRequest, ScheduleTestPlanRequest, ScheduleTestPlansRequest, @@ -18,7 +19,7 @@ client = TestPlanClient(configuration=server_configuration) create_test_plans_request = CreateTestPlansRequest( - testPlans=[ + test_plans=[ CreateTestPlanRequest( name="Python integration test plan", state="NEW", partNumber="px40482" ) @@ -26,9 +27,12 @@ ) # create a test plan -created_test_plans = client.create_test_plans(create_request=create_test_plans_request) +created_test_plans_response = client.create_test_plans( + create_request=create_test_plans_request +) -created_test_plan_id = created_test_plans.created_test_plans[0].id +if created_test_plans_response.created_test_plans: + created_test_plan_id = created_test_plans_response.created_test_plans[0].id # Query test plan using id. query_test_plans_request = QueryTestPlansRequest( @@ -44,7 +48,7 @@ # Update test plan update_test_plans_request = UpdateTestPlansRequest( - testPlans=[ + test_plans=[ UpdateTestPlanRequest( id=created_test_plan_id, name="Updated Test Plan", @@ -69,4 +73,4 @@ ) # Delete test plan -client.delete_test_plans(ids=[created_test_plan_id]) +client.delete_test_plans(ids=DeleteTestPlansRequest(ids=[created_test_plan_id])) diff --git a/examples/test_plan/test_plan_templates/test_plan_templates.py b/examples/test_plan/test_plan_templates.py similarity index 73% rename from examples/test_plan/test_plan_templates/test_plan_templates.py rename to examples/test_plan/test_plan_templates.py index 7d70451e..da18de92 100644 --- a/examples/test_plan/test_plan_templates/test_plan_templates.py +++ b/examples/test_plan/test_plan_templates.py @@ -1,21 +1,17 @@ from nisystemlink.clients.core._http_configuration import HttpConfiguration -from nisystemlink.clients.test_plan.models._execution_definition import ManualExecution -from nisystemlink.clients.test_plan.test_plan_templates._test_plan_templates_client import ( - TestPlanTemplateClient, -) -from nisystemlink.clients.test_plan.test_plan_templates.models._query_test_plan_templates_request import ( +from nisystemlink.clients.test_plan import TestPlanClient +from nisystemlink.clients.test_plan.models import ( QueryTestPlanTemplatesRequest, -) -from nisystemlink.clients.test_plan.test_plan_templates.models._test_plan_templates import ( TestPlanTemplateBase, ) + # Setup the server configuration to point to your instance of SystemLink Enterprise server_configuration = HttpConfiguration( server_uri="https://yourserver.yourcompany.com", api_key="YourAPIKeyGeneratedFromSystemLink", ) -client = TestPlanTemplateClient(configuration=server_configuration) +client = TestPlanClient(configuration=server_configuration) # Test plan template request metadata create_test_plan_template_request = [ @@ -23,7 +19,6 @@ name="Python integration test plan template", templateGroup="sample template group", workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", - executionActions=[ManualExecution(action="TEST", type="MANUAl")], ) ] diff --git a/nisystemlink/clients/test_plan/__init__.py b/nisystemlink/clients/test_plan/__init__.py index 9c0fa90a..ca953629 100644 --- a/nisystemlink/clients/test_plan/__init__.py +++ b/nisystemlink/clients/test_plan/__init__.py @@ -1 +1,3 @@ +from nisystemlink.clients.test_plan._test_plan_client import TestPlanClient + # flake8: noqa diff --git a/nisystemlink/clients/test_plan/test_plan_templates/_test_plan_templates_client.py b/nisystemlink/clients/test_plan/_test_plan_client.py similarity index 54% rename from nisystemlink/clients/test_plan/test_plan_templates/_test_plan_templates_client.py rename to nisystemlink/clients/test_plan/_test_plan_client.py index 65f9a3c6..b477bfd1 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/_test_plan_templates_client.py +++ b/nisystemlink/clients/test_plan/_test_plan_client.py @@ -1,22 +1,20 @@ -"""Implementation of Test plan template Client""" - from typing import List, Optional from nisystemlink.clients import core +from nisystemlink.clients.core._http_configuration import HttpConfiguration from nisystemlink.clients.core._uplink._base_client import BaseClient -from nisystemlink.clients.core._uplink._methods import post +from nisystemlink.clients.core._uplink._methods import get, post +from nisystemlink.clients.test_plan import models from uplink import Field, retry -from . import models - @retry( when=retry.when.status(408, 429, 502, 503, 504), stop=retry.stop.after_attempt(5), on_exception=retry.CONNECTION_ERROR, ) -class TestPlanTemplateClient(BaseClient): - def __init__(self, configuration: Optional[core.HttpConfiguration] = None): +class TestPlanClient(BaseClient): + def __init__(self, configuration: Optional[HttpConfiguration] = None): """Initialize an instance. Args: @@ -26,12 +24,125 @@ def __init__(self, configuration: Optional[core.HttpConfiguration] = None): is used to obtain the configuration. Raises: - ApiException: if unable to communicate with the `/niworkorder` Service. + ApiException: if unable to communicate with the WorkOrder Service. """ if configuration is None: configuration = core.HttpConfigurationManager.get_configuration() + super().__init__(configuration, base_path="/niworkorder/v1/") + @get("testplans/{test_plan_id}") + def get_test_plan(self, test_plan_id: str) -> models.TestPlan: + """Retrieve a test plan by its ID. + + Args: + test_plan_id: The ID of the test plan to retrieve. + + Returns: + The TestPlan object corresponding to the given ID. + """ + ... + + @post("testplans") + def create_test_plans( + self, create_request: models.CreateTestPlansRequest + ) -> models.CreateTestPlansResponse: + """Create a new test plan. + + Args: + test_plan: The test plans to create. + + Returns: + The created test plan object. + """ + ... + + @post("delete-testplans") + def delete_test_plans(self, ids: models.DeleteTestPlansRequest) -> None: + """Delete test plans by IDs. + + Args: + test_plan_ids: A list of test plan IDs to delete. + + Returns: + None + """ + ... + + @post("query-testplans") + def __query_test_plans( + self, query_request: models._QueryTestPlansRequest + ) -> models.PagedTestPlans: + """Query test plans. + + Args: + query: The query to execute. + + Returns: + A PagedTestPlans object containing test plans that match the query. + """ + ... + + def query_test_plans( + self, query_request: models.QueryTestPlansRequest + ) -> models.PagedTestPlans: + """Query test plans. + + Args: + query: The query to execute. + + Returns: + A PagedTestPlans object containing test plans that match the query. + """ + projection_str = ( + [projection.name for projection in query_request.projection] + if query_request.projection + else None + ) + query_params = { + "filter": query_request.filter, + "take": query_request.take, + "continuation_token": query_request.continuation_token, + "order_by": query_request.order_by, + "descending": query_request.descending, + "return_count": query_request.return_count, + "projection": projection_str, + } + + query_params = {k: v for k, v in query_params.items() if v is not None} + + query_test_plans_request = models._QueryTestPlansRequest(**query_params) + + return self.__query_test_plans(query_request=query_test_plans_request) + + @post("schedule-testplans") + def schedule_test_plans( + self, schedule_request: models.ScheduleTestPlansRequest + ) -> models.ScheduleTestPlansResponse: + """Schedule a test plan. + + Args: + schedule: The schedule to apply to the test plan. + + Returns: + A ScheduleTestPlansResponse object containing the scheduled test plan. + """ + ... + + @post("update-testplans") + def update_test_plans( + self, update_request: models.UpdateTestPlansRequest + ) -> models.UpdateTestPlansResponse: + """Update a test plan. + + Args: + test_plan: The test plan to update. + + Returns: + The updated test plan object. + """ + ... + @post("testplan-templates", args=[Field("testPlanTemplates")]) def create_test_plan_templates( self, test_plan_templates: List[models.TestPlanTemplateBase] diff --git a/nisystemlink/clients/test_plan/models/__init__.py b/nisystemlink/clients/test_plan/models/__init__.py index b893eeca..664ea035 100644 --- a/nisystemlink/clients/test_plan/models/__init__.py +++ b/nisystemlink/clients/test_plan/models/__init__.py @@ -1,3 +1,64 @@ -from ._execution_definition import ExecutionDefinition +from nisystemlink.clients.test_plan.models._create_test_plan_request import ( + CreateTestPlanRequest, +) +from nisystemlink.clients.test_plan.models._create_test_plans_request import ( + CreateTestPlansRequest, +) +from nisystemlink.clients.test_plan.models._create_test_plans_response import ( + CreateTestPlansResponse, +) +from nisystemlink.clients.test_plan.models._delete_test_plans_request import ( + DeleteTestPlansRequest, +) +from nisystemlink.clients.test_plan.models._update_test_plan_request import ( + UpdateTestPlanRequest, +) +from nisystemlink.clients.test_plan.models._update_test_plans_request import ( + UpdateTestPlansRequest, +) +from nisystemlink.clients.test_plan.models._update_test_plans_response import ( + UpdateTestPlansResponse, +) +from nisystemlink.clients.test_plan.models._query_test_plans_request import ( + QueryTestPlansRequest, + _QueryTestPlansRequest, +) +from nisystemlink.clients.test_plan.models._paged_test_plans import PagedTestPlans +from nisystemlink.clients.test_plan.models._execution_event import ExecutionEvent +from nisystemlink.clients.test_plan.models._order_by import OrderBy +from nisystemlink.clients.test_plan.models._test_plan import TestPlan +from nisystemlink.clients.test_plan.models._state import State +from nisystemlink.clients.test_plan.models._execution_definition import ( + ExecutionDefinition, +) +from nisystemlink.clients.test_plan.models._schedule_test_plans_request import ( + ScheduleTestPlansRequest, +) +from nisystemlink.clients.test_plan.models._schedule_test_plan_request import ( + ScheduleTestPlanRequest, +) +from nisystemlink.clients.test_plan.models._schedule_test_plans_response import ( + ScheduleTestPlansResponse, +) +from nisystemlink.clients.test_plan.models._workflow_definition import ( + WorkflowDefinition, +) +from nisystemlink.clients.test_plan.models._test_plan_templates import ( + TestPlanTemplateBase, + TestPlanTemplate, +) +from nisystemlink.clients.test_plan.models._create_test_plan_templates_partial_success_response import ( + CreateTestPlanTemplatePartialSuccessResponse, +) +from nisystemlink.clients.test_plan.models._delete_test_plan_templates_partial_success_response import ( + DeleteTestPlanTemplatesPartialSuccessResponse, +) +from nisystemlink.clients.test_plan.models._query_test_plan_templates_request import ( + QueryTestPlanTemplatesRequest, + _QueryTestPlanTemplatesRequest, +) +from nisystemlink.clients.test_plan.models._paged_test_plan_templates import ( + PagedTestPlanTemplates, +) # flake8: noqa diff --git a/nisystemlink/clients/test_plan/test_plan/models/_create_test_plan_request.py b/nisystemlink/clients/test_plan/models/_create_test_plan_request.py similarity index 96% rename from nisystemlink/clients/test_plan/test_plan/models/_create_test_plan_request.py rename to nisystemlink/clients/test_plan/models/_create_test_plan_request.py index 5de730a6..4aab15a6 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/_create_test_plan_request.py +++ b/nisystemlink/clients/test_plan/models/_create_test_plan_request.py @@ -2,7 +2,7 @@ from nisystemlink.clients.core._uplink._json_model import JsonModel -from ...models._execution_definition import ExecutionDefinition +from ._execution_definition import ExecutionDefinition class Dashboard(JsonModel): diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_create_test_plan_templates_partial_success_response.py b/nisystemlink/clients/test_plan/models/_create_test_plan_templates_partial_success_response.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plan_templates/models/_create_test_plan_templates_partial_success_response.py rename to nisystemlink/clients/test_plan/models/_create_test_plan_templates_partial_success_response.py diff --git a/nisystemlink/clients/test_plan/test_plan/models/_create_test_plans_request.py b/nisystemlink/clients/test_plan/models/_create_test_plans_request.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plan/models/_create_test_plans_request.py rename to nisystemlink/clients/test_plan/models/_create_test_plans_request.py diff --git a/nisystemlink/clients/test_plan/test_plan/models/_create_test_plans_response.py b/nisystemlink/clients/test_plan/models/_create_test_plans_response.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plan/models/_create_test_plans_response.py rename to nisystemlink/clients/test_plan/models/_create_test_plans_response.py diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_delete_test_plan_templates_partial_success_response.py b/nisystemlink/clients/test_plan/models/_delete_test_plan_templates_partial_success_response.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plan_templates/models/_delete_test_plan_templates_partial_success_response.py rename to nisystemlink/clients/test_plan/models/_delete_test_plan_templates_partial_success_response.py diff --git a/nisystemlink/clients/test_plan/test_plan/models/_delete_test_plans_request.py b/nisystemlink/clients/test_plan/models/_delete_test_plans_request.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plan/models/_delete_test_plans_request.py rename to nisystemlink/clients/test_plan/models/_delete_test_plans_request.py diff --git a/nisystemlink/clients/test_plan/test_plan/models/_execution_event.py b/nisystemlink/clients/test_plan/models/_execution_event.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plan/models/_execution_event.py rename to nisystemlink/clients/test_plan/models/_execution_event.py diff --git a/nisystemlink/clients/test_plan/test_plan/models/_order_by.py b/nisystemlink/clients/test_plan/models/_order_by.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plan/models/_order_by.py rename to nisystemlink/clients/test_plan/models/_order_by.py diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_paged_test_plan_templates.py b/nisystemlink/clients/test_plan/models/_paged_test_plan_templates.py similarity index 80% rename from nisystemlink/clients/test_plan/test_plan_templates/models/_paged_test_plan_templates.py rename to nisystemlink/clients/test_plan/models/_paged_test_plan_templates.py index 0c3eb4e1..37c3e0e3 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/_paged_test_plan_templates.py +++ b/nisystemlink/clients/test_plan/models/_paged_test_plan_templates.py @@ -1,9 +1,8 @@ from typing import List, Optional from nisystemlink.clients.core._uplink._with_paging import WithPaging -from nisystemlink.clients.test_plan.test_plan_templates.models._test_plan_templates import ( - TestPlanTemplate, -) + +from ._test_plan_templates import TestPlanTemplate class PagedTestPlanTemplates(WithPaging): diff --git a/nisystemlink/clients/test_plan/test_plan/models/_paged_test_plans.py b/nisystemlink/clients/test_plan/models/_paged_test_plans.py similarity index 85% rename from nisystemlink/clients/test_plan/test_plan/models/_paged_test_plans.py rename to nisystemlink/clients/test_plan/models/_paged_test_plans.py index e17e2cf9..dfb12ac1 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/_paged_test_plans.py +++ b/nisystemlink/clients/test_plan/models/_paged_test_plans.py @@ -1,7 +1,8 @@ from typing import List, Optional from nisystemlink.clients.core._uplink._with_paging import WithPaging -from nisystemlink.clients.test_plan.test_plan.models._test_plan import TestPlan + +from ._test_plan import TestPlan class PagedTestPlans(WithPaging): diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates_request.py b/nisystemlink/clients/test_plan/models/_query_test_plan_templates_request.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plan_templates/models/_query_test_plan_templates_request.py rename to nisystemlink/clients/test_plan/models/_query_test_plan_templates_request.py diff --git a/nisystemlink/clients/test_plan/test_plan/models/_query_test_plans_request.py b/nisystemlink/clients/test_plan/models/_query_test_plans_request.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plan/models/_query_test_plans_request.py rename to nisystemlink/clients/test_plan/models/_query_test_plans_request.py diff --git a/nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plan_request.py b/nisystemlink/clients/test_plan/models/_schedule_test_plan_request.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plan_request.py rename to nisystemlink/clients/test_plan/models/_schedule_test_plan_request.py diff --git a/nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_request.py b/nisystemlink/clients/test_plan/models/_schedule_test_plans_request.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_request.py rename to nisystemlink/clients/test_plan/models/_schedule_test_plans_request.py diff --git a/nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_response.py b/nisystemlink/clients/test_plan/models/_schedule_test_plans_response.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plan/models/_schedule_test_plans_response.py rename to nisystemlink/clients/test_plan/models/_schedule_test_plans_response.py diff --git a/nisystemlink/clients/test_plan/test_plan/models/_state.py b/nisystemlink/clients/test_plan/models/_state.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plan/models/_state.py rename to nisystemlink/clients/test_plan/models/_state.py diff --git a/nisystemlink/clients/test_plan/test_plan/models/_test_plan.py b/nisystemlink/clients/test_plan/models/_test_plan.py similarity index 98% rename from nisystemlink/clients/test_plan/test_plan/models/_test_plan.py rename to nisystemlink/clients/test_plan/models/_test_plan.py index d26e80fe..27649f5b 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/_test_plan.py +++ b/nisystemlink/clients/test_plan/models/_test_plan.py @@ -3,10 +3,10 @@ from nisystemlink.clients.core._uplink._json_model import JsonModel +from ._execution_definition import ExecutionDefinition from ._execution_event import ExecutionEvent from ._state import State from ._workflow_definition import WorkflowDefinition -from ...models._execution_definition import ExecutionDefinition class TestPlan(JsonModel): diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py b/nisystemlink/clients/test_plan/models/_test_plan_templates.py similarity index 96% rename from nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py rename to nisystemlink/clients/test_plan/models/_test_plan_templates.py index 3a3d6a50..b3e2edbd 100644 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/_test_plan_templates.py +++ b/nisystemlink/clients/test_plan/models/_test_plan_templates.py @@ -2,9 +2,8 @@ from typing import Dict, List, Optional from nisystemlink.clients.core._uplink._json_model import JsonModel -from nisystemlink.clients.test_plan.models._execution_definition import ( - ExecutionDefinition, -) + +from ._execution_definition import ExecutionDefinition class Dashboard(JsonModel): diff --git a/nisystemlink/clients/test_plan/test_plan/models/_update_test_plan_request.py b/nisystemlink/clients/test_plan/models/_update_test_plan_request.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plan/models/_update_test_plan_request.py rename to nisystemlink/clients/test_plan/models/_update_test_plan_request.py diff --git a/nisystemlink/clients/test_plan/test_plan/models/_update_test_plans_request.py b/nisystemlink/clients/test_plan/models/_update_test_plans_request.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plan/models/_update_test_plans_request.py rename to nisystemlink/clients/test_plan/models/_update_test_plans_request.py diff --git a/nisystemlink/clients/test_plan/test_plan/models/_update_test_plans_response.py b/nisystemlink/clients/test_plan/models/_update_test_plans_response.py similarity index 100% rename from nisystemlink/clients/test_plan/test_plan/models/_update_test_plans_response.py rename to nisystemlink/clients/test_plan/models/_update_test_plans_response.py diff --git a/nisystemlink/clients/test_plan/test_plan/models/_workflow_definition.py b/nisystemlink/clients/test_plan/models/_workflow_definition.py similarity index 96% rename from nisystemlink/clients/test_plan/test_plan/models/_workflow_definition.py rename to nisystemlink/clients/test_plan/models/_workflow_definition.py index b3e05544..d34d688c 100644 --- a/nisystemlink/clients/test_plan/test_plan/models/_workflow_definition.py +++ b/nisystemlink/clients/test_plan/models/_workflow_definition.py @@ -1,7 +1,7 @@ from nisystemlink.clients.core._uplink._json_model import JsonModel +from ._execution_definition import ExecutionDefinition from ._state import State -from ...models._execution_definition import ExecutionDefinition class ActionTransitionDefinition(JsonModel): diff --git a/nisystemlink/clients/test_plan/test_plan/__init__.py b/nisystemlink/clients/test_plan/test_plan/__init__.py deleted file mode 100644 index 013b65cb..00000000 --- a/nisystemlink/clients/test_plan/test_plan/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from ._test_plan_client import TestPlanClient - -# flake8: noqa diff --git a/nisystemlink/clients/test_plan/test_plan/_test_plan_client.py b/nisystemlink/clients/test_plan/test_plan/_test_plan_client.py deleted file mode 100644 index 3599e44c..00000000 --- a/nisystemlink/clients/test_plan/test_plan/_test_plan_client.py +++ /dev/null @@ -1,158 +0,0 @@ -from typing import Optional - -from nisystemlink.clients import core -from nisystemlink.clients.core._http_configuration import HttpConfiguration -from nisystemlink.clients.core._uplink._base_client import BaseClient -from nisystemlink.clients.core._uplink._methods import get, post -from nisystemlink.clients.test_plan.test_plan.models._paged_test_plans import ( - PagedTestPlans, -) -from uplink import retry - - -from .models import ( - _QueryTestPlansRequest, - CreateTestPlansRequest, - CreateTestPlansResponse, - DeleteTestPlansRequest, - QueryTestPlansRequest, - ScheduleTestPlansRequest, - ScheduleTestPlansResponse, - TestPlan, - UpdateTestPlansRequest, - UpdateTestPlansResponse, -) - - -@retry( - when=retry.when.status(408, 429, 502, 503, 504), - stop=retry.stop.after_attempt(5), - on_exception=retry.CONNECTION_ERROR, -) -class TestPlanClient(BaseClient): - def __init__(self, configuration: Optional[HttpConfiguration] = None): - """Initialize an instance. - - Args: - configuration: Defines the web server to connect to and information about - how to connect. If not provided, the - :class:`HttpConfigurationManager ` - is used to obtain the configuration. - - Raises: - ApiException: if unable to communicate with the WorkOrder Service. - """ - if configuration is None: - configuration = core.HttpConfigurationManager.get_configuration() - - super().__init__(configuration, base_path="/niworkorder/v1/") - - @get("testplans/{test_plan_id}") - def get_test_plan(self, test_plan_id) -> TestPlan: - """Retrieve a test plan by its ID. - - Args: - test_plan_id: The ID of the test plan to retrieve. - - Returns: - The TestPlan object corresponding to the given ID. - """ - ... - - @post("testplans") - def create_test_plans( - self, create_request: CreateTestPlansRequest - ) -> CreateTestPlansResponse: - """Create a new test plan. - - Args: - test_plan: The test plans to create. - - Returns: - The created test plan object. - """ - ... - - @post("delete-testplans") - def delete_test_plans(self, ids: DeleteTestPlansRequest) -> None: - """Delete test plans by IDs. - - Args: - test_plan_ids: A list of test plan IDs to delete. - - Returns: - None - """ - ... - - @post("query-testplans") - def __query_test_plans( - self, query_request: _QueryTestPlansRequest - ) -> PagedTestPlans: - """Query test plans. - - Args: - query: The query to execute. - - Returns: - A PagedTestPlans object containing test plans that match the query. - """ - ... - - def query_test_plans(self, query_request: QueryTestPlansRequest) -> PagedTestPlans: - """Query test plans. - - Args: - query: The query to execute. - - Returns: - A PagedTestPlans object containing test plans that match the query. - """ - projection_str = ( - [projection.name for projection in query_request.projection] - if query_request.projection - else None - ) - query_params = { - "filter": query_request.filter, - "take": query_request.take, - "continuation_token": query_request.continuation_token, - "order_by": query_request.order_by, - "descending": query_request.descending, - "return_count": query_request.return_count, - "projection": projection_str, - } - - query_params = {k: v for k, v in query_params.items() if v is not None} - - query_test_plans_request = _QueryTestPlansRequest(**query_params) - - return self.__query_test_plans(query_request=query_test_plans_request) - - @post("schedule-testplans") - def schedule_test_plans( - self, schedule_request: ScheduleTestPlansRequest - ) -> ScheduleTestPlansResponse: - """Schedule a test plan. - - Args: - schedule: The schedule to apply to the test plan. - - Returns: - A ScheduleTestPlansResponse object containing the scheduled test plan. - """ - ... - - @post("update-testplans") - def update_test_plans( - self, update_request: UpdateTestPlansRequest - ) -> UpdateTestPlansResponse: - """Update a test plan. - - Args: - test_plan: The test plan to update. - - Returns: - The updated test plan object. - """ - ... diff --git a/nisystemlink/clients/test_plan/test_plan/models/__init__.py b/nisystemlink/clients/test_plan/test_plan/models/__init__.py deleted file mode 100644 index 53d40e2c..00000000 --- a/nisystemlink/clients/test_plan/test_plan/models/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -from ._create_test_plans_request import CreateTestPlansRequest -from ._create_test_plan_request import CreateTestPlanRequest -from ._create_test_plans_response import CreateTestPlansResponse -from ._schedule_test_plan_request import ScheduleTestPlanRequest -from ._schedule_test_plans_response import ScheduleTestPlansResponse -from ._delete_test_plans_request import DeleteTestPlansRequest -from ._execution_event import ExecutionEvent -from ._query_test_plans_request import ( - QueryTestPlansRequest, - TestPlanField, - _QueryTestPlansRequest, -) -from ._schedule_test_plans_request import ScheduleTestPlansRequest -from ._state import State -from ._test_plan import TestPlan -from ._update_test_plan_request import UpdateTestPlanRequest -from ._update_test_plans_request import UpdateTestPlansRequest -from ._update_test_plans_response import UpdateTestPlansResponse -from ._workflow_definition import WorkflowDefinition -from ._order_by import OrderBy -from ._paged_test_plans import PagedTestPlans - -# flake8: noqa diff --git a/nisystemlink/clients/test_plan/test_plan_templates/__init__.py b/nisystemlink/clients/test_plan/test_plan_templates/__init__.py deleted file mode 100644 index fdbfdd30..00000000 --- a/nisystemlink/clients/test_plan/test_plan_templates/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -from nisystemlink.clients.test_plan.test_plan_templates._test_plan_templates_client import ( - TestPlanTemplateClient, -) - -# flake8: noqa diff --git a/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py b/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py deleted file mode 100644 index ee122be3..00000000 --- a/nisystemlink/clients/test_plan/test_plan_templates/models/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -from nisystemlink.clients.test_plan.test_plan_templates.models._create_test_plan_templates_partial_success_response import ( - CreateTestPlanTemplatePartialSuccessResponse, -) -from nisystemlink.clients.test_plan.test_plan_templates.models._query_test_plan_templates_request import ( - QueryTestPlanTemplatesRequest, - _QueryTestPlanTemplatesRequest, - TestPlanTemplateField, -) -from nisystemlink.clients.test_plan.test_plan_templates.models._delete_test_plan_templates_partial_success_response import ( - DeleteTestPlanTemplatesPartialSuccessResponse, -) -from nisystemlink.clients.test_plan.test_plan_templates.models._test_plan_templates import ( - TestPlanTemplateBase, - TestPlanTemplate, -) -from nisystemlink.clients.test_plan.test_plan_templates.models._paged_test_plan_templates import ( - PagedTestPlanTemplates, -) - -# flake8: noqa diff --git a/tests/integration/test_plan/__init__.py b/tests/integration/test_plan/__init__.py deleted file mode 100644 index 9c0fa90a..00000000 --- a/tests/integration/test_plan/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# flake8: noqa diff --git a/tests/integration/test_plan/test_plan/__init__.py b/tests/integration/test_plan/test_plan/__init__.py deleted file mode 100644 index 9c0fa90a..00000000 --- a/tests/integration/test_plan/test_plan/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# flake8: noqa diff --git a/tests/integration/test_plan/test_plan/test_test_plans.py b/tests/integration/test_plan/test_plan/test_test_plans.py deleted file mode 100644 index 0b3c2fca..00000000 --- a/tests/integration/test_plan/test_plan/test_test_plans.py +++ /dev/null @@ -1,204 +0,0 @@ -from datetime import datetime - -import pytest -from nisystemlink.clients.core._http_configuration import HttpConfiguration -from nisystemlink.clients.test_plan.test_plan import TestPlanClient -from nisystemlink.clients.test_plan.test_plan.models import ( - CreateTestPlanRequest, - CreateTestPlansRequest, - CreateTestPlansResponse, - DeleteTestPlansRequest, - QueryTestPlansRequest, - ScheduleTestPlanRequest, - ScheduleTestPlansRequest, - State, - TestPlan, - TestPlanField, - UpdateTestPlanRequest, - UpdateTestPlansRequest, -) - - -@pytest.fixture(scope="class") -def client(enterprise_config: HttpConfiguration) -> TestPlanClient: - """Fixture to create a TestPlansClient instance""" - return TestPlanClient(enterprise_config) - - -@pytest.mark.integration -@pytest.mark.enterprise -class TestTestPlans: - - _test_plan_create = CreateTestPlansRequest( - testPlans=[ - CreateTestPlanRequest( - name="Python integration test plan", state="NEW", part_number="px40482" - ) - ] - ) - """create test plan object.""" - - def test__create_and_delete_test_plan__returns_created_and_deleted_test_plans( - self, client: TestPlanClient - ): - create_test_plan_response = client.create_test_plans( - create_request=self._test_plan_create - ) - created_test_plan = create_test_plan_response.created_test_plans[0] - - get_test_plan_response: TestPlan = client.get_test_plan(created_test_plan.id) - - delete_test_plan_request = DeleteTestPlansRequest(ids=[created_test_plan.id]) - client.delete_test_plans(ids=delete_test_plan_request) - - assert created_test_plan is not None - assert created_test_plan.name == "Python integration test plan" - assert created_test_plan.state == State.NEW - assert created_test_plan.part_number == "px40482" - assert get_test_plan_response is not None - assert get_test_plan_response.name == "Python integration test plan" - - def test__get_test_plan__returns_get_test_plan(self, client: TestPlanClient): - create_test_plan_response = client.create_test_plans( - create_request=self._test_plan_create - ) - created_test_plan = create_test_plan_response.created_test_plans[0] - - get_test_plan_response: TestPlan = client.get_test_plan(created_test_plan.id) - - delete_request = DeleteTestPlansRequest( - ids=[create_test_plan_response.created_test_plans[0].id] - ) - client.delete_test_plans(ids=delete_request) - - assert get_test_plan_response is not None - assert isinstance(get_test_plan_response, TestPlan) - assert get_test_plan_response.id == created_test_plan.id - - def test__update_test_plan__returns_updated_test_plan(self, client: TestPlanClient): - create_test_plan_response = client.create_test_plans( - create_request=self._test_plan_create - ) - created_test_plan = create_test_plan_response.created_test_plans[0] - - update_test_plans_request = UpdateTestPlansRequest( - testPlans=[ - UpdateTestPlanRequest( - id=created_test_plan.id, - name="Updated Test Plan", - ) - ] - ) - update_test_plans_response = client.update_test_plans( - update_request=update_test_plans_request - ) - - delete_request = DeleteTestPlansRequest( - ids=[create_test_plan_response.created_test_plans[0].id] - ) - client.delete_test_plans(ids=delete_request) - - assert update_test_plans_response is not None - updated_test_plan = update_test_plans_response.updated_test_plans[0] - assert updated_test_plan.id == created_test_plan.id - assert updated_test_plan.name == "Updated Test Plan" - - def test__schedule_test_plan__returns_scheduled_test_plan( - self, client: TestPlanClient - ): - create_test_plan_response = client.create_test_plans( - create_request=self._test_plan_create - ) - created_test_plan = create_test_plan_response.created_test_plans[0] - - schedule_test_plans_request = ScheduleTestPlansRequest( - test_plans=[ - ScheduleTestPlanRequest( - id=created_test_plan.id, - planned_start_date_time=datetime.strptime( - "2025-05-20T15:07:42.527Z", "%Y-%m-%dT%H:%M:%S.%fZ" - ), - estimated_end_date_time=datetime.strptime( - "2025-05-22T15:07:42.527Z", "%Y-%m-%dT%H:%M:%S.%fZ" - ), - system_id="fake-system", - ) - ] - ) - schedule_test_plans_response = client.schedule_test_plans( - schedule_request=schedule_test_plans_request - ) - - delete_request = DeleteTestPlansRequest(ids=[created_test_plan.id]) - client.delete_test_plans(ids=delete_request) - - assert schedule_test_plans_response is not None - scheduled_test_plan = schedule_test_plans_response.scheduled_test_plans[0] - assert scheduled_test_plan.id == created_test_plan.id - assert scheduled_test_plan.planned_start_date_time == datetime.strptime( - "2025-05-20T15:07:42.527Z", "%Y-%m-%dT%H:%M:%S.%fZ" - ) - assert scheduled_test_plan.system_id == "fake-system" - - def test__query_test_plans__return_queried_test_plan(self, client: TestPlanClient): - create_test_plan_response: CreateTestPlansResponse = client.create_test_plans( - create_request=self._test_plan_create - ) - created_test_plan = create_test_plan_response.created_test_plans[0] - - query_test_plans_request = QueryTestPlansRequest( - filter=f'id = "{created_test_plan.id}"', return_count=True - ) - queried_test_plans_response = client.query_test_plans( - query_request=query_test_plans_request - ) - - delete_request = DeleteTestPlansRequest(ids=[created_test_plan.id]) - client.delete_test_plans(ids=delete_request) - - assert queried_test_plans_response is not None - assert queried_test_plans_response.test_plans[0].id == created_test_plan.id - assert queried_test_plans_response.total_count > 0 - - def test__query_test_plans_with_projections__returns_the_test_plans_with_projected_properties( - self, client: TestPlanClient - ): - query_test_plans_request = QueryTestPlansRequest( - projection=[TestPlanField.ID, TestPlanField.NAME] - ) - response = client.query_test_plans(query_request=query_test_plans_request) - - assert response is not None - assert all( - test_plan.id is not None - and test_plan.name is not None - and test_plan.template_id is None - and test_plan.state is None - and test_plan.substate is None - and test_plan.description is None - and test_plan.assigned_to is None - and test_plan.work_order_id is None - and test_plan.work_order_name is None - and test_plan.workspace is None - and test_plan.created_by is None - and test_plan.updated_at is None - and test_plan.created_At is None - and test_plan.updated_by is None - and test_plan.properties is None - and test_plan.part_number is None - and test_plan.dut_id is None - and test_plan.test_program is None - and test_plan.system_filter is None - and test_plan.fixture_ids is None - and test_plan.system_id is None - and test_plan.planned_start_date_time is None - and test_plan.estimated_duration_in_seconds is None - and test_plan.estimated_end_date_time is None - and test_plan.file_ids_from_template is None - and test_plan.execution_actions is None - and test_plan.execution_history is None - and test_plan.dashboard_url is None - and test_plan.dashboard is None - and test_plan.workflow is None - for test_plan in response.test_plans - ) diff --git a/tests/integration/test_plan/test_plan_templates/__init__.py b/tests/integration/test_plan/test_plan_templates/__init__.py deleted file mode 100644 index 9c0fa90a..00000000 --- a/tests/integration/test_plan/test_plan_templates/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# flake8: noqa diff --git a/tests/integration/test_plan/test_plan_templates/test_test_plan_template.py b/tests/integration/test_plan/test_plan_templates/test_test_plan_template.py deleted file mode 100644 index f550caee..00000000 --- a/tests/integration/test_plan/test_plan_templates/test_test_plan_template.py +++ /dev/null @@ -1,183 +0,0 @@ -from typing import List - -import pytest -from nisystemlink.clients.core._http_configuration import HttpConfiguration -from nisystemlink.clients.test_plan.test_plan_templates import TestPlanTemplateClient -from nisystemlink.clients.test_plan.test_plan_templates.models import ( - CreateTestPlanTemplatePartialSuccessResponse, - PagedTestPlanTemplates, - QueryTestPlanTemplatesRequest, - TestPlanTemplate, - TestPlanTemplateBase, - TestPlanTemplateField, -) - - -@pytest.fixture(scope="class") -def client(enterprise_config: HttpConfiguration) -> TestPlanTemplateClient: - """Fixture to create a TestPlanTemplateClient instance.""" - return TestPlanTemplateClient(enterprise_config) - - -@pytest.fixture -def create_test_plan_templates(client: TestPlanTemplateClient): - """Fixture to return a factory that create test plan templates.""" - responses: List[CreateTestPlanTemplatePartialSuccessResponse] = [] - - def _create_test_plan_templates( - new_test_plan_templates: List[TestPlanTemplateBase], - ) -> CreateTestPlanTemplatePartialSuccessResponse: - response = client.create_test_plan_templates( - test_plan_templates=new_test_plan_templates - ) - responses.append(response) - return response - - yield _create_test_plan_templates - - created_test_plan_templates: List[TestPlanTemplate] = [] - for response in responses: - if response.created_test_plan_templates: - created_test_plan_templates = ( - created_test_plan_templates + response.created_test_plan_templates - ) - client.delete_test_plan_templates( - ids=[ - test_plan_template.id - for test_plan_template in created_test_plan_templates - if test_plan_template.id is not None - ] - ) - - -@pytest.mark.integration -@pytest.mark.enterprise -class TestPlanTemplateTest: - - def test__create_test_plan_template__returns_created_test_plan_template( - self, client: TestPlanTemplateClient, create_test_plan_templates - ): - create_test_plan_template_request: List[TestPlanTemplateBase] = [ - TestPlanTemplateBase( - name="Python integration test plan template", - templateGroup="sample template group", - workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", - ) - ] - create_test_plan_template_response = create_test_plan_templates( - create_test_plan_template_request - ) - - template_id = ( - create_test_plan_template_response.created_test_plan_templates[0].id - if create_test_plan_template_response.created_test_plan_templates - and create_test_plan_template_response.created_test_plan_templates[0].id - else None - ) - - assert template_id is not None - assert ( - create_test_plan_template_response.created_test_plan_templates[0].name - == create_test_plan_template_request[0].name - ) - - def test__query_test_plan_template__returns_queried_test_plan_template( - self, client: TestPlanTemplateClient, create_test_plan_templates - ): - - create_test_plan_template_request: List[TestPlanTemplateBase] = [ - TestPlanTemplateBase( - name="Python integration test plan template", - templateGroup="sample template group", - workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", - ) - ] - - create_test_plan_template_response = create_test_plan_templates( - create_test_plan_template_request - ) - - template_id = ( - create_test_plan_template_response.created_test_plan_templates[0].id - if create_test_plan_template_response.created_test_plan_templates - and create_test_plan_template_response.created_test_plan_templates[0].id - else None - ) - - assert template_id is not None - - query = QueryTestPlanTemplatesRequest(filter=f'id="{template_id}"', take=1) - - query_test_plan_template_response: PagedTestPlanTemplates = ( - client.query_test_plan_templates(query_test_plan_templates=query) - ) - - assert len(query_test_plan_template_response.test_plan_templates) == 1, query - assert ( - query_test_plan_template_response.test_plan_templates[0].id == template_id - ) - - def test__delete_test_plan_template(self, client: TestPlanTemplateClient): - - create_test_plan_template_request: List[TestPlanTemplateBase] = [ - TestPlanTemplateBase( - name="Python integration test plan template", - templateGroup="sample template group", - workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", - ) - ] - create_test_plan_template_response: ( - CreateTestPlanTemplatePartialSuccessResponse - ) = client.create_test_plan_templates( - test_plan_templates=create_test_plan_template_request - ) - - template_id = ( - create_test_plan_template_response.created_test_plan_templates[0].id - if create_test_plan_template_response.created_test_plan_templates - and create_test_plan_template_response.created_test_plan_templates[0].id - else None - ) - - assert template_id is not None - - client.delete_test_plan_templates(ids=[template_id]) - - query_deleted_test_plan_template_response: PagedTestPlanTemplates = ( - client.query_test_plan_templates( - query_test_plan_templates=QueryTestPlanTemplatesRequest( - filter=f'id="{template_id}"', take=1 - ) - ) - ) - - assert len(query_deleted_test_plan_template_response.test_plan_templates) == 0 - - def test_query_test_plan_templates_with_projections__returns_test_plan_templates_with_projected_properties( - self, client: TestPlanTemplateClient - ): - query = QueryTestPlanTemplatesRequest( - projection=[TestPlanTemplateField.ID, TestPlanTemplateField.NAME], - ) - print(query) - response = client.query_test_plan_templates(query_test_plan_templates=query) - - assert response is not None - assert all( - test_plan_template.id is not None - and test_plan_template.name is not None - and test_plan_template.template_group is None - and test_plan_template.product_families is None - and test_plan_template.part_numbers is None - and test_plan_template.summary is None - and test_plan_template.description is None - and test_plan_template.test_program is None - and test_plan_template.estimated_duration_in_seconds is None - and test_plan_template.system_filter is None - and test_plan_template.execution_actions is None - and test_plan_template.file_ids is None - and test_plan_template.workspace is None - and test_plan_template.properties is None - and test_plan_template.dashboard is None - for test_plan_template in response.test_plan_templates - ) diff --git a/tests/integration/test_plan/test_test_plans.py b/tests/integration/test_plan/test_test_plans.py new file mode 100644 index 00000000..74634ce6 --- /dev/null +++ b/tests/integration/test_plan/test_test_plans.py @@ -0,0 +1,412 @@ +from datetime import datetime +from typing import List + +import pytest +from nisystemlink.clients.core._http_configuration import HttpConfiguration +from nisystemlink.clients.test_plan import TestPlanClient +from nisystemlink.clients.test_plan.models._create_test_plan_request import ( + CreateTestPlanRequest, +) +from nisystemlink.clients.test_plan.models._create_test_plan_templates_partial_success_response import ( + CreateTestPlanTemplatePartialSuccessResponse, +) +from nisystemlink.clients.test_plan.models._create_test_plans_request import ( + CreateTestPlansRequest, +) +from nisystemlink.clients.test_plan.models._create_test_plans_response import ( + CreateTestPlansResponse, +) +from nisystemlink.clients.test_plan.models._delete_test_plans_request import ( + DeleteTestPlansRequest, +) +from nisystemlink.clients.test_plan.models._paged_test_plan_templates import ( + PagedTestPlanTemplates, +) +from nisystemlink.clients.test_plan.models._query_test_plan_templates_request import ( + QueryTestPlanTemplatesRequest, + TestPlanTemplateField, +) +from nisystemlink.clients.test_plan.models._query_test_plans_request import ( + QueryTestPlansRequest, + TestPlanField, +) +from nisystemlink.clients.test_plan.models._schedule_test_plan_request import ( + ScheduleTestPlanRequest, +) +from nisystemlink.clients.test_plan.models._schedule_test_plans_request import ( + ScheduleTestPlansRequest, +) +from nisystemlink.clients.test_plan.models._state import State +from nisystemlink.clients.test_plan.models._test_plan import TestPlan +from nisystemlink.clients.test_plan.models._test_plan_templates import ( + TestPlanTemplate, + TestPlanTemplateBase, +) +from nisystemlink.clients.test_plan.models._update_test_plan_request import ( + UpdateTestPlanRequest, +) +from nisystemlink.clients.test_plan.models._update_test_plans_request import ( + UpdateTestPlansRequest, +) + + +@pytest.fixture(scope="class") +def client(enterprise_config: HttpConfiguration) -> TestPlanClient: + """Fixture to create a TestPlansClient instance""" + return TestPlanClient(enterprise_config) + + +@pytest.fixture +def create_test_plan_templates(client: TestPlanClient): + """Fixture to return a factory that create test plan templates.""" + responses: List[CreateTestPlanTemplatePartialSuccessResponse] = [] + + def _create_test_plan_templates( + new_test_plan_templates: List[TestPlanTemplateBase], + ) -> CreateTestPlanTemplatePartialSuccessResponse: + response = client.create_test_plan_templates( + test_plan_templates=new_test_plan_templates + ) + responses.append(response) + return response + + yield _create_test_plan_templates + + created_test_plan_templates: List[TestPlanTemplate] = [] + for response in responses: + if response.created_test_plan_templates: + created_test_plan_templates = ( + created_test_plan_templates + response.created_test_plan_templates + ) + client.delete_test_plan_templates( + ids=[ + test_plan_template.id + for test_plan_template in created_test_plan_templates + if test_plan_template.id is not None + ] + ) + + +@pytest.mark.integration +@pytest.mark.enterprise +class TestTestPlanClient: + + _test_plan_create = CreateTestPlansRequest( + testPlans=[ + CreateTestPlanRequest( + name="Python integration test plan", state="NEW", part_number="px40482" + ) + ] + ) + """create test plan object.""" + + def test__create_and_delete_test_plan__returns_created_and_deleted_test_plans( + self, client: TestPlanClient + ): + create_test_plan_response = client.create_test_plans( + create_request=self._test_plan_create + ) + + assert create_test_plan_response.created_test_plans is not None + + created_test_plan = create_test_plan_response.created_test_plans[0] + + get_test_plan_response: TestPlan = client.get_test_plan(created_test_plan.id) + + delete_test_plan_request = DeleteTestPlansRequest(ids=[created_test_plan.id]) + client.delete_test_plans(ids=delete_test_plan_request) + + assert created_test_plan is not None + assert created_test_plan.name == "Python integration test plan" + assert created_test_plan.state == State.NEW + assert created_test_plan.part_number == "px40482" + assert get_test_plan_response is not None + assert get_test_plan_response.name == "Python integration test plan" + + def test__get_test_plan__returns_get_test_plan(self, client: TestPlanClient): + create_test_plan_response = client.create_test_plans( + create_request=self._test_plan_create + ) + + assert create_test_plan_response.created_test_plans is not None + + created_test_plan = create_test_plan_response.created_test_plans[0] + + get_test_plan_response: TestPlan = client.get_test_plan(created_test_plan.id) + + delete_request = DeleteTestPlansRequest( + ids=[create_test_plan_response.created_test_plans[0].id] + ) + client.delete_test_plans(ids=delete_request) + + assert get_test_plan_response is not None + assert isinstance(get_test_plan_response, TestPlan) + assert get_test_plan_response.id == created_test_plan.id + + def test__update_test_plan__returns_updated_test_plan(self, client: TestPlanClient): + create_test_plan_response = client.create_test_plans( + create_request=self._test_plan_create + ) + + assert create_test_plan_response.created_test_plans is not None + + created_test_plan = create_test_plan_response.created_test_plans[0] + + update_test_plans_request = UpdateTestPlansRequest( + test_plans=[ + UpdateTestPlanRequest( + id=created_test_plan.id, + name="Updated Test Plan", + ) + ] + ) + update_test_plans_response = client.update_test_plans( + update_request=update_test_plans_request + ) + + delete_request = DeleteTestPlansRequest( + ids=[create_test_plan_response.created_test_plans[0].id] + ) + client.delete_test_plans(ids=delete_request) + + assert update_test_plans_response.updated_test_plans is not None + + updated_test_plan = update_test_plans_response.updated_test_plans[0] + assert updated_test_plan.id == created_test_plan.id + assert updated_test_plan.name == "Updated Test Plan" + + def test__schedule_test_plan__returns_scheduled_test_plan( + self, client: TestPlanClient + ): + create_test_plan_response = client.create_test_plans( + create_request=self._test_plan_create + ) + + assert create_test_plan_response.created_test_plans is not None + + created_test_plan = create_test_plan_response.created_test_plans[0] + + schedule_test_plans_request = ScheduleTestPlansRequest( + test_plans=[ + ScheduleTestPlanRequest( + id=created_test_plan.id, + planned_start_date_time=datetime.strptime( + "2025-05-20T15:07:42.527Z", "%Y-%m-%dT%H:%M:%S.%fZ" + ), + estimated_end_date_time=datetime.strptime( + "2025-05-22T15:07:42.527Z", "%Y-%m-%dT%H:%M:%S.%fZ" + ), + system_id="fake-system", + ) + ] + ) + schedule_test_plans_response = client.schedule_test_plans( + schedule_request=schedule_test_plans_request + ) + + delete_request = DeleteTestPlansRequest(ids=[created_test_plan.id]) + client.delete_test_plans(ids=delete_request) + + assert schedule_test_plans_response.scheduled_test_plans is not None + + scheduled_test_plan = schedule_test_plans_response.scheduled_test_plans[0] + assert scheduled_test_plan.id == created_test_plan.id + assert scheduled_test_plan.planned_start_date_time == datetime.strptime( + "2025-05-20T15:07:42.527Z", "%Y-%m-%dT%H:%M:%S.%fZ" + ) + assert scheduled_test_plan.system_id == "fake-system" + + def test__query_test_plans__return_queried_test_plan(self, client: TestPlanClient): + create_test_plan_response: CreateTestPlansResponse = client.create_test_plans( + create_request=self._test_plan_create + ) + + assert create_test_plan_response.created_test_plans is not None + + created_test_plan = create_test_plan_response.created_test_plans[0] + + query_test_plans_request = QueryTestPlansRequest( + filter=f'id = "{created_test_plan.id}"', return_count=True + ) + queried_test_plans_response = client.query_test_plans( + query_request=query_test_plans_request + ) + + delete_request = DeleteTestPlansRequest(ids=[created_test_plan.id]) + client.delete_test_plans(ids=delete_request) + + assert queried_test_plans_response is not None + assert queried_test_plans_response.test_plans[0].id == created_test_plan.id + assert queried_test_plans_response.total_count is not None + assert queried_test_plans_response.total_count > 0 + + def test__query_test_plans_with_projections__returns_the_test_plans_with_projected_properties( + self, client: TestPlanClient + ): + query_test_plans_request = QueryTestPlansRequest( + projection=[TestPlanField.ID, TestPlanField.NAME] + ) + response = client.query_test_plans(query_request=query_test_plans_request) + + assert response is not None + assert all( + test_plan.id is not None + and test_plan.name is not None + and test_plan.template_id is None + and test_plan.state is None + and test_plan.substate is None + and test_plan.description is None + and test_plan.assigned_to is None + and test_plan.work_order_id is None + and test_plan.work_order_name is None + and test_plan.workspace is None + and test_plan.created_by is None + and test_plan.updated_at is None + and test_plan.created_At is None + and test_plan.updated_by is None + and test_plan.properties is None + and test_plan.part_number is None + and test_plan.dut_id is None + and test_plan.test_program is None + and test_plan.system_filter is None + and test_plan.fixture_ids is None + and test_plan.system_id is None + and test_plan.planned_start_date_time is None + and test_plan.estimated_duration_in_seconds is None + and test_plan.estimated_end_date_time is None + and test_plan.file_ids_from_template is None + and test_plan.execution_actions is None + and test_plan.execution_history is None + and test_plan.dashboard_url is None + and test_plan.dashboard is None + and test_plan.workflow is None + for test_plan in response.test_plans + ) + + def test__create_test_plan_template__returns_created_test_plan_template( + self, client: TestPlanClient, create_test_plan_templates + ): + create_test_plan_template_request: List[TestPlanTemplateBase] = [ + TestPlanTemplateBase( + name="Python integration test plan template", + templateGroup="sample template group", + workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", + ) + ] + create_test_plan_template_response = create_test_plan_templates( + create_test_plan_template_request + ) + + template_id = ( + create_test_plan_template_response.created_test_plan_templates[0].id + if create_test_plan_template_response.created_test_plan_templates + and create_test_plan_template_response.created_test_plan_templates[0].id + else None + ) + + assert template_id is not None + assert ( + create_test_plan_template_response.created_test_plan_templates[0].name + == create_test_plan_template_request[0].name + ) + + def test__query_test_plan_template__returns_queried_test_plan_template( + self, client: TestPlanClient, create_test_plan_templates + ): + + create_test_plan_template_request: List[TestPlanTemplateBase] = [ + TestPlanTemplateBase( + name="Python integration test plan template", + templateGroup="sample template group", + workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", + ) + ] + + create_test_plan_template_response = create_test_plan_templates( + create_test_plan_template_request + ) + + template_id = ( + create_test_plan_template_response.created_test_plan_templates[0].id + if create_test_plan_template_response.created_test_plan_templates + and create_test_plan_template_response.created_test_plan_templates[0].id + else None + ) + + assert template_id is not None + + query = QueryTestPlanTemplatesRequest(filter=f'id="{template_id}"', take=1) + + query_test_plan_template_response: PagedTestPlanTemplates = ( + client.query_test_plan_templates(query_test_plan_templates=query) + ) + + assert len(query_test_plan_template_response.test_plan_templates) == 1, query + assert ( + query_test_plan_template_response.test_plan_templates[0].id == template_id + ) + + def test__delete_test_plan_template(self, client: TestPlanClient): + + create_test_plan_template_request: List[TestPlanTemplateBase] = [ + TestPlanTemplateBase( + name="Python integration test plan template", + templateGroup="sample template group", + workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", + ) + ] + create_test_plan_template_response: ( + CreateTestPlanTemplatePartialSuccessResponse + ) = client.create_test_plan_templates( + test_plan_templates=create_test_plan_template_request + ) + + template_id = ( + create_test_plan_template_response.created_test_plan_templates[0].id + if create_test_plan_template_response.created_test_plan_templates + and create_test_plan_template_response.created_test_plan_templates[0].id + else None + ) + + assert template_id is not None + + client.delete_test_plan_templates(ids=[template_id]) + + query_deleted_test_plan_template_response: PagedTestPlanTemplates = ( + client.query_test_plan_templates( + query_test_plan_templates=QueryTestPlanTemplatesRequest( + filter=f'id="{template_id}"', take=1 + ) + ) + ) + + assert len(query_deleted_test_plan_template_response.test_plan_templates) == 0 + + def test_query_test_plan_templates_with_projections__returns_test_plan_templates_with_projected_properties( + self, client: TestPlanClient + ): + query = QueryTestPlanTemplatesRequest( + projection=[TestPlanTemplateField.ID, TestPlanTemplateField.NAME], + ) + print(query) + response = client.query_test_plan_templates(query_test_plan_templates=query) + + assert response is not None + assert all( + test_plan_template.id is not None + and test_plan_template.name is not None + and test_plan_template.template_group is None + and test_plan_template.product_families is None + and test_plan_template.part_numbers is None + and test_plan_template.summary is None + and test_plan_template.description is None + and test_plan_template.test_program is None + and test_plan_template.estimated_duration_in_seconds is None + and test_plan_template.system_filter is None + and test_plan_template.execution_actions is None + and test_plan_template.file_ids is None + and test_plan_template.workspace is None + and test_plan_template.properties is None + and test_plan_template.dashboard is None + for test_plan_template in response.test_plan_templates + ) From 15572ccca8588385f7b359e4cdee288c48ae054e Mon Sep 17 00:00:00 2001 From: Ammar Husain Mian Fazulul Date: Thu, 22 May 2025 23:40:29 +0530 Subject: [PATCH 44/64] resolved comments --- examples/test_plan/test_plan_templates.py | 6 ++--- .../clients/test_plan/_test_plan_client.py | 2 +- .../clients/test_plan/models/__init__.py | 3 +++ .../_create_test_plan_template_request.py | 13 ++++++++++ .../_query_test_plan_templates_request.py | 14 +++-------- .../models/_query_test_plans_request.py | 12 +++------- .../integration/test_plan/test_test_plans.py | 24 ++++++++++--------- 7 files changed, 39 insertions(+), 35 deletions(-) create mode 100644 nisystemlink/clients/test_plan/models/_create_test_plan_template_request.py diff --git a/examples/test_plan/test_plan_templates.py b/examples/test_plan/test_plan_templates.py index da18de92..0c82e0e5 100644 --- a/examples/test_plan/test_plan_templates.py +++ b/examples/test_plan/test_plan_templates.py @@ -1,8 +1,8 @@ from nisystemlink.clients.core._http_configuration import HttpConfiguration from nisystemlink.clients.test_plan import TestPlanClient from nisystemlink.clients.test_plan.models import ( + CreateTestPlanTemplateRequest, QueryTestPlanTemplatesRequest, - TestPlanTemplateBase, ) @@ -15,9 +15,9 @@ # Test plan template request metadata create_test_plan_template_request = [ - TestPlanTemplateBase( + CreateTestPlanTemplateRequest( name="Python integration test plan template", - templateGroup="sample template group", + template_group="sample template group", workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", ) ] diff --git a/nisystemlink/clients/test_plan/_test_plan_client.py b/nisystemlink/clients/test_plan/_test_plan_client.py index b477bfd1..de3dd189 100644 --- a/nisystemlink/clients/test_plan/_test_plan_client.py +++ b/nisystemlink/clients/test_plan/_test_plan_client.py @@ -145,7 +145,7 @@ def update_test_plans( @post("testplan-templates", args=[Field("testPlanTemplates")]) def create_test_plan_templates( - self, test_plan_templates: List[models.TestPlanTemplateBase] + self, test_plan_templates: List[models.CreateTestPlanTemplateRequest] ) -> models.CreateTestPlanTemplatePartialSuccessResponse: """Creates one or more test plan template and return errors for failed creations. diff --git a/nisystemlink/clients/test_plan/models/__init__.py b/nisystemlink/clients/test_plan/models/__init__.py index 664ea035..60617fc0 100644 --- a/nisystemlink/clients/test_plan/models/__init__.py +++ b/nisystemlink/clients/test_plan/models/__init__.py @@ -60,5 +60,8 @@ from nisystemlink.clients.test_plan.models._paged_test_plan_templates import ( PagedTestPlanTemplates, ) +from nisystemlink.clients.test_plan.models._create_test_plan_template_request import ( + CreateTestPlanTemplateRequest, +) # flake8: noqa diff --git a/nisystemlink/clients/test_plan/models/_create_test_plan_template_request.py b/nisystemlink/clients/test_plan/models/_create_test_plan_template_request.py new file mode 100644 index 00000000..9b1c152c --- /dev/null +++ b/nisystemlink/clients/test_plan/models/_create_test_plan_template_request.py @@ -0,0 +1,13 @@ +from nisystemlink.clients.test_plan.models._test_plan_templates import ( + TestPlanTemplateBase, +) + + +class CreateTestPlanTemplateRequest(TestPlanTemplateBase): + """Contains information about a test plan template request.""" + + name: str + """Name of the test plan template.""" + + template_group: str + """The template group defined by the user.""" diff --git a/nisystemlink/clients/test_plan/models/_query_test_plan_templates_request.py b/nisystemlink/clients/test_plan/models/_query_test_plan_templates_request.py index c54552fe..d57f5024 100644 --- a/nisystemlink/clients/test_plan/models/_query_test_plan_templates_request.py +++ b/nisystemlink/clients/test_plan/models/_query_test_plan_templates_request.py @@ -2,7 +2,7 @@ from enum import Enum from typing import List, Optional -from nisystemlink.clients.core._uplink._json_model import JsonModel +from nisystemlink.clients.core._uplink._with_paging import WithPaging class TestPlanTemplateOrderBy(str, Enum): @@ -37,7 +37,7 @@ class TestPlanTemplateField(str, Enum): UPDATED_AT = enum.auto() -class QueryTestPlanTemplatesRequest(JsonModel): +class QueryTestPlanTemplatesRequest(WithPaging): """Request information for the query test plan templates API.""" filter: Optional[str] = None @@ -91,10 +91,6 @@ class QueryTestPlanTemplatesRequest(JsonModel): """Whether to return the test plan templates in the descending order. By default, test plan templates are sorted in the ascending order.""" - continuation_token: Optional[str] = None - """Allows users to continue the query at the next test plan templates that matches the given - criteria.""" - projection: Optional[List[TestPlanTemplateField]] = None """ Gets or sets the projection to be used when retrieving the assets. If not specified, @@ -102,7 +98,7 @@ class QueryTestPlanTemplatesRequest(JsonModel): """ -class _QueryTestPlanTemplatesRequest(JsonModel): +class _QueryTestPlanTemplatesRequest(WithPaging): """Request information for the query test plan templates API.""" filter: Optional[str] = None @@ -158,10 +154,6 @@ class _QueryTestPlanTemplatesRequest(JsonModel): """Whether to return the test plan templates in the descending order. By default, test plan templates are sorted in the ascending order.""" - continuation_token: Optional[str] = None - """Allows users to continue the query at the next test plan templates that matches the given - criteria.""" - projection: Optional[List[str]] = None """ Gets or sets the projection to be used when retrieving the assets. If not specified, diff --git a/nisystemlink/clients/test_plan/models/_query_test_plans_request.py b/nisystemlink/clients/test_plan/models/_query_test_plans_request.py index e94411a1..f092e8c4 100644 --- a/nisystemlink/clients/test_plan/models/_query_test_plans_request.py +++ b/nisystemlink/clients/test_plan/models/_query_test_plans_request.py @@ -1,7 +1,7 @@ import enum from typing import List, Optional -from nisystemlink.clients.core._uplink._json_model import JsonModel +from nisystemlink.clients.core._uplink._with_paging import WithPaging from ._order_by import OrderBy @@ -41,7 +41,7 @@ class TestPlanField(enum.Enum): WORKFLOW = enum.auto() -class QueryTestPlansRequest(JsonModel): +class QueryTestPlansRequest(WithPaging): """Represents the request body for querying test plans. Allows filtering, sorting, and pagination of test plan results. """ @@ -61,9 +61,6 @@ class QueryTestPlansRequest(JsonModel): return_count: Optional[bool] = None """Whether to include the total count of matching test plans in the response.""" - continuation_token: Optional[str] = None - """A token to retrieve the next page of results for paginated queries.""" - projection: Optional[List[TestPlanField]] = None """ Gets or sets the projection to be used when retrieving the assets. If not specified, @@ -71,7 +68,7 @@ class QueryTestPlansRequest(JsonModel): """ -class _QueryTestPlansRequest(JsonModel): +class _QueryTestPlansRequest(WithPaging): """Represents the request body for querying test plans. Allows filtering, sorting, and pagination of test plan results. """ @@ -91,9 +88,6 @@ class _QueryTestPlansRequest(JsonModel): return_count: Optional[bool] = None """Whether to include the total count of matching test plans in the response.""" - continuation_token: Optional[str] = None - """A token to retrieve the next page of results for paginated queries.""" - projection: Optional[List[str]] = None """Gets or sets the projection to be used when retrieving the assets. If not specified, all properties will be returned. diff --git a/tests/integration/test_plan/test_test_plans.py b/tests/integration/test_plan/test_test_plans.py index 74634ce6..2189976d 100644 --- a/tests/integration/test_plan/test_test_plans.py +++ b/tests/integration/test_plan/test_test_plans.py @@ -7,6 +7,9 @@ from nisystemlink.clients.test_plan.models._create_test_plan_request import ( CreateTestPlanRequest, ) +from nisystemlink.clients.test_plan.models._create_test_plan_template_request import ( + CreateTestPlanTemplateRequest, +) from nisystemlink.clients.test_plan.models._create_test_plan_templates_partial_success_response import ( CreateTestPlanTemplatePartialSuccessResponse, ) @@ -40,7 +43,6 @@ from nisystemlink.clients.test_plan.models._test_plan import TestPlan from nisystemlink.clients.test_plan.models._test_plan_templates import ( TestPlanTemplate, - TestPlanTemplateBase, ) from nisystemlink.clients.test_plan.models._update_test_plan_request import ( UpdateTestPlanRequest, @@ -62,7 +64,7 @@ def create_test_plan_templates(client: TestPlanClient): responses: List[CreateTestPlanTemplatePartialSuccessResponse] = [] def _create_test_plan_templates( - new_test_plan_templates: List[TestPlanTemplateBase], + new_test_plan_templates: List[CreateTestPlanTemplateRequest], ) -> CreateTestPlanTemplatePartialSuccessResponse: response = client.create_test_plan_templates( test_plan_templates=new_test_plan_templates @@ -286,10 +288,10 @@ def test__query_test_plans_with_projections__returns_the_test_plans_with_project def test__create_test_plan_template__returns_created_test_plan_template( self, client: TestPlanClient, create_test_plan_templates ): - create_test_plan_template_request: List[TestPlanTemplateBase] = [ - TestPlanTemplateBase( + create_test_plan_template_request: List[CreateTestPlanTemplateRequest] = [ + CreateTestPlanTemplateRequest( name="Python integration test plan template", - templateGroup="sample template group", + template_group="sample template group", workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", ) ] @@ -314,10 +316,10 @@ def test__query_test_plan_template__returns_queried_test_plan_template( self, client: TestPlanClient, create_test_plan_templates ): - create_test_plan_template_request: List[TestPlanTemplateBase] = [ - TestPlanTemplateBase( + create_test_plan_template_request: List[CreateTestPlanTemplateRequest] = [ + CreateTestPlanTemplateRequest( name="Python integration test plan template", - templateGroup="sample template group", + template_group="sample template group", workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", ) ] @@ -348,10 +350,10 @@ def test__query_test_plan_template__returns_queried_test_plan_template( def test__delete_test_plan_template(self, client: TestPlanClient): - create_test_plan_template_request: List[TestPlanTemplateBase] = [ - TestPlanTemplateBase( + create_test_plan_template_request: List[CreateTestPlanTemplateRequest] = [ + CreateTestPlanTemplateRequest( name="Python integration test plan template", - templateGroup="sample template group", + template_group="sample template group", workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", ) ] From 2231a4a16341ea81f07401f9227c8a1c4b5203be Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Fri, 23 May 2025 11:14:05 +0530 Subject: [PATCH 45/64] refactor file names --- .../test_plan/{test_plan.py => test_plans.py} | 0 .../clients/test_plan/models/__init__.py | 48 +++++++++---------- ...test_plans.py => test_test_plan_client.py} | 0 3 files changed, 24 insertions(+), 24 deletions(-) rename examples/test_plan/{test_plan.py => test_plans.py} (100%) rename tests/integration/test_plan/{test_test_plans.py => test_test_plan_client.py} (100%) diff --git a/examples/test_plan/test_plan.py b/examples/test_plan/test_plans.py similarity index 100% rename from examples/test_plan/test_plan.py rename to examples/test_plan/test_plans.py diff --git a/nisystemlink/clients/test_plan/models/__init__.py b/nisystemlink/clients/test_plan/models/__init__.py index 60617fc0..dbcfb328 100644 --- a/nisystemlink/clients/test_plan/models/__init__.py +++ b/nisystemlink/clients/test_plan/models/__init__.py @@ -1,66 +1,66 @@ -from nisystemlink.clients.test_plan.models._create_test_plan_request import ( +from ._create_test_plan_request import ( CreateTestPlanRequest, ) -from nisystemlink.clients.test_plan.models._create_test_plans_request import ( +from ._create_test_plans_request import ( CreateTestPlansRequest, ) -from nisystemlink.clients.test_plan.models._create_test_plans_response import ( +from ._create_test_plans_response import ( CreateTestPlansResponse, ) -from nisystemlink.clients.test_plan.models._delete_test_plans_request import ( +from ._delete_test_plans_request import ( DeleteTestPlansRequest, ) -from nisystemlink.clients.test_plan.models._update_test_plan_request import ( +from ._update_test_plan_request import ( UpdateTestPlanRequest, ) -from nisystemlink.clients.test_plan.models._update_test_plans_request import ( +from ._update_test_plans_request import ( UpdateTestPlansRequest, ) -from nisystemlink.clients.test_plan.models._update_test_plans_response import ( +from ._update_test_plans_response import ( UpdateTestPlansResponse, ) -from nisystemlink.clients.test_plan.models._query_test_plans_request import ( +from ._query_test_plans_request import ( QueryTestPlansRequest, _QueryTestPlansRequest, ) -from nisystemlink.clients.test_plan.models._paged_test_plans import PagedTestPlans -from nisystemlink.clients.test_plan.models._execution_event import ExecutionEvent -from nisystemlink.clients.test_plan.models._order_by import OrderBy -from nisystemlink.clients.test_plan.models._test_plan import TestPlan -from nisystemlink.clients.test_plan.models._state import State -from nisystemlink.clients.test_plan.models._execution_definition import ( +from ._paged_test_plans import PagedTestPlans +from ._execution_event import ExecutionEvent +from ._order_by import OrderBy +from ._test_plan import TestPlan +from ._state import State +from ._execution_definition import ( ExecutionDefinition, ) -from nisystemlink.clients.test_plan.models._schedule_test_plans_request import ( +from ._schedule_test_plans_request import ( ScheduleTestPlansRequest, ) -from nisystemlink.clients.test_plan.models._schedule_test_plan_request import ( +from ._schedule_test_plan_request import ( ScheduleTestPlanRequest, ) -from nisystemlink.clients.test_plan.models._schedule_test_plans_response import ( +from ._schedule_test_plans_response import ( ScheduleTestPlansResponse, ) -from nisystemlink.clients.test_plan.models._workflow_definition import ( +from ._workflow_definition import ( WorkflowDefinition, ) -from nisystemlink.clients.test_plan.models._test_plan_templates import ( +from ._test_plan_templates import ( TestPlanTemplateBase, TestPlanTemplate, ) -from nisystemlink.clients.test_plan.models._create_test_plan_templates_partial_success_response import ( +from ._create_test_plan_templates_partial_success_response import ( CreateTestPlanTemplatePartialSuccessResponse, ) -from nisystemlink.clients.test_plan.models._delete_test_plan_templates_partial_success_response import ( +from ._delete_test_plan_templates_partial_success_response import ( DeleteTestPlanTemplatesPartialSuccessResponse, ) -from nisystemlink.clients.test_plan.models._query_test_plan_templates_request import ( +from ._query_test_plan_templates_request import ( QueryTestPlanTemplatesRequest, _QueryTestPlanTemplatesRequest, ) -from nisystemlink.clients.test_plan.models._paged_test_plan_templates import ( +from ._paged_test_plan_templates import ( PagedTestPlanTemplates, ) -from nisystemlink.clients.test_plan.models._create_test_plan_template_request import ( +from ._create_test_plan_template_request import ( CreateTestPlanTemplateRequest, ) diff --git a/tests/integration/test_plan/test_test_plans.py b/tests/integration/test_plan/test_test_plan_client.py similarity index 100% rename from tests/integration/test_plan/test_test_plans.py rename to tests/integration/test_plan/test_test_plan_client.py From 82de1be4ce75545501a9881d56d95d1f5c33db4a Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Fri, 23 May 2025 19:39:16 +0530 Subject: [PATCH 46/64] update comment --- examples/test_plan/test_plan_templates.py | 2 +- examples/test_plan/test_plans.py | 18 +- .../clients/test_plan/_test_plan_client.py | 77 +------- .../clients/test_plan/models/__init__.py | 70 ++----- .../models/_create_test_plan_request.py | 13 +- .../_create_test_plan_template_request.py | 4 +- ...plan_templates_partial_success_response.py | 5 +- ...te_test_plans_partial_success_response.py} | 5 +- .../models/_create_test_plans_request.py | 15 -- .../clients/test_plan/models/_dashboard.py | 20 ++ .../models/_delete_test_plans_request.py | 10 - .../test_plan/models/_execution_definition.py | 31 +-- .../test_plan/models/_execution_event.py | 23 ++- .../_query_test_plan_templates_request.py | 112 +++-------- .../models/_query_test_plans_request.py | 86 +++------ .../models/_schedule_test_plans_request.py | 2 +- .../clients/test_plan/models/_test_plan.py | 7 +- .../models/_update_test_plan_request.py | 14 +- .../test_plan/models/_workflow_definition.py | 29 +-- .../test_plan/test_test_plan_client.py | 182 +++++++----------- 20 files changed, 236 insertions(+), 489 deletions(-) rename nisystemlink/clients/test_plan/models/{_create_test_plans_response.py => _create_test_plans_partial_success_response.py} (83%) delete mode 100644 nisystemlink/clients/test_plan/models/_create_test_plans_request.py create mode 100644 nisystemlink/clients/test_plan/models/_dashboard.py delete mode 100644 nisystemlink/clients/test_plan/models/_delete_test_plans_request.py diff --git a/examples/test_plan/test_plan_templates.py b/examples/test_plan/test_plan_templates.py index 0c82e0e5..fe831461 100644 --- a/examples/test_plan/test_plan_templates.py +++ b/examples/test_plan/test_plan_templates.py @@ -18,7 +18,7 @@ CreateTestPlanTemplateRequest( name="Python integration test plan template", template_group="sample template group", - workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", + workspace="YourWorksapceId", ) ] diff --git a/examples/test_plan/test_plans.py b/examples/test_plan/test_plans.py index d5796bbb..8f9cf2d3 100644 --- a/examples/test_plan/test_plans.py +++ b/examples/test_plan/test_plans.py @@ -2,8 +2,6 @@ from nisystemlink.clients.test_plan import TestPlanClient from nisystemlink.clients.test_plan.models import ( CreateTestPlanRequest, - CreateTestPlansRequest, - DeleteTestPlansRequest, QueryTestPlansRequest, ScheduleTestPlanRequest, ScheduleTestPlansRequest, @@ -18,17 +16,15 @@ ) client = TestPlanClient(configuration=server_configuration) -create_test_plans_request = CreateTestPlansRequest( - test_plans=[ - CreateTestPlanRequest( - name="Python integration test plan", state="NEW", partNumber="px40482" - ) - ] -) +create_test_plans_request = [ + CreateTestPlanRequest( + name="Python integration test plan", state="NEW", partNumber="px40482" + ) +] # create a test plan created_test_plans_response = client.create_test_plans( - create_request=create_test_plans_request + test_plans=create_test_plans_request ) if created_test_plans_response.created_test_plans: @@ -73,4 +69,4 @@ ) # Delete test plan -client.delete_test_plans(ids=DeleteTestPlansRequest(ids=[created_test_plan_id])) +client.delete_test_plans(ids=[created_test_plan_id]) diff --git a/nisystemlink/clients/test_plan/_test_plan_client.py b/nisystemlink/clients/test_plan/_test_plan_client.py index de3dd189..f24a8520 100644 --- a/nisystemlink/clients/test_plan/_test_plan_client.py +++ b/nisystemlink/clients/test_plan/_test_plan_client.py @@ -43,10 +43,10 @@ def get_test_plan(self, test_plan_id: str) -> models.TestPlan: """ ... - @post("testplans") + @post("testplans", args=[Field("testPlans")]) def create_test_plans( - self, create_request: models.CreateTestPlansRequest - ) -> models.CreateTestPlansResponse: + self, test_plans: List[models.CreateTestPlanRequest] + ) -> models.CreateTestPlansPartialSuccessResponse: """Create a new test plan. Args: @@ -57,8 +57,8 @@ def create_test_plans( """ ... - @post("delete-testplans") - def delete_test_plans(self, ids: models.DeleteTestPlansRequest) -> None: + @post("delete-testplans", args=[Field("ids")]) + def delete_test_plans(self, ids: List[str]) -> None: """Delete test plans by IDs. Args: @@ -70,19 +70,6 @@ def delete_test_plans(self, ids: models.DeleteTestPlansRequest) -> None: ... @post("query-testplans") - def __query_test_plans( - self, query_request: models._QueryTestPlansRequest - ) -> models.PagedTestPlans: - """Query test plans. - - Args: - query: The query to execute. - - Returns: - A PagedTestPlans object containing test plans that match the query. - """ - ... - def query_test_plans( self, query_request: models.QueryTestPlansRequest ) -> models.PagedTestPlans: @@ -94,26 +81,7 @@ def query_test_plans( Returns: A PagedTestPlans object containing test plans that match the query. """ - projection_str = ( - [projection.name for projection in query_request.projection] - if query_request.projection - else None - ) - query_params = { - "filter": query_request.filter, - "take": query_request.take, - "continuation_token": query_request.continuation_token, - "order_by": query_request.order_by, - "descending": query_request.descending, - "return_count": query_request.return_count, - "projection": projection_str, - } - - query_params = {k: v for k, v in query_params.items() if v is not None} - - query_test_plans_request = models._QueryTestPlansRequest(**query_params) - - return self.__query_test_plans(query_request=query_test_plans_request) + ... @post("schedule-testplans") def schedule_test_plans( @@ -161,18 +129,6 @@ def create_test_plan_templates( ... @post("query-testplan-templates") - def __query_test_plan_templates( - self, query_test_plan_templates: models._QueryTestPlanTemplatesRequest - ) -> models.PagedTestPlanTemplates: - """Queries one or more test plan templates and return errors for failed queries. - - Returns: A list of test plan templates, based on the query and errors for the wrong query. - - Raises: ApiException: if unable to communicate with the `/niworkorder` service of provided invalid - arguments. - """ - ... - def query_test_plan_templates( self, query_test_plan_templates: models.QueryTestPlanTemplatesRequest ) -> models.PagedTestPlanTemplates: @@ -183,26 +139,7 @@ def query_test_plan_templates( Raises: ApiException: if unable to communicate with the `/niworkorder` service of provided invalid arguments. """ - projection_str = ( - [projection.name for projection in query_test_plan_templates.projection] - if query_test_plan_templates.projection - else None - ) - query_params = { - "filter": query_test_plan_templates.filter, - "take": query_test_plan_templates.take, - "substitutions": query_test_plan_templates.substitutions, - "continuationToken": query_test_plan_templates.continuation_token, - "orderBy": query_test_plan_templates.order_by, - "descending": query_test_plan_templates.descending, - "projection": projection_str, - } - - query_params = {k: v for k, v in query_params.items() if v is not None} - - query_request = models._QueryTestPlanTemplatesRequest(**query_params) - - return self.__query_test_plan_templates(query_test_plan_templates=query_request) + ... @post("delete-testplan-templates", args=[Field("ids")]) def delete_test_plan_templates( diff --git a/nisystemlink/clients/test_plan/models/__init__.py b/nisystemlink/clients/test_plan/models/__init__.py index dbcfb328..482d25f1 100644 --- a/nisystemlink/clients/test_plan/models/__init__.py +++ b/nisystemlink/clients/test_plan/models/__init__.py @@ -1,52 +1,24 @@ -from ._create_test_plan_request import ( - CreateTestPlanRequest, -) -from ._create_test_plans_request import ( - CreateTestPlansRequest, -) -from ._create_test_plans_response import ( - CreateTestPlansResponse, -) -from ._delete_test_plans_request import ( - DeleteTestPlansRequest, -) -from ._update_test_plan_request import ( - UpdateTestPlanRequest, -) -from ._update_test_plans_request import ( - UpdateTestPlansRequest, -) -from ._update_test_plans_response import ( - UpdateTestPlansResponse, -) -from ._query_test_plans_request import ( - QueryTestPlansRequest, - _QueryTestPlansRequest, -) +from ._create_test_plan_request import CreateTestPlanRequest +from ._create_test_plans_partial_success_response import ( + CreateTestPlansPartialSuccessResponse, +) +from ._dashboard import Dashboard, DashboardUrl +from ._update_test_plan_request import UpdateTestPlanRequest +from ._update_test_plans_request import UpdateTestPlansRequest +from ._update_test_plans_response import UpdateTestPlansResponse +from ._query_test_plans_request import QueryTestPlansRequest, TestPlanField from ._paged_test_plans import PagedTestPlans from ._execution_event import ExecutionEvent from ._order_by import OrderBy from ._test_plan import TestPlan from ._state import State -from ._execution_definition import ( - ExecutionDefinition, -) -from ._schedule_test_plans_request import ( - ScheduleTestPlansRequest, -) -from ._schedule_test_plan_request import ( - ScheduleTestPlanRequest, -) -from ._schedule_test_plans_response import ( - ScheduleTestPlansResponse, -) -from ._workflow_definition import ( - WorkflowDefinition, -) -from ._test_plan_templates import ( - TestPlanTemplateBase, - TestPlanTemplate, -) +from ._execution_definition import ExecutionDefinition +from ._schedule_test_plans_request import ScheduleTestPlansRequest +from ._schedule_test_plan_request import ScheduleTestPlanRequest +from ._schedule_test_plans_response import ScheduleTestPlansResponse +from ._workflow_definition import WorkflowDefinition + +from ._test_plan_templates import TestPlanTemplateBase, TestPlanTemplate from ._create_test_plan_templates_partial_success_response import ( CreateTestPlanTemplatePartialSuccessResponse, ) @@ -55,13 +27,9 @@ ) from ._query_test_plan_templates_request import ( QueryTestPlanTemplatesRequest, - _QueryTestPlanTemplatesRequest, -) -from ._paged_test_plan_templates import ( - PagedTestPlanTemplates, -) -from ._create_test_plan_template_request import ( - CreateTestPlanTemplateRequest, + TestPlanTemplateField, ) +from ._paged_test_plan_templates import PagedTestPlanTemplates +from ._create_test_plan_template_request import CreateTestPlanTemplateRequest # flake8: noqa diff --git a/nisystemlink/clients/test_plan/models/_create_test_plan_request.py b/nisystemlink/clients/test_plan/models/_create_test_plan_request.py index 4aab15a6..df911c18 100644 --- a/nisystemlink/clients/test_plan/models/_create_test_plan_request.py +++ b/nisystemlink/clients/test_plan/models/_create_test_plan_request.py @@ -2,19 +2,10 @@ from nisystemlink.clients.core._uplink._json_model import JsonModel +from ._dashboard import Dashboard from ._execution_definition import ExecutionDefinition -class Dashboard(JsonModel): - """Represents a dashboard reference.""" - - id: Optional[str] = None - """ID of the dashboard""" - - variables: Optional[Dict[str, str]] = None - """Variables for the dashboard""" - - class CreateTestPlanRequest(JsonModel): """Represents the request body content for creating a test plan.""" @@ -51,7 +42,7 @@ class CreateTestPlanRequest(JsonModel): test_program: Optional[str] = None """The test program associated with the test plan.""" - systemtest_programfilter: Optional[str] = None + system_filter: Optional[str] = None """The system filter to apply.""" workspace: Optional[str] = None diff --git a/nisystemlink/clients/test_plan/models/_create_test_plan_template_request.py b/nisystemlink/clients/test_plan/models/_create_test_plan_template_request.py index 9b1c152c..981ab732 100644 --- a/nisystemlink/clients/test_plan/models/_create_test_plan_template_request.py +++ b/nisystemlink/clients/test_plan/models/_create_test_plan_template_request.py @@ -1,6 +1,4 @@ -from nisystemlink.clients.test_plan.models._test_plan_templates import ( - TestPlanTemplateBase, -) +from ._test_plan_templates import TestPlanTemplateBase class CreateTestPlanTemplateRequest(TestPlanTemplateBase): diff --git a/nisystemlink/clients/test_plan/models/_create_test_plan_templates_partial_success_response.py b/nisystemlink/clients/test_plan/models/_create_test_plan_templates_partial_success_response.py index c43be005..4eee6232 100644 --- a/nisystemlink/clients/test_plan/models/_create_test_plan_templates_partial_success_response.py +++ b/nisystemlink/clients/test_plan/models/_create_test_plan_templates_partial_success_response.py @@ -3,7 +3,8 @@ from nisystemlink.clients.core._api_error import ApiError from nisystemlink.clients.core._uplink._json_model import JsonModel -from ._test_plan_templates import TestPlanTemplate, TestPlanTemplateBase +from ._create_test_plan_template_request import CreateTestPlanTemplateRequest +from ._test_plan_templates import TestPlanTemplate class CreateTestPlanTemplatePartialSuccessResponse(JsonModel): @@ -11,7 +12,7 @@ class CreateTestPlanTemplatePartialSuccessResponse(JsonModel): created_test_plan_templates: Optional[List[TestPlanTemplate]] = None """The list of test plan templates that were successfully created.""" - failed_test_plan_templates: Optional[List[TestPlanTemplateBase]] = None + failed_test_plan_templates: Optional[List[CreateTestPlanTemplateRequest]] = None """The list of test plan templates that were not created. If this is `None`, then all test plan templates were successfully created. diff --git a/nisystemlink/clients/test_plan/models/_create_test_plans_response.py b/nisystemlink/clients/test_plan/models/_create_test_plans_partial_success_response.py similarity index 83% rename from nisystemlink/clients/test_plan/models/_create_test_plans_response.py rename to nisystemlink/clients/test_plan/models/_create_test_plans_partial_success_response.py index 4c900278..1bdd19d2 100644 --- a/nisystemlink/clients/test_plan/models/_create_test_plans_response.py +++ b/nisystemlink/clients/test_plan/models/_create_test_plans_partial_success_response.py @@ -7,14 +7,11 @@ from ._test_plan import TestPlan -class CreateTestPlansResponse(JsonModel): +class CreateTestPlansPartialSuccessResponse(JsonModel): """Represents the response from creating test plans, including successfully created, failed test plans, and any associated errors. """ - test_plans: Optional[List[TestPlan]] = None - """List of all test plans involved in the operation.""" - created_test_plans: Optional[List[TestPlan]] = None """List of test plans that were successfully created.""" diff --git a/nisystemlink/clients/test_plan/models/_create_test_plans_request.py b/nisystemlink/clients/test_plan/models/_create_test_plans_request.py deleted file mode 100644 index db0edbaf..00000000 --- a/nisystemlink/clients/test_plan/models/_create_test_plans_request.py +++ /dev/null @@ -1,15 +0,0 @@ -from typing import List, Optional - -from nisystemlink.clients.core._uplink._json_model import JsonModel - -from ._create_test_plan_request import CreateTestPlanRequest - - -class CreateTestPlansRequest(JsonModel): - """Represents the request body for creating multiple test plans.""" - - test_plans: Optional[List[CreateTestPlanRequest]] = None - """ - A list of test plan creation request bodies. Each item in the list contains - the content required to create an individual test plan. - """ diff --git a/nisystemlink/clients/test_plan/models/_dashboard.py b/nisystemlink/clients/test_plan/models/_dashboard.py new file mode 100644 index 00000000..030f72ee --- /dev/null +++ b/nisystemlink/clients/test_plan/models/_dashboard.py @@ -0,0 +1,20 @@ +from typing import Dict, Optional + +from nisystemlink.clients.core._uplink._json_model import JsonModel + + +class Dashboard(JsonModel): + """Represents a dashboard reference.""" + + id: Optional[str] = None + """ID of the dashboard""" + + variables: Optional[Dict[str, str]] = None + """Variables for the dashboard""" + + +class DashboardUrl(Dashboard): + """Definition and URL of the dashboard reference associated with this test plan.""" + + url: Optional[str] = None + """URL of the dashboard reference associated with this test plan.""" diff --git a/nisystemlink/clients/test_plan/models/_delete_test_plans_request.py b/nisystemlink/clients/test_plan/models/_delete_test_plans_request.py deleted file mode 100644 index aef42b7f..00000000 --- a/nisystemlink/clients/test_plan/models/_delete_test_plans_request.py +++ /dev/null @@ -1,10 +0,0 @@ -from typing import List - -from nisystemlink.clients.core._uplink._json_model import JsonModel - - -class DeleteTestPlansRequest(JsonModel): - """Represents a request to delete one or more test plans.""" - - ids: List[str] - """List of test plan IDS of test plans to be deleted""" diff --git a/nisystemlink/clients/test_plan/models/_execution_definition.py b/nisystemlink/clients/test_plan/models/_execution_definition.py index 6e9d8097..6257ab3d 100644 --- a/nisystemlink/clients/test_plan/models/_execution_definition.py +++ b/nisystemlink/clients/test_plan/models/_execution_definition.py @@ -1,4 +1,4 @@ -from typing import Annotated, Any, List, Literal, Optional, Union +from typing import Annotated, Any, Dict, List, Literal, Optional, Union from nisystemlink.clients.core._uplink._json_model import JsonModel from pydantic import Field @@ -13,7 +13,7 @@ class Job(JsonModel): arguments: List[List[Any]] """List of argument lists for each function.""" - metadata: dict[str, Any] + metadata: Dict[str, Any] """Additional metadata for the job.""" @@ -29,6 +29,9 @@ class NotebookExecution(JsonModel): notebookId: str """ID of the notebook to execute.""" + parameters: Optional[Dict[str, str]] = None + """ Dictionary of parameters that will be passed to the notebook when the execution is run.""" + class ManualExecution(JsonModel): """Represents a manual execution definition.""" @@ -49,33 +52,13 @@ class JobExecution(JsonModel): type: Literal["JOB"] = Field(default="JOB") """Type of execution, default is 'JOB'.""" - jobs: List[Job] + jobs: Optional[List[Job]] = None """List of jobs to execute.""" systemId: Optional[str] = None """Optional system ID where jobs will run.""" -class ScheduleExecution(JsonModel): - """Represents a scheduled execution definition.""" - - action: str - """User defined action to perform in workflow (user defined).""" - - type: Literal["SCHEDULE"] = Field(default="SCHEDULE") - """Type of execution, default is 'SCHEDULE'.""" - - -class UnscheduleExecution(JsonModel): - """Represents an unscheduled execution definition.""" - - action: str - """User defined action to perform in workflow (user defined).""" - - type: Literal["UNSCHEDULE"] = Field(default="UNSCHEDULE") - """Type of execution, default is 'UNSCHEDULE'.""" - - class NoneExecution(JsonModel): """Represents a definition where no execution is specified.""" @@ -91,8 +74,6 @@ class NoneExecution(JsonModel): NotebookExecution, ManualExecution, JobExecution, - ScheduleExecution, - UnscheduleExecution, NoneExecution, ], Field(discriminator="type"), diff --git a/nisystemlink/clients/test_plan/models/_execution_event.py b/nisystemlink/clients/test_plan/models/_execution_event.py index 2b1d7808..6a51a835 100644 --- a/nisystemlink/clients/test_plan/models/_execution_event.py +++ b/nisystemlink/clients/test_plan/models/_execution_event.py @@ -1,6 +1,8 @@ -from typing import List, Optional, Union +from datetime import datetime +from typing import Annotated, List, Literal, Optional, Union from nisystemlink.clients.core._uplink._json_model import JsonModel +from pydantic import Field class ExecutionEventBase(JsonModel): @@ -9,7 +11,7 @@ class ExecutionEventBase(JsonModel): action: Optional[str] = None """The user-defined action that initiated the event.""" - triggered_at: Optional[str] = None + triggered_at: Optional[datetime] = None """The time the event was triggered.""" triggered_by: Optional[str] = None @@ -19,7 +21,7 @@ class ExecutionEventBase(JsonModel): class NotebookExecutionEvent(ExecutionEventBase): """Represents an execution event that was triggered by a notebook execution.""" - type: Optional[str] = "NOTEBOOK" + type: Literal["NOTEBOOK"] = Field(default="NOTEBOOK") """Represents an execution event triggered by a notebook.""" execution_id: Optional[str] = None @@ -29,18 +31,25 @@ class NotebookExecutionEvent(ExecutionEventBase): class JobExecutionEvent(ExecutionEventBase): """A concrete execution event that represents an event triggered by a job.""" - type: Optional[str] = "JOB" + type: Literal["JOB"] = Field(default="JOB") """Represents an execution event triggered by a job.""" - job_ids: Optional[List[str]] + job_ids: Optional[List[str]] = None """Includes the type identifier and a list of job IDs.""" class ManualExecutionEvent(ExecutionEventBase): """A concrete execution event that represents an event triggered manually.""" - type: Optional[str] = "MANUAL" + type: Literal["MANUAL"] = Field(default="MANUAL") """Represents an execution event triggered manually. Includes only the type identifier.""" -ExecutionEvent = Union[NotebookExecutionEvent, ManualExecutionEvent, JobExecutionEvent] +ExecutionEvent = Annotated[ + Union[ + NotebookExecutionEvent, + ManualExecutionEvent, + JobExecutionEvent, + ], + Field(discriminator="type"), +] diff --git a/nisystemlink/clients/test_plan/models/_query_test_plan_templates_request.py b/nisystemlink/clients/test_plan/models/_query_test_plan_templates_request.py index d57f5024..25fca6b0 100644 --- a/nisystemlink/clients/test_plan/models/_query_test_plan_templates_request.py +++ b/nisystemlink/clients/test_plan/models/_query_test_plan_templates_request.py @@ -1,4 +1,3 @@ -import enum from enum import Enum from typing import List, Optional @@ -8,33 +7,33 @@ class TestPlanTemplateOrderBy(str, Enum): """An enumeration by which test plan templates can be ordered/sorted.""" - ID = enum.auto() - NAME = enum.auto() - TEMPLATE_GROUP = enum.auto() - CREATED_AT = enum.auto() - UPDATED_AT = enum.auto() + ID = "ID" + NAME = "NAME" + TEMPLATE_GROUP = "TEMPLATE_GROUP" + CREATED_AT = "CREATED_AT" + UPDATED_AT = "UPDATED_AT" class TestPlanTemplateField(str, Enum): - ID = enum.auto() - NAME = enum.auto() - TEMPLATE_GROUP = enum.auto() - PRODUCT_FAMILIES = enum.auto() - PART_NUMBERS = enum.auto() - SUMMARY = enum.auto() - DESCRIPTION = enum.auto() - TEST_PROGRAM = enum.auto() - ESTIMATED_DURATION_IN_SECONDS = enum.auto() - SYSTEM_FILTER = enum.auto() - EXECUTION_ACTIONS = enum.auto() - FILE_IDS = enum.auto() - WORKSPACE = enum.auto() - PROPERTIES = enum.auto() - DASHBOARD = enum.auto() - CREATED_BY = enum.auto() - UPDATED_BY = enum.auto() - CREATED_AT = enum.auto() - UPDATED_AT = enum.auto() + ID = "ID" + NAME = "NAME" + TEMPLATE_GROUP = "TEMPLATE_GROUP" + PRODUCT_FAMILIES = "PRODUCT_FAMILIES" + PART_NUMBERS = "PART_NUMBERS" + SUMMARY = "SUMMARY" + DESCRIPTION = "DESCRIPTION" + TEST_PROGRAM = "TEST_PROGRAM" + ESTIMATED_DURATION_IN_SECONDS = "ESTIMATED_DURATION_IN_SECONDS" + SYSTEM_FILTER = "SYSTEM_FILTER" + EXECUTION_ACTIONS = "EXECUTION_ACTIONS" + FILE_IDS = "FILE_IDS" + WORKSPACE = "WORKSPACE" + PROPERTIES = "PROPERTIES" + DASHBOARD = "DASHBOARD" + CREATED_BY = "CREATED_BY" + UPDATED_BY = "UPDATED_BY" + CREATED_AT = "CREATED_AT" + UPDATED_AT = "UPDATED_AT" class QueryTestPlanTemplatesRequest(WithPaging): @@ -96,66 +95,3 @@ class QueryTestPlanTemplatesRequest(WithPaging): Gets or sets the projection to be used when retrieving the assets. If not specified, all properties will be returned. """ - - -class _QueryTestPlanTemplatesRequest(WithPaging): - """Request information for the query test plan templates API.""" - - filter: Optional[str] = None - """The test plan template query filter in dynamic LINQ format. - - `id`: String representing the ID of a test plan template. Field supports only equals '=' and not - equal '!=' operators for filtering. - `productFamilies`: Array of strings representing the product families to which the test plan - template belongs. - `partNumbers`: Array of strings representing the part numbers of the products to which the test - plan template belongs. - `fileIds`: The array of file IDs associated with the test plan template. - `name`: String representing the name of a test plan template. - `summary`: String representing the summary of a test plan template. - `description`: String representing description of the test plan created from this template. - `templateGroup`: String representing the template group defined by the user. - `testProgram`: String representing the test program name of the test plan created from this - template. - `systemFilter`: String representing the LINQ filter used to filter the potential list of systems - capable of executing test plans created from this template. - `workspace`: String representing the workspace where the test plan template belongs. - `createdBy`: String representing the user who created the test plan template. - `updatedBy`: String representing the user who updated the test plan template. - `createdAt`: ISO-8601 formatted timestamp indicating when the test plan template was created. - `updatedAt`: ISO-8601 formatted timestamp indicating when the test plan template was most - recently updated. - `properties`: Collection of key-value pairs related to a test plan created from this template. - Example: properties.Any(key == "Location" & value == "Austin") - - See - [Dynamic Linq](https://github.com/ni/systemlink-OpenAPI-documents/wiki/Dynamic-Linq-Query-Language) - documentation for more details. - - `"@0"`, `"@1"` etc. can be used in conjunction with the `substitutions` parameter to keep this - query string more simple and reusable. - """ - - take: Optional[int] = None - """The maximum number of test plan templates to return.""" - - order_by: Optional[TestPlanTemplateOrderBy] = None - """Field by which test plan templates can be ordered/sorted.""" - - substitutions: Optional[List[str]] = None - """Makes substitutions in the query filter expression - using non-negative integers. These integers - use the @ symbol as a prefix. The filter - expression replaces each substitution - with the element at the corresponding - index in this list. The index is zero-based.""" - - descending: Optional[bool] = None - """Whether to return the test plan templates in the descending order. By default, test plan - templates are sorted in the ascending order.""" - - projection: Optional[List[str]] = None - """ - Gets or sets the projection to be used when retrieving the assets. If not specified, - all properties will be returned. - """ diff --git a/nisystemlink/clients/test_plan/models/_query_test_plans_request.py b/nisystemlink/clients/test_plan/models/_query_test_plans_request.py index f092e8c4..61c30327 100644 --- a/nisystemlink/clients/test_plan/models/_query_test_plans_request.py +++ b/nisystemlink/clients/test_plan/models/_query_test_plans_request.py @@ -9,36 +9,36 @@ class TestPlanField(enum.Enum): """Model for an object describing an test plan with all of its properties.""" - ID = enum.auto() - TEMPLATE_ID = enum.auto() - NAME = enum.auto() - STATE = enum.auto() - SUBSTATE = enum.auto() - DESCRIPTION = enum.auto() - ASSIGNED_TO = enum.auto() - WORK_ORDER_ID = enum.auto() - WORK_ORDER_NAME = enum.auto() - WORKSPACE = enum.auto() - CREATED_BY = enum.auto() - UPDATED_BY = enum.auto() - CREATED_AT = enum.auto() - UPDATED_AT = enum.auto() - PROPERTIES = enum.auto() - PART_NUMBER = enum.auto() - DUT_ID = enum.auto() - TEST_PROGRAM = enum.auto() - SYSTEM_ID = enum.auto() - FIXTURE_IDS = enum.auto() - SYSTEM_FILTER = enum.auto() - PLANNED_START_DATE_TIME = enum.auto() - ESTIMATED_END_DATE_TIME = enum.auto() - ESTIMATED_DURATION_IN_SECONDS = enum.auto() - FILE_IDS_FROM_TEMPLATE = enum.auto() - EXECUTION_ACTIONS = enum.auto() - EXECUTION_HISTORY = enum.auto() - DASHBOARD_URL = enum.auto() - DASHBOARD = enum.auto() - WORKFLOW = enum.auto() + ID = "ID" + TEMPLATE_ID = "TEMPLATE_ID" + NAME = "NAME" + STATE = "STATE" + SUBSTATE = "SUBSTATE" + DESCRIPTION = "DESCRIPTION" + ASSIGNED_TO = "ASSIGNED_TO" + WORK_ORDER_ID = "WORK_ORDER_ID" + WORK_ORDER_NAME = "WORK_ORDER_NAME" + WORKSPACE = "WORKSPACE" + CREATED_BY = "CREATED_BY" + UPDATED_BY = "UPDATED_BY" + CREATED_AT = "CREATED_AT" + UPDATED_AT = "UPDATED_AT" + PROPERTIES = "PROPERTIES" + PART_NUMBER = "PART_NUMBER" + DUT_ID = "DUT_ID" + TEST_PROGRAM = "TEST_PROGRAM" + SYSTEM_ID = "SYSTEM_ID" + FIXTURE_IDS = "FIXTURE_IDS" + SYSTEM_FILTER = "SYSTEM_FILTER" + PLANNED_START_DATE_TIME = "PLANNED_START_DATE_TIME" + ESTIMATED_END_DATE_TIME = "ESTIMATED_END_DATE_TIME" + ESTIMATED_DURATION_IN_SECONDS = "ESTIMATED_DURATION_IN_SECONDS" + FILE_IDS_FROM_TEMPLATE = "FILE_IDS_FROM_TEMPLATE" + EXECUTION_ACTIONS = "EXECUTION_ACTIONS" + EXECUTION_HISTORY = "EXECUTION_HISTORY" + DASHBOARD_URL = "DASHBOARD_URL" + DASHBOARD = "DASHBOARD" + WORKFLOW = "WORKFLOW" class QueryTestPlansRequest(WithPaging): @@ -66,29 +66,3 @@ class QueryTestPlansRequest(WithPaging): Gets or sets the projection to be used when retrieving the assets. If not specified, all properties will be returned. """ - - -class _QueryTestPlansRequest(WithPaging): - """Represents the request body for querying test plans. - Allows filtering, sorting, and pagination of test plan results. - """ - - filter: Optional[str] = None - """A string expression to filter the test plans returned by the query.""" - - take: Optional[int] = None - """The maximum number of test plans to return in the response.""" - - order_by: Optional[str] = None - """The field name to use for sorting the test plans.""" - - descending: Optional[bool] = None - """Whether to sort the test plans in descending order.""" - - return_count: Optional[bool] = None - """Whether to include the total count of matching test plans in the response.""" - - projection: Optional[List[str]] = None - """Gets or sets the projection to be used when retrieving the assets. If not specified, - all properties will be returned. - """ diff --git a/nisystemlink/clients/test_plan/models/_schedule_test_plans_request.py b/nisystemlink/clients/test_plan/models/_schedule_test_plans_request.py index eaff40d4..68627d7e 100644 --- a/nisystemlink/clients/test_plan/models/_schedule_test_plans_request.py +++ b/nisystemlink/clients/test_plan/models/_schedule_test_plans_request.py @@ -8,7 +8,7 @@ class ScheduleTestPlansRequest(JsonModel): """Represents the request body for scheduling multiple test plans.""" - test_plans: Optional[List[ScheduleTestPlanRequest]] + test_plans: List[ScheduleTestPlanRequest] """List of test plan scheduling content objects.""" replace: Optional[bool] = None diff --git a/nisystemlink/clients/test_plan/models/_test_plan.py b/nisystemlink/clients/test_plan/models/_test_plan.py index 27649f5b..d0d2979a 100644 --- a/nisystemlink/clients/test_plan/models/_test_plan.py +++ b/nisystemlink/clients/test_plan/models/_test_plan.py @@ -3,6 +3,7 @@ from nisystemlink.clients.core._uplink._json_model import JsonModel +from ._dashboard import DashboardUrl from ._execution_definition import ExecutionDefinition from ._execution_event import ExecutionEvent from ._state import State @@ -48,10 +49,10 @@ class TestPlan(JsonModel): updated_by: Optional[str] = None """The user who last updated the test plan.""" - created_At: Optional[str] = None + created_At: Optional[datetime] = None """The date and time when the test plan was created.""" - updated_at: Optional[str] = None + updated_at: Optional[datetime] = None """The date and time when the test plan was last updated.""" properties: Optional[Dict[str, str]] = None @@ -96,7 +97,7 @@ class TestPlan(JsonModel): dashboard_url: Optional[Dict[str, str]] = None """The URLs for dashboards related to the test plan.""" - dashboard: Optional[Dict[str, str]] = None + dashboard: Optional[DashboardUrl] = None """The dashboard data related to the test plan.""" workflow: Optional[WorkflowDefinition] = None diff --git a/nisystemlink/clients/test_plan/models/_update_test_plan_request.py b/nisystemlink/clients/test_plan/models/_update_test_plan_request.py index da765047..7fe1ad25 100644 --- a/nisystemlink/clients/test_plan/models/_update_test_plan_request.py +++ b/nisystemlink/clients/test_plan/models/_update_test_plan_request.py @@ -1,4 +1,4 @@ -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional from nisystemlink.clients.core._uplink._json_model import JsonModel @@ -18,25 +18,25 @@ class UpdateTestPlanRequest(JsonModel): description: Optional[str] = None """The new description for the test plan.""" - dut_id: Optional[Union[str, None]] = None + dut_id: Optional[str] = None """The device under test (DUT) identifier.""" part_number: Optional[str] = None """The part number associated with the test plan.""" - assigned_to: Optional[Union[str, None]] = None + assigned_to: Optional[str] = None """The user or group assigned to the test plan.""" - test_program: Optional[Union[str, None]] = None + test_program: Optional[str] = None """The test program associated with the test plan.""" - properties: Optional[Union[Dict[str, str], None]] = None + properties: Optional[Dict[str, str]] = None """Additional properties for the test plan as key-value pairs.""" - workspace: Optional[Union[str, None]] = None + workspace: Optional[str] = None """The workspace to which the test plan belongs.""" - work_order_id: Optional[Union[str, None]] = None + work_order_id: Optional[str] = None """The work order identifier associated with the test plan.""" file_ids_from_template: Optional[List[str]] = None diff --git a/nisystemlink/clients/test_plan/models/_workflow_definition.py b/nisystemlink/clients/test_plan/models/_workflow_definition.py index d34d688c..88570230 100644 --- a/nisystemlink/clients/test_plan/models/_workflow_definition.py +++ b/nisystemlink/clients/test_plan/models/_workflow_definition.py @@ -1,4 +1,7 @@ +from typing import List, Optional + from nisystemlink.clients.core._uplink._json_model import JsonModel +from pydantic import Field from ._execution_definition import ExecutionDefinition from ._state import State @@ -16,57 +19,57 @@ class ActionTransitionDefinition(JsonModel): next_substate: str """The substate to transition to within the next state.""" - show_in_u_i: bool + show_in_UI: bool = Field(alias="showInUI") """Indicates whether this transition should be visible in the user interface.""" class SubstateDefinition(JsonModel): """Represents a substate within a workflow definition.""" - id: str + id: Optional[str] = None """The unique identifier for the substate.""" - label: str + label: Optional[str] = None """The display label for the substate.""" - available_actions: list[ActionTransitionDefinition] + available_actions: Optional[list[ActionTransitionDefinition]] = None """List of actions that can be performed from this substate.""" class StateDefinition(JsonModel): """Represents the definition of a workflow state within a test plan.""" - state: State + state: Optional[State] = None """The state associated with this definition.""" - dashboard_available: bool + dashboard_available: Optional[bool] = None """Indicates if the state is available on the dashboard.""" - default_substate: str + default_substate: Optional[str] = None """The name of the default substate for this state.""" - substates: list[SubstateDefinition] + substates: Optional[list[SubstateDefinition]] = None """A list of substates defined for this state.""" class ActionDefinition(JsonModel): """Represents the definition of an action within a workflow.""" - id: str + id: Optional[str] = None """The unique identifier for the action.""" - label: str + label: Optional[str] = None """The display label for the action.""" - execution_action: ExecutionDefinition + execution_action: Optional[ExecutionDefinition] = None """The execution details associated with the action.""" class WorkflowDefinition(JsonModel): """Contains information about a workflow definition.""" - actions: list[ActionDefinition] + actions: Optional[List[ActionDefinition]] = None """A list of action definitions in the workflow.""" - states: list[StateDefinition] + states: Optional[List[StateDefinition]] = None """A list of state definitions in the workflow.""" diff --git a/tests/integration/test_plan/test_test_plan_client.py b/tests/integration/test_plan/test_test_plan_client.py index 2189976d..e841b32b 100644 --- a/tests/integration/test_plan/test_test_plan_client.py +++ b/tests/integration/test_plan/test_test_plan_client.py @@ -4,50 +4,22 @@ import pytest from nisystemlink.clients.core._http_configuration import HttpConfiguration from nisystemlink.clients.test_plan import TestPlanClient -from nisystemlink.clients.test_plan.models._create_test_plan_request import ( +from nisystemlink.clients.test_plan.models import ( CreateTestPlanRequest, -) -from nisystemlink.clients.test_plan.models._create_test_plan_template_request import ( - CreateTestPlanTemplateRequest, -) -from nisystemlink.clients.test_plan.models._create_test_plan_templates_partial_success_response import ( + CreateTestPlansPartialSuccessResponse, CreateTestPlanTemplatePartialSuccessResponse, -) -from nisystemlink.clients.test_plan.models._create_test_plans_request import ( - CreateTestPlansRequest, -) -from nisystemlink.clients.test_plan.models._create_test_plans_response import ( - CreateTestPlansResponse, -) -from nisystemlink.clients.test_plan.models._delete_test_plans_request import ( - DeleteTestPlansRequest, -) -from nisystemlink.clients.test_plan.models._paged_test_plan_templates import ( + CreateTestPlanTemplateRequest, PagedTestPlanTemplates, -) -from nisystemlink.clients.test_plan.models._query_test_plan_templates_request import ( - QueryTestPlanTemplatesRequest, - TestPlanTemplateField, -) -from nisystemlink.clients.test_plan.models._query_test_plans_request import ( QueryTestPlansRequest, - TestPlanField, -) -from nisystemlink.clients.test_plan.models._schedule_test_plan_request import ( + QueryTestPlanTemplatesRequest, ScheduleTestPlanRequest, -) -from nisystemlink.clients.test_plan.models._schedule_test_plans_request import ( ScheduleTestPlansRequest, -) -from nisystemlink.clients.test_plan.models._state import State -from nisystemlink.clients.test_plan.models._test_plan import TestPlan -from nisystemlink.clients.test_plan.models._test_plan_templates import ( + State, + TestPlan, + TestPlanField, TestPlanTemplate, -) -from nisystemlink.clients.test_plan.models._update_test_plan_request import ( + TestPlanTemplateField, UpdateTestPlanRequest, -) -from nisystemlink.clients.test_plan.models._update_test_plans_request import ( UpdateTestPlansRequest, ) @@ -58,6 +30,34 @@ def client(enterprise_config: HttpConfiguration) -> TestPlanClient: return TestPlanClient(enterprise_config) +@pytest.fixture +def create_test_plans(client: TestPlanClient): + """Fixture to return a factory that create test plans.""" + responses: List[CreateTestPlansPartialSuccessResponse] = [] + + def _create_test_plans( + new_test_plans: List[CreateTestPlanRequest], + ) -> CreateTestPlansPartialSuccessResponse: + response = client.create_test_plans(test_plans=new_test_plans) + responses.append(response) + return response + + yield _create_test_plans + + created_test_plans: List[TestPlan] = [] + for response in responses: + if response.created_test_plans: + created_test_plans += response.created_test_plans + + client.delete_test_plans( + ids=[ + test_plans.id + for test_plans in created_test_plans + if test_plans.id is not None + ] + ) + + @pytest.fixture def create_test_plan_templates(client: TestPlanClient): """Fixture to return a factory that create test plan templates.""" @@ -93,21 +93,26 @@ def _create_test_plan_templates( @pytest.mark.enterprise class TestTestPlanClient: - _test_plan_create = CreateTestPlansRequest( - testPlans=[ - CreateTestPlanRequest( - name="Python integration test plan", state="NEW", part_number="px40482" - ) - ] - ) - """create test plan object.""" + _test_plan_create = [ + CreateTestPlanRequest( + name="Python integration test plan", state="NEW", part_number="px40482" + ) + ] + """create test plan request object.""" + + _create_test_plan_template_request = [ + CreateTestPlanTemplateRequest( + name="Python integration test plan template", + template_group="sample template group", + workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", + ) + ] + """create test plan template request object.""" def test__create_and_delete_test_plan__returns_created_and_deleted_test_plans( - self, client: TestPlanClient + self, client: TestPlanClient, create_test_plans ): - create_test_plan_response = client.create_test_plans( - create_request=self._test_plan_create - ) + create_test_plan_response = create_test_plans(self._test_plan_create) assert create_test_plan_response.created_test_plans is not None @@ -115,9 +120,6 @@ def test__create_and_delete_test_plan__returns_created_and_deleted_test_plans( get_test_plan_response: TestPlan = client.get_test_plan(created_test_plan.id) - delete_test_plan_request = DeleteTestPlansRequest(ids=[created_test_plan.id]) - client.delete_test_plans(ids=delete_test_plan_request) - assert created_test_plan is not None assert created_test_plan.name == "Python integration test plan" assert created_test_plan.state == State.NEW @@ -125,10 +127,10 @@ def test__create_and_delete_test_plan__returns_created_and_deleted_test_plans( assert get_test_plan_response is not None assert get_test_plan_response.name == "Python integration test plan" - def test__get_test_plan__returns_get_test_plan(self, client: TestPlanClient): - create_test_plan_response = client.create_test_plans( - create_request=self._test_plan_create - ) + def test__get_test_plan__returns_get_test_plan( + self, client: TestPlanClient, create_test_plans + ): + create_test_plan_response = create_test_plans(self._test_plan_create) assert create_test_plan_response.created_test_plans is not None @@ -136,19 +138,14 @@ def test__get_test_plan__returns_get_test_plan(self, client: TestPlanClient): get_test_plan_response: TestPlan = client.get_test_plan(created_test_plan.id) - delete_request = DeleteTestPlansRequest( - ids=[create_test_plan_response.created_test_plans[0].id] - ) - client.delete_test_plans(ids=delete_request) - assert get_test_plan_response is not None assert isinstance(get_test_plan_response, TestPlan) assert get_test_plan_response.id == created_test_plan.id - def test__update_test_plan__returns_updated_test_plan(self, client: TestPlanClient): - create_test_plan_response = client.create_test_plans( - create_request=self._test_plan_create - ) + def test__update_test_plan__returns_updated_test_plan( + self, client: TestPlanClient, create_test_plans + ): + create_test_plan_response = create_test_plans(self._test_plan_create) assert create_test_plan_response.created_test_plans is not None @@ -166,11 +163,6 @@ def test__update_test_plan__returns_updated_test_plan(self, client: TestPlanClie update_request=update_test_plans_request ) - delete_request = DeleteTestPlansRequest( - ids=[create_test_plan_response.created_test_plans[0].id] - ) - client.delete_test_plans(ids=delete_request) - assert update_test_plans_response.updated_test_plans is not None updated_test_plan = update_test_plans_response.updated_test_plans[0] @@ -178,11 +170,9 @@ def test__update_test_plan__returns_updated_test_plan(self, client: TestPlanClie assert updated_test_plan.name == "Updated Test Plan" def test__schedule_test_plan__returns_scheduled_test_plan( - self, client: TestPlanClient + self, client: TestPlanClient, create_test_plans ): - create_test_plan_response = client.create_test_plans( - create_request=self._test_plan_create - ) + create_test_plan_response = create_test_plans(self._test_plan_create) assert create_test_plan_response.created_test_plans is not None @@ -206,9 +196,6 @@ def test__schedule_test_plan__returns_scheduled_test_plan( schedule_request=schedule_test_plans_request ) - delete_request = DeleteTestPlansRequest(ids=[created_test_plan.id]) - client.delete_test_plans(ids=delete_request) - assert schedule_test_plans_response.scheduled_test_plans is not None scheduled_test_plan = schedule_test_plans_response.scheduled_test_plans[0] @@ -218,10 +205,10 @@ def test__schedule_test_plan__returns_scheduled_test_plan( ) assert scheduled_test_plan.system_id == "fake-system" - def test__query_test_plans__return_queried_test_plan(self, client: TestPlanClient): - create_test_plan_response: CreateTestPlansResponse = client.create_test_plans( - create_request=self._test_plan_create - ) + def test__query_test_plans__return_queried_test_plan( + self, client: TestPlanClient, create_test_plans + ): + create_test_plan_response = create_test_plans(self._test_plan_create) assert create_test_plan_response.created_test_plans is not None @@ -234,9 +221,6 @@ def test__query_test_plans__return_queried_test_plan(self, client: TestPlanClien query_request=query_test_plans_request ) - delete_request = DeleteTestPlansRequest(ids=[created_test_plan.id]) - client.delete_test_plans(ids=delete_request) - assert queried_test_plans_response is not None assert queried_test_plans_response.test_plans[0].id == created_test_plan.id assert queried_test_plans_response.total_count is not None @@ -288,15 +272,8 @@ def test__query_test_plans_with_projections__returns_the_test_plans_with_project def test__create_test_plan_template__returns_created_test_plan_template( self, client: TestPlanClient, create_test_plan_templates ): - create_test_plan_template_request: List[CreateTestPlanTemplateRequest] = [ - CreateTestPlanTemplateRequest( - name="Python integration test plan template", - template_group="sample template group", - workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", - ) - ] create_test_plan_template_response = create_test_plan_templates( - create_test_plan_template_request + self._create_test_plan_template_request ) template_id = ( @@ -309,23 +286,14 @@ def test__create_test_plan_template__returns_created_test_plan_template( assert template_id is not None assert ( create_test_plan_template_response.created_test_plan_templates[0].name - == create_test_plan_template_request[0].name + == self._create_test_plan_template_request[0].name ) def test__query_test_plan_template__returns_queried_test_plan_template( self, client: TestPlanClient, create_test_plan_templates ): - - create_test_plan_template_request: List[CreateTestPlanTemplateRequest] = [ - CreateTestPlanTemplateRequest( - name="Python integration test plan template", - template_group="sample template group", - workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", - ) - ] - create_test_plan_template_response = create_test_plan_templates( - create_test_plan_template_request + self._create_test_plan_template_request ) template_id = ( @@ -349,18 +317,10 @@ def test__query_test_plan_template__returns_queried_test_plan_template( ) def test__delete_test_plan_template(self, client: TestPlanClient): - - create_test_plan_template_request: List[CreateTestPlanTemplateRequest] = [ - CreateTestPlanTemplateRequest( - name="Python integration test plan template", - template_group="sample template group", - workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", - ) - ] create_test_plan_template_response: ( CreateTestPlanTemplatePartialSuccessResponse ) = client.create_test_plan_templates( - test_plan_templates=create_test_plan_template_request + test_plan_templates=self._create_test_plan_template_request ) template_id = ( From 42f8271ebed41d2c4b550c146e0aa2cda9267aef Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Fri, 23 May 2025 20:18:40 +0530 Subject: [PATCH 47/64] update test constant --- examples/test_plan/test_plan_templates.py | 33 +++++++++++- examples/test_plan/test_plans.py | 37 ++++++++++++- .../clients/test_plan/models/__init__.py | 9 +++- .../test_plan/models/_test_plan_templates.py | 14 +---- .../test_plan/test_test_plan_client.py | 54 ++++++++++++++++++- 5 files changed, 129 insertions(+), 18 deletions(-) diff --git a/examples/test_plan/test_plan_templates.py b/examples/test_plan/test_plan_templates.py index fe831461..596cf9a2 100644 --- a/examples/test_plan/test_plan_templates.py +++ b/examples/test_plan/test_plan_templates.py @@ -2,6 +2,10 @@ from nisystemlink.clients.test_plan import TestPlanClient from nisystemlink.clients.test_plan.models import ( CreateTestPlanTemplateRequest, + Dashboard, + Job, + JobExecution, + ManualExecution, QueryTestPlanTemplatesRequest, ) @@ -18,7 +22,34 @@ CreateTestPlanTemplateRequest( name="Python integration test plan template", template_group="sample template group", - workspace="YourWorksapceId", + product_families=["FamilyA", "FamilyB"], + part_numbers=["PN-1001", "PN-1002"], + summary="Template for running integration test plans", + description="This template defines execution steps for integration workflows.", + test_program="TP-INT-002", + estimated_duration_in_seconds=86400, + system_filter="os:linux AND arch:x64", + execution_actions=[ + ManualExecution(action="boot", type="MANUAL"), + JobExecution( + action="run", + type="JOB", + jobs=[ + Job( + functions=["run_test_suite"], + arguments=[["test_suite.py"]], + metadata={"env": "staging"}, + ) + ], + systemId="system-001", + ), + ], + file_ids=["file1", "file2"], + # workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", + properties={"env": "staging", "priority": "high"}, + dashboard=Dashboard( + id="DashBoardId", variables={"product": "PXIe-4080", "location": "Lab1"} + ), ) ] diff --git a/examples/test_plan/test_plans.py b/examples/test_plan/test_plans.py index 8f9cf2d3..a8aac37b 100644 --- a/examples/test_plan/test_plans.py +++ b/examples/test_plan/test_plans.py @@ -2,6 +2,10 @@ from nisystemlink.clients.test_plan import TestPlanClient from nisystemlink.clients.test_plan.models import ( CreateTestPlanRequest, + Dashboard, + Job, + JobExecution, + ManualExecution, QueryTestPlansRequest, ScheduleTestPlanRequest, ScheduleTestPlansRequest, @@ -18,7 +22,38 @@ create_test_plans_request = [ CreateTestPlanRequest( - name="Python integration test plan", state="NEW", partNumber="px40482" + name="Python integration test plan", + # template_id="Python Sample Id", + state="NEW", + description="Test plan for verifying integration flow", + assigned_to="test.user@example.com", + # work_order_id="Sample-Work-Order", + estimated_duration_in_seconds=86400, + properties={"env": "staging", "priority": "high"}, + part_number="px40482", + dut_id="Sample-Dut_Id", + test_program="TP-Integration-001", + system_filter="os:linux AND arch:x64", + # workspace="IntegrationWorkspace", + file_ids_from_template=["file1", "file2"], + dashboard=Dashboard( + id="DashBoardId", variables={"product": "PXIe-4080", "location": "Lab1"} + ), + execution_actions=[ + ManualExecution(action="boot", type="MANUAL"), + JobExecution( + action="run", + type="JOB", + jobs=[ + Job( + functions=["run_test_suite"], + arguments=[["test_suite.py"]], + metadata={"env": "staging"}, + ) + ], + systemId="system-001", + ), + ], ) ] diff --git a/nisystemlink/clients/test_plan/models/__init__.py b/nisystemlink/clients/test_plan/models/__init__.py index 482d25f1..4a1ef1d1 100644 --- a/nisystemlink/clients/test_plan/models/__init__.py +++ b/nisystemlink/clients/test_plan/models/__init__.py @@ -12,7 +12,14 @@ from ._order_by import OrderBy from ._test_plan import TestPlan from ._state import State -from ._execution_definition import ExecutionDefinition +from ._execution_definition import ( + ExecutionDefinition, + ManualExecution, + JobExecution, + NoneExecution, + NotebookExecution, + Job, +) from ._schedule_test_plans_request import ScheduleTestPlansRequest from ._schedule_test_plan_request import ScheduleTestPlanRequest from ._schedule_test_plans_response import ScheduleTestPlansResponse diff --git a/nisystemlink/clients/test_plan/models/_test_plan_templates.py b/nisystemlink/clients/test_plan/models/_test_plan_templates.py index b3e2edbd..5c4d8425 100644 --- a/nisystemlink/clients/test_plan/models/_test_plan_templates.py +++ b/nisystemlink/clients/test_plan/models/_test_plan_templates.py @@ -3,22 +3,10 @@ from nisystemlink.clients.core._uplink._json_model import JsonModel +from ._dashboard import Dashboard from ._execution_definition import ExecutionDefinition -class Dashboard(JsonModel): - """Contains information about a reference of a dashboard linked to test plan template.""" - - id: Optional[str] = None - """The globally unique id of the dashboard.""" - - variables: Optional[Dict[str, str]] = None - """Dictionary of variables set on the dashboard. - These will be appended to the URL as query parameters. - Each key will be prefixed with "var-" and the value will be the value of the variable. - """ - - class TestPlanTemplateBase(JsonModel): """Contains information about a test plan template.""" diff --git a/tests/integration/test_plan/test_test_plan_client.py b/tests/integration/test_plan/test_test_plan_client.py index e841b32b..c9326829 100644 --- a/tests/integration/test_plan/test_test_plan_client.py +++ b/tests/integration/test_plan/test_test_plan_client.py @@ -9,6 +9,10 @@ CreateTestPlansPartialSuccessResponse, CreateTestPlanTemplatePartialSuccessResponse, CreateTestPlanTemplateRequest, + Dashboard, + Job, + JobExecution, + ManualExecution, PagedTestPlanTemplates, QueryTestPlansRequest, QueryTestPlanTemplatesRequest, @@ -93,9 +97,44 @@ def _create_test_plan_templates( @pytest.mark.enterprise class TestTestPlanClient: + _dashboard = Dashboard( + id="DashBoardId", variables={"product": "PXIe-4080", "location": "Lab1"} + ) + + _execution_actions = [ + ManualExecution(action="boot", type="MANUAL"), + JobExecution( + action="run", + type="JOB", + jobs=[ + Job( + functions=["run_test_suite"], + arguments=[["test_suite.py"]], + metadata={"env": "staging"}, + ) + ], + systemId="system-001", + ), + ] + _test_plan_create = [ CreateTestPlanRequest( - name="Python integration test plan", state="NEW", part_number="px40482" + name="Python integration test plan", + # template_id="Python Sample Id", + state="NEW", + description="Test plan for verifying integration flow", + assigned_to="test.user@example.com", + # work_order_id="Sample-Work-Order", + estimated_duration_in_seconds=86400, + properties={"env": "staging", "priority": "high"}, + part_number="px40482", + dut_id="Sample-Dut_Id", + test_program="TP-Integration-001", + system_filter="os:linux AND arch:x64", + # workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", + file_ids_from_template=["file1", "file2"], + dashboard=_dashboard, + execution_actions=_execution_actions, ) ] """create test plan request object.""" @@ -104,7 +143,18 @@ class TestTestPlanClient: CreateTestPlanTemplateRequest( name="Python integration test plan template", template_group="sample template group", - workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", + product_families=["FamilyA", "FamilyB"], + part_numbers=["PN-1001", "PN-1002"], + summary="Template for running integration test plans", + description="This template defines execution steps for integration workflows.", + test_program="TP-INT-002", + estimated_duration_in_seconds=86400, + system_filter="os:linux AND arch:x64", + execution_actions=_execution_actions, + file_ids=["file1", "file2"], + # workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", + properties={"env": "staging", "priority": "high"}, + dashboard=_dashboard, ) ] """create test plan template request object.""" From a640febc113bd2a7fe0ed2a7eae0e21e76a3b18b Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Fri, 23 May 2025 20:27:53 +0530 Subject: [PATCH 48/64] update test constant --- nisystemlink/clients/test_plan/models/_workflow_definition.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nisystemlink/clients/test_plan/models/_workflow_definition.py b/nisystemlink/clients/test_plan/models/_workflow_definition.py index 88570230..2af17ec5 100644 --- a/nisystemlink/clients/test_plan/models/_workflow_definition.py +++ b/nisystemlink/clients/test_plan/models/_workflow_definition.py @@ -32,7 +32,7 @@ class SubstateDefinition(JsonModel): label: Optional[str] = None """The display label for the substate.""" - available_actions: Optional[list[ActionTransitionDefinition]] = None + available_actions: Optional[List[ActionTransitionDefinition]] = None """List of actions that can be performed from this substate.""" @@ -48,7 +48,7 @@ class StateDefinition(JsonModel): default_substate: Optional[str] = None """The name of the default substate for this state.""" - substates: Optional[list[SubstateDefinition]] = None + substates: Optional[List[SubstateDefinition]] = None """A list of substates defined for this state.""" From d22d4c1ce8da3d8432c4afedfbe89878fcb36df7 Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Fri, 23 May 2025 20:38:51 +0530 Subject: [PATCH 49/64] update test --- .../test_plan/test_test_plan_client.py | 49 +++++++++++++------ 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/tests/integration/test_plan/test_test_plan_client.py b/tests/integration/test_plan/test_test_plan_client.py index c9326829..7c9ed332 100644 --- a/tests/integration/test_plan/test_test_plan_client.py +++ b/tests/integration/test_plan/test_test_plan_client.py @@ -13,7 +13,6 @@ Job, JobExecution, ManualExecution, - PagedTestPlanTemplates, QueryTestPlansRequest, QueryTestPlanTemplatesRequest, ScheduleTestPlanRequest, @@ -277,15 +276,23 @@ def test__query_test_plans__return_queried_test_plan( assert queried_test_plans_response.total_count > 0 def test__query_test_plans_with_projections__returns_the_test_plans_with_projected_properties( - self, client: TestPlanClient + self, client: TestPlanClient, create_test_plans ): + create_test_plan_response = create_test_plans(self._test_plan_create) + + assert create_test_plan_response.created_test_plans is not None + + created_test_plan = create_test_plan_response.created_test_plans[0] query_test_plans_request = QueryTestPlansRequest( - projection=[TestPlanField.ID, TestPlanField.NAME] + filter=f'id = "{created_test_plan.id}"', + projection=[TestPlanField.ID, TestPlanField.NAME], + take=1, ) response = client.query_test_plans(query_request=query_test_plans_request) assert response is not None - assert all( + test_plan = response.test_plans[0] + assert ( test_plan.id is not None and test_plan.name is not None and test_plan.template_id is None @@ -316,7 +323,6 @@ def test__query_test_plans_with_projections__returns_the_test_plans_with_project and test_plan.dashboard_url is None and test_plan.dashboard is None and test_plan.workflow is None - for test_plan in response.test_plans ) def test__create_test_plan_template__returns_created_test_plan_template( @@ -357,8 +363,8 @@ def test__query_test_plan_template__returns_queried_test_plan_template( query = QueryTestPlanTemplatesRequest(filter=f'id="{template_id}"', take=1) - query_test_plan_template_response: PagedTestPlanTemplates = ( - client.query_test_plan_templates(query_test_plan_templates=query) + query_test_plan_template_response = client.query_test_plan_templates( + query_test_plan_templates=query ) assert len(query_test_plan_template_response.test_plan_templates) == 1, query @@ -384,27 +390,41 @@ def test__delete_test_plan_template(self, client: TestPlanClient): client.delete_test_plan_templates(ids=[template_id]) - query_deleted_test_plan_template_response: PagedTestPlanTemplates = ( - client.query_test_plan_templates( - query_test_plan_templates=QueryTestPlanTemplatesRequest( - filter=f'id="{template_id}"', take=1 - ) + query_deleted_test_plan_template_response = client.query_test_plan_templates( + query_test_plan_templates=QueryTestPlanTemplatesRequest( + filter=f'id="{template_id}"', take=1 ) ) assert len(query_deleted_test_plan_template_response.test_plan_templates) == 0 def test_query_test_plan_templates_with_projections__returns_test_plan_templates_with_projected_properties( - self, client: TestPlanClient + self, client: TestPlanClient, create_test_plan_templates ): + create_test_plan_template_response = create_test_plan_templates( + self._create_test_plan_template_request + ) + + template_id = ( + create_test_plan_template_response.created_test_plan_templates[0].id + if create_test_plan_template_response.created_test_plan_templates + and create_test_plan_template_response.created_test_plan_templates[0].id + else None + ) + + assert template_id is not None + query = QueryTestPlanTemplatesRequest( + filter=f'id="{template_id}"', projection=[TestPlanTemplateField.ID, TestPlanTemplateField.NAME], + take=1, ) print(query) response = client.query_test_plan_templates(query_test_plan_templates=query) assert response is not None - assert all( + test_plan_template = response.test_plan_templates[0] + assert ( test_plan_template.id is not None and test_plan_template.name is not None and test_plan_template.template_group is None @@ -420,5 +440,4 @@ def test_query_test_plan_templates_with_projections__returns_test_plan_templates and test_plan_template.workspace is None and test_plan_template.properties is None and test_plan_template.dashboard is None - for test_plan_template in response.test_plan_templates ) From 09768cfef5647965787ef6a241230aa0e7ebd6e6 Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Fri, 23 May 2025 21:49:43 +0530 Subject: [PATCH 50/64] update constant --- examples/test_plan/test_plan_templates.py | 2 +- examples/test_plan/test_plans.py | 4 +-- .../test_plan/test_test_plan_client.py | 27 ++++++++++++++++--- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/examples/test_plan/test_plan_templates.py b/examples/test_plan/test_plan_templates.py index 596cf9a2..eab2c44e 100644 --- a/examples/test_plan/test_plan_templates.py +++ b/examples/test_plan/test_plan_templates.py @@ -45,7 +45,7 @@ ), ], file_ids=["file1", "file2"], - # workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", + workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", properties={"env": "staging", "priority": "high"}, dashboard=Dashboard( id="DashBoardId", variables={"product": "PXIe-4080", "location": "Lab1"} diff --git a/examples/test_plan/test_plans.py b/examples/test_plan/test_plans.py index a8aac37b..69e66ee8 100644 --- a/examples/test_plan/test_plans.py +++ b/examples/test_plan/test_plans.py @@ -23,18 +23,16 @@ create_test_plans_request = [ CreateTestPlanRequest( name="Python integration test plan", - # template_id="Python Sample Id", state="NEW", description="Test plan for verifying integration flow", assigned_to="test.user@example.com", - # work_order_id="Sample-Work-Order", estimated_duration_in_seconds=86400, properties={"env": "staging", "priority": "high"}, part_number="px40482", dut_id="Sample-Dut_Id", test_program="TP-Integration-001", system_filter="os:linux AND arch:x64", - # workspace="IntegrationWorkspace", + workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", file_ids_from_template=["file1", "file2"], dashboard=Dashboard( id="DashBoardId", variables={"product": "PXIe-4080", "location": "Lab1"} diff --git a/tests/integration/test_plan/test_test_plan_client.py b/tests/integration/test_plan/test_test_plan_client.py index 7c9ed332..c6b517f9 100644 --- a/tests/integration/test_plan/test_test_plan_client.py +++ b/tests/integration/test_plan/test_test_plan_client.py @@ -96,6 +96,8 @@ def _create_test_plan_templates( @pytest.mark.enterprise class TestTestPlanClient: + _workspace = "33eba2fe-fe42-48a1-a47f-a6669479a8aa" + _dashboard = Dashboard( id="DashBoardId", variables={"product": "PXIe-4080", "location": "Lab1"} ) @@ -123,14 +125,13 @@ class TestTestPlanClient: state="NEW", description="Test plan for verifying integration flow", assigned_to="test.user@example.com", - # work_order_id="Sample-Work-Order", estimated_duration_in_seconds=86400, properties={"env": "staging", "priority": "high"}, part_number="px40482", dut_id="Sample-Dut_Id", test_program="TP-Integration-001", system_filter="os:linux AND arch:x64", - # workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", + workspace=_workspace, file_ids_from_template=["file1", "file2"], dashboard=_dashboard, execution_actions=_execution_actions, @@ -151,7 +152,7 @@ class TestTestPlanClient: system_filter="os:linux AND arch:x64", execution_actions=_execution_actions, file_ids=["file1", "file2"], - # workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", + workspace=_workspace, properties={"env": "staging", "priority": "high"}, dashboard=_dashboard, ) @@ -161,7 +162,23 @@ class TestTestPlanClient: def test__create_and_delete_test_plan__returns_created_and_deleted_test_plans( self, client: TestPlanClient, create_test_plans ): - create_test_plan_response = create_test_plans(self._test_plan_create) + create_test_plan_template_response = client.create_test_plan_templates( + test_plan_templates=self._create_test_plan_template_request + ) + + template_id = ( + create_test_plan_template_response.created_test_plan_templates[0].id + if create_test_plan_template_response.created_test_plan_templates + and create_test_plan_template_response.created_test_plan_templates[0].id + else None + ) + + assert template_id is not None + + test_plan_request = self._test_plan_create + test_plan_request[0].template_id = template_id + + create_test_plan_response = create_test_plans(test_plan_request) assert create_test_plan_response.created_test_plans is not None @@ -169,6 +186,8 @@ def test__create_and_delete_test_plan__returns_created_and_deleted_test_plans( get_test_plan_response: TestPlan = client.get_test_plan(created_test_plan.id) + client.delete_test_plan_templates(ids=[template_id]) + assert created_test_plan is not None assert created_test_plan.name == "Python integration test plan" assert created_test_plan.state == State.NEW From ce85d2af1e8051f220142e333621e6e0c3c7c7dc Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Fri, 23 May 2025 22:06:12 +0530 Subject: [PATCH 51/64] refactor --- docs/getting_started.rst | 1 + examples/test_plan/test_plans.py | 10 ++++++++-- nisystemlink/clients/test_plan/__init__.py | 2 +- tests/integration/test_plan/__init__.py | 1 + 4 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 tests/integration/test_plan/__init__.py diff --git a/docs/getting_started.rst b/docs/getting_started.rst index d2e6f530..042ae88f 100644 --- a/docs/getting_started.rst +++ b/docs/getting_started.rst @@ -337,6 +337,7 @@ default connection. The default connection depends on your environment. With a :class:`.TestPlanClient` object, you can: * Create, query, get, update, schedule and delete TestPlans +* Create, query and delete test plan templates Examples ~~~~~~~~ diff --git a/examples/test_plan/test_plans.py b/examples/test_plan/test_plans.py index 69e66ee8..c0d453e7 100644 --- a/examples/test_plan/test_plans.py +++ b/examples/test_plan/test_plans.py @@ -1,3 +1,5 @@ +from datetime import datetime + from nisystemlink.clients.core._http_configuration import HttpConfiguration from nisystemlink.clients.test_plan import TestPlanClient from nisystemlink.clients.test_plan.models import ( @@ -91,8 +93,12 @@ test_plans=[ ScheduleTestPlanRequest( id=created_test_plan_id, - planned_start_date_time="2025-05-20T15:07:42.527Z", - estimated_end_date_time="2025-05-20T15:07:42.527Z", + planned_start_date_time=datetime.strptime( + "2025-05-20T15:07:42.527Z", "%Y-%m-%dT%H:%M:%S.%fZ" + ), + estimated_end_date_time=datetime.strptime( + "2025-05-22T15:07:42.527Z", "%Y-%m-%dT%H:%M:%S.%fZ" + ), system_id="fake-system", ) ] diff --git a/nisystemlink/clients/test_plan/__init__.py b/nisystemlink/clients/test_plan/__init__.py index ca953629..013b65cb 100644 --- a/nisystemlink/clients/test_plan/__init__.py +++ b/nisystemlink/clients/test_plan/__init__.py @@ -1,3 +1,3 @@ -from nisystemlink.clients.test_plan._test_plan_client import TestPlanClient +from ._test_plan_client import TestPlanClient # flake8: noqa diff --git a/tests/integration/test_plan/__init__.py b/tests/integration/test_plan/__init__.py new file mode 100644 index 00000000..9c0fa90a --- /dev/null +++ b/tests/integration/test_plan/__init__.py @@ -0,0 +1 @@ +# flake8: noqa From 8969220562498390ae5636a76e57cf504c8459f7 Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Fri, 23 May 2025 22:17:54 +0530 Subject: [PATCH 52/64] update docs --- docs/api_reference/test_plan.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api_reference/test_plan.rst b/docs/api_reference/test_plan.rst index 43881177..7e3f5669 100644 --- a/docs/api_reference/test_plan.rst +++ b/docs/api_reference/test_plan.rst @@ -3,7 +3,7 @@ nisystemlink.clients.test_plan ====================== -.. autoclass:: nisystemlink.clients.test_plan.test_plan.TestPlanClient +.. autoclass:: nisystemlink.clients.test_plan.TestPlanClient :exclude-members: __init__ .. automethod:: __init__ From 1bff3b4cf112b4c42f91022321bd5395cd564279 Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Fri, 23 May 2025 22:47:21 +0530 Subject: [PATCH 53/64] fix warnings --- examples/test_plan/test_plans.py | 5 +---- nisystemlink/clients/test_plan/_test_plan_client.py | 2 ++ .../test_plan/models/_query_test_plan_templates_request.py | 4 ++++ .../clients/test_plan/models/_query_test_plans_request.py | 2 ++ nisystemlink/clients/test_plan/models/_test_plan.py | 2 ++ .../clients/test_plan/models/_test_plan_templates.py | 2 ++ 6 files changed, 13 insertions(+), 4 deletions(-) diff --git a/examples/test_plan/test_plans.py b/examples/test_plan/test_plans.py index c0d453e7..a871364e 100644 --- a/examples/test_plan/test_plans.py +++ b/examples/test_plan/test_plans.py @@ -67,10 +67,7 @@ # Query test plan using id. query_test_plans_request = QueryTestPlansRequest( - skip=0, - take=1, - descending=False, - returnCount=False, + skip=0, take=1, descending=False, returnCount=False ) client.query_test_plans(query_request=query_test_plans_request) diff --git a/nisystemlink/clients/test_plan/_test_plan_client.py b/nisystemlink/clients/test_plan/_test_plan_client.py index f24a8520..248e7940 100644 --- a/nisystemlink/clients/test_plan/_test_plan_client.py +++ b/nisystemlink/clients/test_plan/_test_plan_client.py @@ -14,6 +14,8 @@ on_exception=retry.CONNECTION_ERROR, ) class TestPlanClient(BaseClient): + __test__ = False + def __init__(self, configuration: Optional[HttpConfiguration] = None): """Initialize an instance. diff --git a/nisystemlink/clients/test_plan/models/_query_test_plan_templates_request.py b/nisystemlink/clients/test_plan/models/_query_test_plan_templates_request.py index 25fca6b0..7ad558d8 100644 --- a/nisystemlink/clients/test_plan/models/_query_test_plan_templates_request.py +++ b/nisystemlink/clients/test_plan/models/_query_test_plan_templates_request.py @@ -15,6 +15,10 @@ class TestPlanTemplateOrderBy(str, Enum): class TestPlanTemplateField(str, Enum): + """Model for an object describing an test plan template with all of its properties.""" + + __test__ = False + ID = "ID" NAME = "NAME" TEMPLATE_GROUP = "TEMPLATE_GROUP" diff --git a/nisystemlink/clients/test_plan/models/_query_test_plans_request.py b/nisystemlink/clients/test_plan/models/_query_test_plans_request.py index 61c30327..91d44423 100644 --- a/nisystemlink/clients/test_plan/models/_query_test_plans_request.py +++ b/nisystemlink/clients/test_plan/models/_query_test_plans_request.py @@ -9,6 +9,8 @@ class TestPlanField(enum.Enum): """Model for an object describing an test plan with all of its properties.""" + __test__ = False + ID = "ID" TEMPLATE_ID = "TEMPLATE_ID" NAME = "NAME" diff --git a/nisystemlink/clients/test_plan/models/_test_plan.py b/nisystemlink/clients/test_plan/models/_test_plan.py index d0d2979a..812c6098 100644 --- a/nisystemlink/clients/test_plan/models/_test_plan.py +++ b/nisystemlink/clients/test_plan/models/_test_plan.py @@ -13,6 +13,8 @@ class TestPlan(JsonModel): """Contains information about a test plan.""" + __test__ = False + id: str """The unique identifier of the test plan.""" diff --git a/nisystemlink/clients/test_plan/models/_test_plan_templates.py b/nisystemlink/clients/test_plan/models/_test_plan_templates.py index 5c4d8425..cbd37396 100644 --- a/nisystemlink/clients/test_plan/models/_test_plan_templates.py +++ b/nisystemlink/clients/test_plan/models/_test_plan_templates.py @@ -62,6 +62,8 @@ class TestPlanTemplateBase(JsonModel): class TestPlanTemplate(TestPlanTemplateBase): """Contains response information for test plan template.""" + __test__ = False + id: Optional[str] = None """The globally unique id of the test plan template.""" From 69158306522ab85eab7dc37b4819b01c07f6b567 Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Fri, 23 May 2025 22:53:09 +0530 Subject: [PATCH 54/64] try example fail fix --- examples/test_plan/test_plan_templates.py | 2 +- examples/test_plan/test_plans.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/test_plan/test_plan_templates.py b/examples/test_plan/test_plan_templates.py index eab2c44e..3af5fdaf 100644 --- a/examples/test_plan/test_plan_templates.py +++ b/examples/test_plan/test_plan_templates.py @@ -45,7 +45,7 @@ ), ], file_ids=["file1", "file2"], - workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", + workspace="your_workspace_id", properties={"env": "staging", "priority": "high"}, dashboard=Dashboard( id="DashBoardId", variables={"product": "PXIe-4080", "location": "Lab1"} diff --git a/examples/test_plan/test_plans.py b/examples/test_plan/test_plans.py index a871364e..c4ca165b 100644 --- a/examples/test_plan/test_plans.py +++ b/examples/test_plan/test_plans.py @@ -34,7 +34,7 @@ dut_id="Sample-Dut_Id", test_program="TP-Integration-001", system_filter="os:linux AND arch:x64", - workspace="33eba2fe-fe42-48a1-a47f-a6669479a8aa", + workspace="your_workspace_id", file_ids_from_template=["file1", "file2"], dashboard=Dashboard( id="DashBoardId", variables={"product": "PXIe-4080", "location": "Lab1"} From 5d080f47e6a5a1158d9fbf50f7c36056908590b5 Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Fri, 23 May 2025 23:06:51 +0530 Subject: [PATCH 55/64] lint --- tests/integration/test_plan/test_test_plan_client.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/integration/test_plan/test_test_plan_client.py b/tests/integration/test_plan/test_test_plan_client.py index c6b517f9..0989635e 100644 --- a/tests/integration/test_plan/test_test_plan_client.py +++ b/tests/integration/test_plan/test_test_plan_client.py @@ -121,7 +121,6 @@ class TestTestPlanClient: _test_plan_create = [ CreateTestPlanRequest( name="Python integration test plan", - # template_id="Python Sample Id", state="NEW", description="Test plan for verifying integration flow", assigned_to="test.user@example.com", From f2aa65144d0c54cd98ed2ff9491e6624d41ff5b4 Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Fri, 23 May 2025 23:22:26 +0530 Subject: [PATCH 56/64] update execution actions --- .../test_plan/models/_execution_definition.py | 22 +++++++++++++++++++ .../test_plan/test_test_plan_client.py | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/nisystemlink/clients/test_plan/models/_execution_definition.py b/nisystemlink/clients/test_plan/models/_execution_definition.py index 6257ab3d..5e901538 100644 --- a/nisystemlink/clients/test_plan/models/_execution_definition.py +++ b/nisystemlink/clients/test_plan/models/_execution_definition.py @@ -69,12 +69,34 @@ class NoneExecution(JsonModel): """Type of execution, default is 'NONE'.""" +class ScheduleExecution(JsonModel): + """Represents a scheduled execution definition.""" + + action: str + """User defined action to perform in workflow (user defined).""" + + type: Literal["SCHEDULE"] = Field(default="SCHEDULE") + """Type of execution, default is 'SCHEDULE'.""" + + +class UnscheduleExecution(JsonModel): + """Represents an unscheduled execution definition.""" + + action: str + """User defined action to perform in workflow (user defined).""" + + type: Literal["UNSCHEDULE"] = Field(default="UNSCHEDULE") + """Type of execution, default is 'UNSCHEDULE'.""" + + ExecutionDefinition = Annotated[ Union[ NotebookExecution, ManualExecution, JobExecution, NoneExecution, + ScheduleExecution, + UnscheduleExecution, ], Field(discriminator="type"), ] diff --git a/tests/integration/test_plan/test_test_plan_client.py b/tests/integration/test_plan/test_test_plan_client.py index 0989635e..001f34c8 100644 --- a/tests/integration/test_plan/test_test_plan_client.py +++ b/tests/integration/test_plan/test_test_plan_client.py @@ -96,7 +96,7 @@ def _create_test_plan_templates( @pytest.mark.enterprise class TestTestPlanClient: - _workspace = "33eba2fe-fe42-48a1-a47f-a6669479a8aa" + _workspace = "2300760d-38c4-48a1-9acb-800260812337" _dashboard = Dashboard( id="DashBoardId", variables={"product": "PXIe-4080", "location": "Lab1"} From 0fd415bc62ea66959f091349108846dd34bbaf64 Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Sat, 24 May 2025 11:17:04 +0530 Subject: [PATCH 57/64] update run test py setup --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index ac60d35e..66301a64 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -64,6 +64,7 @@ types = "mypy --config-file mypy.ini nisystemlink examples tests" [tool.pytest.ini_options] addopts = "--strict-markers" +testpaths = ["tests"] markers = [ "unit: mark a test as a unit test", "integration: mark a test as an integration test", From cd55dd3836841d1abf6bd21dc45e50ade6ba9f95 Mon Sep 17 00:00:00 2001 From: aravindhan-ni <175607614+aravindhan-ni@users.noreply.github.com> Date: Sat, 24 May 2025 11:19:56 +0530 Subject: [PATCH 58/64] Update tests test name Co-authored-by: Richard Bell <418101+rbell517@users.noreply.github.com> --- tests/integration/test_plan/test_test_plan_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/test_plan/test_test_plan_client.py b/tests/integration/test_plan/test_test_plan_client.py index 001f34c8..98cb0c9e 100644 --- a/tests/integration/test_plan/test_test_plan_client.py +++ b/tests/integration/test_plan/test_test_plan_client.py @@ -416,7 +416,7 @@ def test__delete_test_plan_template(self, client: TestPlanClient): assert len(query_deleted_test_plan_template_response.test_plan_templates) == 0 - def test_query_test_plan_templates_with_projections__returns_test_plan_templates_with_projected_properties( + def test__query_test_plan_templates_with_projections__returns_test_plan_templates_with_projected_properties( self, client: TestPlanClient, create_test_plan_templates ): create_test_plan_template_response = create_test_plan_templates( From 142dfd49a6fb5279e9d29d4db34f73ce1327d15b Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Mon, 26 May 2025 12:28:55 +0530 Subject: [PATCH 59/64] lint and update exports --- .../clients/test_plan/models/__init__.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/nisystemlink/clients/test_plan/models/__init__.py b/nisystemlink/clients/test_plan/models/__init__.py index 4a1ef1d1..198de273 100644 --- a/nisystemlink/clients/test_plan/models/__init__.py +++ b/nisystemlink/clients/test_plan/models/__init__.py @@ -8,7 +8,12 @@ from ._update_test_plans_response import UpdateTestPlansResponse from ._query_test_plans_request import QueryTestPlansRequest, TestPlanField from ._paged_test_plans import PagedTestPlans -from ._execution_event import ExecutionEvent +from ._execution_event import ( + ExecutionEvent, + NotebookExecutionEvent, + JobExecutionEvent, + ManualExecutionEvent, +) from ._order_by import OrderBy from ._test_plan import TestPlan from ._state import State @@ -19,11 +24,19 @@ NoneExecution, NotebookExecution, Job, + ScheduleExecution, + UnscheduleExecution, ) from ._schedule_test_plans_request import ScheduleTestPlansRequest from ._schedule_test_plan_request import ScheduleTestPlanRequest from ._schedule_test_plans_response import ScheduleTestPlansResponse -from ._workflow_definition import WorkflowDefinition +from ._workflow_definition import ( + WorkflowDefinition, + ActionDefinition, + ActionTransitionDefinition, + StateDefinition, + SubstateDefinition, +) from ._test_plan_templates import TestPlanTemplateBase, TestPlanTemplate from ._create_test_plan_templates_partial_success_response import ( @@ -35,6 +48,7 @@ from ._query_test_plan_templates_request import ( QueryTestPlanTemplatesRequest, TestPlanTemplateField, + TestPlanTemplateOrderBy, ) from ._paged_test_plan_templates import PagedTestPlanTemplates from ._create_test_plan_template_request import CreateTestPlanTemplateRequest From f34f0fbaf5f559257d1c95648686d3e8aa8a0f08 Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Mon, 26 May 2025 17:13:35 +0530 Subject: [PATCH 60/64] refactor --- .../clients/test_plan/models/__init__.py | 2 -- .../test_plan/models/_execution_definition.py | 22 ------------------- 2 files changed, 24 deletions(-) diff --git a/nisystemlink/clients/test_plan/models/__init__.py b/nisystemlink/clients/test_plan/models/__init__.py index 198de273..02241526 100644 --- a/nisystemlink/clients/test_plan/models/__init__.py +++ b/nisystemlink/clients/test_plan/models/__init__.py @@ -24,8 +24,6 @@ NoneExecution, NotebookExecution, Job, - ScheduleExecution, - UnscheduleExecution, ) from ._schedule_test_plans_request import ScheduleTestPlansRequest from ._schedule_test_plan_request import ScheduleTestPlanRequest diff --git a/nisystemlink/clients/test_plan/models/_execution_definition.py b/nisystemlink/clients/test_plan/models/_execution_definition.py index 5e901538..6257ab3d 100644 --- a/nisystemlink/clients/test_plan/models/_execution_definition.py +++ b/nisystemlink/clients/test_plan/models/_execution_definition.py @@ -69,34 +69,12 @@ class NoneExecution(JsonModel): """Type of execution, default is 'NONE'.""" -class ScheduleExecution(JsonModel): - """Represents a scheduled execution definition.""" - - action: str - """User defined action to perform in workflow (user defined).""" - - type: Literal["SCHEDULE"] = Field(default="SCHEDULE") - """Type of execution, default is 'SCHEDULE'.""" - - -class UnscheduleExecution(JsonModel): - """Represents an unscheduled execution definition.""" - - action: str - """User defined action to perform in workflow (user defined).""" - - type: Literal["UNSCHEDULE"] = Field(default="UNSCHEDULE") - """Type of execution, default is 'UNSCHEDULE'.""" - - ExecutionDefinition = Annotated[ Union[ NotebookExecution, ManualExecution, JobExecution, NoneExecution, - ScheduleExecution, - UnscheduleExecution, ], Field(discriminator="type"), ] From 6431f9a8e45eec421e161c12bcd15af3791dac2f Mon Sep 17 00:00:00 2001 From: aravindhan-ni <175607614+aravindhan-ni@users.noreply.github.com> Date: Mon, 26 May 2025 20:31:30 +0530 Subject: [PATCH 61/64] Create main.yml --- .github/workflows/main.yml | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..c7848788 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,48 @@ +name: Python package + +on: + push: + branches: [master, main] + pull_request: + branches: [master, main] + +jobs: + build-lint-unit-test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] + steps: + - uses: actions/checkout@v4 + - name: Install poetry + run: pipx install poetry + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: "poetry" + - run: poetry install + - run: poetry run poe test + - run: poetry run poe check + - run: poetry run poe lint + - run: poetry run poe types + integration-test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] + # Do not run in parallel to limit parallel integration tests stomping on each other + max-parallel: 1 + steps: + - uses: actions/checkout@v4 + - name: Install poetry + run: pipx install poetry + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: "poetry" + - run: poetry install + - run: > + poetry run pytest + -m integration + --cloud-api-key "${{ secrets.CLOUD_API_KEY }}" + --enterprise-uri "https://test-api.lifecyclesolutions.ni.com" --enterprise-api-key "${{ secrets.ENTERPRISE_API_KEY }}" From ef4704f1b5795c70095f538af99b929610587b66 Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Tue, 27 May 2025 12:06:28 +0530 Subject: [PATCH 62/64] remove workflow --- .../clients/test_plan/models/__init__.py | 7 -- .../clients/test_plan/models/_test_plan.py | 4 - .../test_plan/models/_workflow_definition.py | 75 ------------------- .../test_plan/test_test_plan_client.py | 1 - 4 files changed, 87 deletions(-) delete mode 100644 nisystemlink/clients/test_plan/models/_workflow_definition.py diff --git a/nisystemlink/clients/test_plan/models/__init__.py b/nisystemlink/clients/test_plan/models/__init__.py index 02241526..1f7b7707 100644 --- a/nisystemlink/clients/test_plan/models/__init__.py +++ b/nisystemlink/clients/test_plan/models/__init__.py @@ -28,13 +28,6 @@ from ._schedule_test_plans_request import ScheduleTestPlansRequest from ._schedule_test_plan_request import ScheduleTestPlanRequest from ._schedule_test_plans_response import ScheduleTestPlansResponse -from ._workflow_definition import ( - WorkflowDefinition, - ActionDefinition, - ActionTransitionDefinition, - StateDefinition, - SubstateDefinition, -) from ._test_plan_templates import TestPlanTemplateBase, TestPlanTemplate from ._create_test_plan_templates_partial_success_response import ( diff --git a/nisystemlink/clients/test_plan/models/_test_plan.py b/nisystemlink/clients/test_plan/models/_test_plan.py index 812c6098..23c9af3b 100644 --- a/nisystemlink/clients/test_plan/models/_test_plan.py +++ b/nisystemlink/clients/test_plan/models/_test_plan.py @@ -7,7 +7,6 @@ from ._execution_definition import ExecutionDefinition from ._execution_event import ExecutionEvent from ._state import State -from ._workflow_definition import WorkflowDefinition class TestPlan(JsonModel): @@ -101,6 +100,3 @@ class TestPlan(JsonModel): dashboard: Optional[DashboardUrl] = None """The dashboard data related to the test plan.""" - - workflow: Optional[WorkflowDefinition] = None - """The workflow definition associated with the test plan.""" diff --git a/nisystemlink/clients/test_plan/models/_workflow_definition.py b/nisystemlink/clients/test_plan/models/_workflow_definition.py deleted file mode 100644 index 2af17ec5..00000000 --- a/nisystemlink/clients/test_plan/models/_workflow_definition.py +++ /dev/null @@ -1,75 +0,0 @@ -from typing import List, Optional - -from nisystemlink.clients.core._uplink._json_model import JsonModel -from pydantic import Field - -from ._execution_definition import ExecutionDefinition -from ._state import State - - -class ActionTransitionDefinition(JsonModel): - """Represents a transition between workflow states triggered by a specific action.""" - - action: str - """The name of the action that triggers the transition.""" - - next_state: State - """The state to transition to after the action is performed.""" - - next_substate: str - """The substate to transition to within the next state.""" - - show_in_UI: bool = Field(alias="showInUI") - """Indicates whether this transition should be visible in the user interface.""" - - -class SubstateDefinition(JsonModel): - """Represents a substate within a workflow definition.""" - - id: Optional[str] = None - """The unique identifier for the substate.""" - - label: Optional[str] = None - """The display label for the substate.""" - - available_actions: Optional[List[ActionTransitionDefinition]] = None - """List of actions that can be performed from this substate.""" - - -class StateDefinition(JsonModel): - """Represents the definition of a workflow state within a test plan.""" - - state: Optional[State] = None - """The state associated with this definition.""" - - dashboard_available: Optional[bool] = None - """Indicates if the state is available on the dashboard.""" - - default_substate: Optional[str] = None - """The name of the default substate for this state.""" - - substates: Optional[List[SubstateDefinition]] = None - """A list of substates defined for this state.""" - - -class ActionDefinition(JsonModel): - """Represents the definition of an action within a workflow.""" - - id: Optional[str] = None - """The unique identifier for the action.""" - - label: Optional[str] = None - """The display label for the action.""" - - execution_action: Optional[ExecutionDefinition] = None - """The execution details associated with the action.""" - - -class WorkflowDefinition(JsonModel): - """Contains information about a workflow definition.""" - - actions: Optional[List[ActionDefinition]] = None - """A list of action definitions in the workflow.""" - - states: Optional[List[StateDefinition]] = None - """A list of state definitions in the workflow.""" diff --git a/tests/integration/test_plan/test_test_plan_client.py b/tests/integration/test_plan/test_test_plan_client.py index 98cb0c9e..2744fcbb 100644 --- a/tests/integration/test_plan/test_test_plan_client.py +++ b/tests/integration/test_plan/test_test_plan_client.py @@ -340,7 +340,6 @@ def test__query_test_plans_with_projections__returns_the_test_plans_with_project and test_plan.execution_history is None and test_plan.dashboard_url is None and test_plan.dashboard is None - and test_plan.workflow is None ) def test__create_test_plan_template__returns_created_test_plan_template( From 0f2db441565bac241fb5023b5247efc9bcafb9b9 Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Tue, 27 May 2025 21:11:34 +0530 Subject: [PATCH 63/64] refactor --- .github/workflows/main.yml | 48 -------------------------------------- 1 file changed, 48 deletions(-) delete mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index c7848788..00000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Python package - -on: - push: - branches: [master, main] - pull_request: - branches: [master, main] - -jobs: - build-lint-unit-test: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] - steps: - - uses: actions/checkout@v4 - - name: Install poetry - run: pipx install poetry - - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - cache: "poetry" - - run: poetry install - - run: poetry run poe test - - run: poetry run poe check - - run: poetry run poe lint - - run: poetry run poe types - integration-test: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] - # Do not run in parallel to limit parallel integration tests stomping on each other - max-parallel: 1 - steps: - - uses: actions/checkout@v4 - - name: Install poetry - run: pipx install poetry - - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - cache: "poetry" - - run: poetry install - - run: > - poetry run pytest - -m integration - --cloud-api-key "${{ secrets.CLOUD_API_KEY }}" - --enterprise-uri "https://test-api.lifecyclesolutions.ni.com" --enterprise-api-key "${{ secrets.ENTERPRISE_API_KEY }}" From 732af5f754c0c5fe1dc27f82049ee15b89c84025 Mon Sep 17 00:00:00 2001 From: Aravindhan Palanisamy Date: Wed, 28 May 2025 12:49:57 +0530 Subject: [PATCH 64/64] add comment to usage of workspace --- tests/integration/assetmanagement/test_asset_management.py | 5 ++++- tests/integration/systems/test_systems.py | 3 ++- tests/integration/test_plan/test_test_plan_client.py | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/integration/assetmanagement/test_asset_management.py b/tests/integration/assetmanagement/test_asset_management.py index 6a5acebe..592fe3fb 100644 --- a/tests/integration/assetmanagement/test_asset_management.py +++ b/tests/integration/assetmanagement/test_asset_management.py @@ -54,6 +54,9 @@ def client(enterprise_config: HttpConfiguration) -> AssetManagementClient: @pytest.mark.integration @pytest.mark.enterprise class TestAssetManagement: + _workspace = "2300760d-38c4-48a1-9acb-800260812337" + """Used the main-test default workspace since the client + for creating a workspace has not been added yet""" _create_assets_request = [ CreateAssetRequest( @@ -77,7 +80,7 @@ class TestAssetManagement: date="2022-06-07T18:58:05.000Z", ), is_NI_asset=True, - workspace="2300760d-38c4-48a1-9acb-800260812337", + workspace=_workspace, location=AssetLocationForCreate( state=AssetPresence(asset_presence=AssetPresenceStatus.PRESENT) ), diff --git a/tests/integration/systems/test_systems.py b/tests/integration/systems/test_systems.py index 937439ac..426d0ef6 100644 --- a/tests/integration/systems/test_systems.py +++ b/tests/integration/systems/test_systems.py @@ -27,7 +27,8 @@ def client(enterprise_config: HttpConfiguration) -> SystemsClient: workspace_id = "2300760d-38c4-48a1-9acb-800260812337" -"""Constant represent id of the workspace.""" +"""Used the main-test default workspace since the client +for creating a workspace has not been added yet""" @pytest.fixture diff --git a/tests/integration/test_plan/test_test_plan_client.py b/tests/integration/test_plan/test_test_plan_client.py index 2744fcbb..3b90466b 100644 --- a/tests/integration/test_plan/test_test_plan_client.py +++ b/tests/integration/test_plan/test_test_plan_client.py @@ -97,6 +97,8 @@ def _create_test_plan_templates( class TestTestPlanClient: _workspace = "2300760d-38c4-48a1-9acb-800260812337" + """Used the main-test default workspace since the client + for creating a workspace has not been added yet""" _dashboard = Dashboard( id="DashBoardId", variables={"product": "PXIe-4080", "location": "Lab1"}