MPT-21922 finalize helpdesk queues/cases on E2E teardown (+ _process_value refactor)#340
Closed
jentyk wants to merge 1 commit into
Closed
MPT-21922 finalize helpdesk queues/cases on E2E teardown (+ _process_value refactor)#340jentyk wants to merge 1 commit into
jentyk wants to merge 1 commit into
Conversation
Extract the dict- and list-conversion branches of BaseModel._process_value into module-level helpers (_build_model_from_dict and _resolve_list_model_class). This flattens the nested conditionals that drove cognitive complexity to 18, bringing the method under the allowed 15. Behaviour is unchanged; the redundant trailing isinstance(value, BaseModel) check folds into the final return. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



This branch carries two changes under MPT-21922.
1. MPT-21922 — E2E helpdesk teardown cleanup (the ticket)
Bug: "[E2E] Queue and Case Status update upon test completions — when test completed, update queue status to disabled and case status to completed." (reported by John McDonnell)
E2E helpdesk fixtures left resources in non-terminal states after a test:
created_case/async_created_casehad no teardown at all, andCasesServicehas no delete — so every run left cases lingering open.created_queuetore down via delete, butcase_dataattaches a case to that queue; deleting a queue with an active case fails (the "TEARDOWN - Unable to delete" path), leaving the queue active too.Fix (
tests/e2e/helper.py,tests/e2e/helpdesk/conftest.py):create_fixture_resource_and_finalize+async_create_fixture_resource_and_finalize, mirroring the existing delete-teardown context managers but invoking a terminal-state transition best-effort (errors logged, never raised — same convention as the delete helpers).2.
_process_valuecognitive-complexity refactorRefactors
BaseModel._process_valueinmpt_api_client/models/model.pyto reduce its Cognitive Complexity from 18 to ~4 (allowed: 15), flagged by SonarQube.The dict- and list-conversion branches are extracted into two flat module-level helpers (
_build_model_from_dict,_resolve_list_model_class), removing the nesting that drove the score. Behaviour is unchanged; the redundant trailingisinstance(value, BaseModel)check folds into the final return. Helpers are kept module-level (matchingto_snake_case/to_camel_case) to avoid tripping WPS214's method-count limit.Verification
make checkpasses clean for both changes (ruff format,ruff check,flake8/WPS,mypy,uv lock --check); 118 model unit tests pass; helpdesk E2E suite collects cleanly.