-
Notifications
You must be signed in to change notification settings - Fork 0
MPT-20326: Added endpoints and e2e tests for program parameter groups #307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
robcsegal
merged 1 commit into
main
from
MPT-20326-add-endpoints-and-e-2-e-tests-for-program-parameter-groups
Apr 17, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
mpt_api_client/resources/program/programs_parameter_groups.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| from mpt_api_client.http import AsyncService, Service | ||
| from mpt_api_client.http.mixins import ( | ||
| AsyncCollectionMixin, | ||
| AsyncManagedResourceMixin, | ||
| CollectionMixin, | ||
| ManagedResourceMixin, | ||
| ) | ||
| from mpt_api_client.models import Model | ||
| from mpt_api_client.models.model import BaseModel | ||
|
|
||
|
|
||
| class ParameterGroup(Model): | ||
| """Parameter Group resource. | ||
|
|
||
| Attributes: | ||
| name: Parameter group name. | ||
| label: Display label for the parameter group. | ||
| description: Parameter group description. | ||
| display_order: Display order of the group. | ||
| default: Whether this is the default parameter group. | ||
| parameter_count: Number of parameters in this group. | ||
| program: Reference to the program this group belongs to. | ||
| audit: Audit information (created, updated events). | ||
| """ | ||
|
|
||
| name: str | None | ||
| label: str | None | ||
| description: str | None | ||
| display_order: int | None | ||
| default: bool | None | ||
| parameter_count: int | None | ||
| program: BaseModel | None | ||
| audit: BaseModel | None | ||
|
|
||
|
|
||
| class ParameterGroupsServiceConfig: | ||
| """Parameter Groups service configuration.""" | ||
|
|
||
| _endpoint = "/public/v1/program/programs/{program_id}/parameter-groups" | ||
| _model_class = ParameterGroup | ||
| _collection_key = "data" | ||
|
|
||
|
|
||
| class ParameterGroupsService( | ||
| ManagedResourceMixin[ParameterGroup], | ||
| CollectionMixin[ParameterGroup], | ||
| Service[ParameterGroup], | ||
| ParameterGroupsServiceConfig, | ||
| ): | ||
| """Parameter Groups service.""" | ||
|
|
||
|
|
||
| class AsyncParameterGroupsService( | ||
| AsyncManagedResourceMixin[ParameterGroup], | ||
| AsyncCollectionMixin[ParameterGroup], | ||
| AsyncService[ParameterGroup], | ||
| ParameterGroupsServiceConfig, | ||
| ): | ||
| """Parameter Groups service.""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import pytest | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def parameter_group_id(e2e_config): | ||
| return e2e_config["program.parameter.group.id"] | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def invalid_parameter_group_id(): | ||
| return "PPG-0000-0000-0000" | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def parameter_group_data(): | ||
| return { | ||
| "name": "E2E Created Program Parameter Group", | ||
| "description": "E2E Created Program Parameter Group", | ||
| "label": "E2E Created Program Parameter Group", | ||
| "default": False, | ||
| "displayOrder": 100, | ||
| } |
63 changes: 63 additions & 0 deletions
63
tests/e2e/program/program/parameter_group/test_async_parameter_group.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import pytest | ||
|
|
||
| from mpt_api_client.exceptions import MPTAPIError | ||
| from mpt_api_client.rql.query_builder import RQLQuery | ||
|
|
||
| pytestmark = [pytest.mark.flaky] | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| async def created_parameter_group(async_mpt_vendor, program_id, parameter_group_data): | ||
| service = async_mpt_vendor.program.programs.parameter_groups(program_id) | ||
| group = await service.create(parameter_group_data) | ||
| yield group | ||
| try: | ||
| await service.delete(group.id) | ||
| except MPTAPIError as error: | ||
| print(f"TEARDOWN - Unable to delete parameter group {group.id}: {error.title}") # noqa: WPS421 | ||
|
|
||
|
|
||
| def test_create_parameter_group(created_parameter_group): | ||
| result = created_parameter_group.name == "E2E Created Program Parameter Group" | ||
|
|
||
| assert result is True | ||
|
|
||
|
|
||
| async def test_update_parameter_group(async_mpt_vendor, program_id, created_parameter_group): | ||
| service = async_mpt_vendor.program.programs.parameter_groups(program_id) | ||
| update_data = {"name": "E2E Updated Program Parameter Group"} | ||
|
|
||
| result = await service.update(created_parameter_group.id, update_data) | ||
|
|
||
| assert result.name == update_data["name"] | ||
|
|
||
|
|
||
| async def test_get_parameter_group(async_mpt_vendor, program_id, parameter_group_id): | ||
| service = async_mpt_vendor.program.programs.parameter_groups(program_id) | ||
|
|
||
| result = await service.get(parameter_group_id) | ||
|
|
||
| assert result.id == parameter_group_id | ||
|
|
||
|
|
||
| async def test_delete_parameter_group(async_mpt_vendor, program_id, created_parameter_group): | ||
| parameter_group_data = created_parameter_group | ||
|
|
||
| result = async_mpt_vendor.program.programs.parameter_groups(program_id) | ||
|
|
||
| await result.delete(parameter_group_data.id) | ||
|
|
||
|
|
||
| async def test_filter_and_select_parameter_groups(async_mpt_vendor, program_id, parameter_group_id): | ||
| select_fields = ["-description", "-audit"] | ||
| filtered_groups = ( | ||
| async_mpt_vendor.program.programs | ||
| .parameter_groups(program_id) | ||
| .filter(RQLQuery(id=parameter_group_id)) | ||
| .filter(RQLQuery(name="E2E Seeded Program Parameter Group")) | ||
| .select(*select_fields) | ||
| ) | ||
|
|
||
| result = [parameter_group async for parameter_group in filtered_groups.iterate()] | ||
|
|
||
| assert len(result) == 1 |
63 changes: 63 additions & 0 deletions
63
tests/e2e/program/program/parameter_group/test_sync_parameter_group.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import pytest | ||
|
|
||
| from mpt_api_client.exceptions import MPTAPIError | ||
| from mpt_api_client.rql.query_builder import RQLQuery | ||
|
|
||
| pytestmark = [pytest.mark.flaky] | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def created_parameter_group(mpt_vendor, program_id, parameter_group_data): | ||
| service = mpt_vendor.program.programs.parameter_groups(program_id) | ||
| group = service.create(parameter_group_data) | ||
| yield group | ||
| try: | ||
| service.delete(group.id) | ||
| except MPTAPIError as error: | ||
| print(f"TEARDOWN - Unable to delete parameter group {group.id}: {error.title}") # noqa: WPS421 | ||
|
|
||
|
|
||
| def test_create_parameter_group(created_parameter_group): | ||
| result = created_parameter_group.name == "E2E Created Program Parameter Group" | ||
|
|
||
| assert result is True | ||
|
|
||
|
|
||
| def test_update_parameter_group(mpt_vendor, program_id, created_parameter_group): | ||
| service = mpt_vendor.program.programs.parameter_groups(program_id) | ||
| update_data = {"name": "E2E Updated Program Parameter Group"} | ||
|
|
||
| result = service.update(created_parameter_group.id, update_data) | ||
|
|
||
| assert result.name == update_data["name"] | ||
|
|
||
|
|
||
| def test_get_parameter_group(mpt_vendor, program_id, parameter_group_id): | ||
| service = mpt_vendor.program.programs.parameter_groups(program_id) | ||
|
|
||
| result = service.get(parameter_group_id) | ||
|
|
||
| assert result.id == parameter_group_id | ||
|
|
||
|
|
||
| def test_delete_parameter_group(mpt_vendor, program_id, created_parameter_group): | ||
| parameter_group_data = created_parameter_group | ||
|
|
||
| result = mpt_vendor.program.programs.parameter_groups(program_id) | ||
|
|
||
| result.delete(parameter_group_data.id) | ||
|
|
||
|
|
||
| def test_filter_and_select_parameter_groups(mpt_vendor, program_id, parameter_group_id): | ||
| select_fields = ["-description", "-audit"] | ||
| filtered_groups = ( | ||
| mpt_vendor.program.programs | ||
| .parameter_groups(program_id) | ||
| .filter(RQLQuery(id=parameter_group_id)) | ||
| .filter(RQLQuery(name="E2E Seeded Program Parameter Group")) | ||
| .select(*select_fields) | ||
| ) | ||
|
|
||
| result = list(filtered_groups.iterate()) | ||
|
|
||
| assert len(result) == 1 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
tests/unit/resources/program/test_programs_parameter_groups.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| import pytest | ||
|
|
||
| from mpt_api_client.models.model import BaseModel | ||
| from mpt_api_client.resources.program.programs_parameter_groups import ( | ||
| AsyncParameterGroupsService, | ||
| ParameterGroup, | ||
| ParameterGroupsService, | ||
| ) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def parameter_groups_service(http_client): | ||
| return ParameterGroupsService( | ||
| http_client=http_client, endpoint_params={"program_id": "PPG-001"} | ||
| ) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def async_parameter_groups_service(async_http_client): | ||
| return AsyncParameterGroupsService( | ||
| http_client=async_http_client, endpoint_params={"program_id": "PPG-001"} | ||
| ) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def parameter_group_data(): | ||
| return { | ||
| "id": "GRP-001", | ||
| "name": "Program Parameter Group", | ||
| "label": "Program Parameter Group", | ||
| "description": "Program Parameter Group", | ||
| "displayOrder": 1, | ||
| "default": True, | ||
| "parameterCount": 5, | ||
| "program": {"id": "PPG-001", "name": "Program"}, | ||
| "audit": { | ||
| "created": {"at": "2024-01-01T00:00:00Z"}, | ||
| "updated": {"at": "2024-01-02T00:00:00Z"}, | ||
| }, | ||
| } | ||
|
|
||
|
|
||
| def test_endpoint(parameter_groups_service): | ||
| result = parameter_groups_service.path == "/public/v1/program/programs/PPG-001/parameter-groups" | ||
|
|
||
| assert result is True | ||
|
|
||
|
|
||
| def test_async_endpoint(async_parameter_groups_service): | ||
| result = ( | ||
| async_parameter_groups_service.path | ||
| == "/public/v1/program/programs/PPG-001/parameter-groups" | ||
| ) | ||
|
|
||
| assert result is True | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("method", ["get", "create", "delete", "update", "iterate"]) | ||
| def test_methods_present(parameter_groups_service, method): | ||
| result = hasattr(parameter_groups_service, method) | ||
|
|
||
| assert result is True | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("method", ["get", "create", "delete", "update", "iterate"]) | ||
| def test_async_methods_present(async_parameter_groups_service, method): | ||
| result = hasattr(async_parameter_groups_service, method) | ||
|
|
||
| assert result is True | ||
|
|
||
|
|
||
| def test_parameter_group_primitive_fields(parameter_group_data): | ||
| result = ParameterGroup(parameter_group_data) | ||
|
|
||
| assert result.to_dict() == parameter_group_data | ||
|
|
||
|
|
||
| def test_parameter_group_nested_field_types(parameter_group_data): | ||
| result = ParameterGroup(parameter_group_data) | ||
|
|
||
| assert isinstance(result.program, BaseModel) | ||
| assert isinstance(result.audit, BaseModel) | ||
|
|
||
|
|
||
| def test_parameter_group_optional_fields_absent(): | ||
| result = ParameterGroup({"id": "PPG-001"}) | ||
|
|
||
| assert result.id == "PPG-001" | ||
| assert not hasattr(result, "name") | ||
| assert not hasattr(result, "label") | ||
| assert not hasattr(result, "description") | ||
| assert not hasattr(result, "program") | ||
| assert not hasattr(result, "audit") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.