Skip to content

MPT-18374 Add Helpdesk Forms API services and tests#245

Merged
d3rky merged 1 commit intomainfrom
feat/MPT-18374
Mar 25, 2026
Merged

MPT-18374 Add Helpdesk Forms API services and tests#245
d3rky merged 1 commit intomainfrom
feat/MPT-18374

Conversation

@jentyk
Copy link
Member

@jentyk jentyk commented Mar 24, 2026

Summary

  • Add sync and async Helpdesk Forms services for /public/v1/helpdesk/forms
  • Implement publish and unpublish resource actions on forms
  • Wire forms into Helpdesk module properties (helpdesk.forms, async_helpdesk.forms)
  • Add unit tests for forms service behavior and helpdesk property exposure
  • Add e2e forms test scaffolding and sync/async test cases (created, not executed)

Testing

  • uv run pytest tests/unit/resources/helpdesk/test_forms.py tests/unit/resources/helpdesk/test_helpdesk.py
  • make check-all
  • uv run pytest tests/unit/resources/helpdesk/test_forms.py

Closes MPT-18374

  • Add synchronous FormsService and asynchronous AsyncFormsService for /public/v1/helpdesk/forms
  • Implement form resource actions: publish() and unpublish()
  • Expose forms via Helpdesk.forms and AsyncHelpdesk.forms properties
  • Add unit tests covering service configuration, available methods (get, create, update, delete, fetch_page, iterate, publish, unpublish) and resource-action behavior (sync + async)
  • Add unit test to verify Helpdesk/AsyncHelpdesk expose the new forms services
  • Add E2E test scaffolding and sync/async E2E test cases for form lifecycle (tests largely marked skip pending MPT-19124)
  • Update pyproject.toml flake8 per-file-ignores for helpdesk resource files (ignore WPS214)

@coderabbitai
Copy link

coderabbitai bot commented Mar 24, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 91accee0-c4d5-41c3-bb76-96d82248a29c

📥 Commits

Reviewing files that changed from the base of the PR and between 2d8c233 and 7f03ffa.

📒 Files selected for processing (9)
  • mpt_api_client/resources/helpdesk/forms.py
  • mpt_api_client/resources/helpdesk/helpdesk.py
  • pyproject.toml
  • tests/e2e/helpdesk/forms/__init__.py
  • tests/e2e/helpdesk/forms/conftest.py
  • tests/e2e/helpdesk/forms/test_async_forms.py
  • tests/e2e/helpdesk/forms/test_sync_forms.py
  • tests/unit/resources/helpdesk/test_forms.py
  • tests/unit/resources/helpdesk/test_helpdesk.py
✅ Files skipped from review due to trivial changes (5)
  • pyproject.toml
  • tests/unit/resources/helpdesk/test_helpdesk.py
  • mpt_api_client/resources/helpdesk/forms.py
  • tests/e2e/helpdesk/forms/conftest.py
  • tests/e2e/helpdesk/forms/init.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • tests/unit/resources/helpdesk/test_forms.py
  • tests/e2e/helpdesk/forms/test_sync_forms.py
  • tests/e2e/helpdesk/forms/test_async_forms.py

📝 Walkthrough

Walkthrough

Adds a Helpdesk Form resource: new Form model and sync/async FormsService with publish/unpublish actions, wires forms properties onto Helpdesk/AsyncHelpdesk, and adds unit and end-to-end tests and fixtures for forms.

Changes

Cohort / File(s) Summary
Core Implementation
mpt_api_client/resources/helpdesk/forms.py
New Form model, FormsServiceConfig (endpoint /public/v1/helpdesk/forms, collection key "data"), and FormsService/AsyncFormsService exposing publish(resource_id, resource_data=None) / unpublish(...) that POST to action paths and return Form.
Helpdesk Integration
mpt_api_client/resources/helpdesk/helpdesk.py
Added forms property on Helpdesk and AsyncHelpdesk to instantiate FormsService / AsyncFormsService using existing HTTP clients; added corresponding imports.
E2E Test package & fixtures
tests/e2e/helpdesk/forms/__init__.py, tests/e2e/helpdesk/forms/conftest.py
Created test package and fixtures: form_data, invalid_form_id, created_form (sync create+teardown), and async_created_form (async create+teardown).
E2E Tests
tests/e2e/helpdesk/forms/test_sync_forms.py, tests/e2e/helpdesk/forms/test_async_forms.py
Added flaky-marked E2E tests for CRUD and publish/unpublish flows; most tests are skipped pending MPT-19124; active test_not_found asserts MPTAPIError for invalid IDs.
Unit Tests
tests/unit/resources/helpdesk/test_forms.py, tests/unit/resources/helpdesk/test_helpdesk.py
Unit tests verify service path, expected methods (get, create, update, delete, fetch_page, iterate, publish, unpublish), and mock POST action tests for publish/unpublish. Helpdesk tests extended to include forms.
Lint config
pyproject.toml
Added WPS214 to per-file-ignores for mpt_api_client/resources/helpdesk/*.py.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Jira Issue Key In Title ✅ Passed The PR title contains exactly one Jira issue key in the correct format MPT-18374, which follows the required pattern MPT-XXXX.
Test Coverage Required ✅ Passed PR modifies code files and includes comprehensive test changes across 6 test files alongside code modifications.
Single Commit Required ✅ Passed The pull request contains exactly 1 commit with all Helpdesk Forms API changes properly integrated.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@jentyk jentyk changed the title Add Helpdesk Forms API services and tests MPT-18374 Add Helpdesk Forms API services and tests Mar 24, 2026
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
tests/unit/resources/helpdesk/test_forms.py (1)

18-27: Consider simplifying assertion pattern.

The intermediate result variable for boolean comparisons adds unnecessary indirection. Direct assertions would be more idiomatic:

✨ Proposed simplification
 def test_endpoint(forms_service):
-    result = forms_service.path == "/public/v1/helpdesk/forms"
-
-    assert result is True
+    assert forms_service.path == "/public/v1/helpdesk/forms"


 def test_async_endpoint(async_forms_service):
-    result = async_forms_service.path == "/public/v1/helpdesk/forms"
-
-    assert result is True
+    assert async_forms_service.path == "/public/v1/helpdesk/forms"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/unit/resources/helpdesk/test_forms.py` around lines 18 - 27, The tests
test_endpoint and test_async_endpoint create an unnecessary intermediate boolean
variable `result`; remove `result` and assert the path directly by replacing the
two blocks with direct assertions (e.g. use `assert forms_service.path ==
"/public/v1/helpdesk/forms"` and `assert async_forms_service.path ==
"/public/v1/helpdesk/forms"`), eliminating the redundant `result` assignment and
`assert result is True`.
mpt_api_client/resources/helpdesk/forms.py (1)

11-12: Consider whether Form model needs additional typed fields.

The Form model currently only inherits from Model without defining any Form-specific attributes. While this works (attributes are dynamically populated from API responses), adding type hints for common fields like name, description, status would improve IDE support and documentation.

This is optional and can be deferred if the API schema is still evolving.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@mpt_api_client/resources/helpdesk/forms.py` around lines 11 - 12, The Form
model currently just subclasses Model with no typed attributes; add explicit
typed fields (e.g., name: str, description: Optional[str], status: Optional[str]
or an Enum, id: Optional[int/str>, created_at: Optional[datetime]) to the Form
class to improve IDE/type-checker support and documentation while keeping
flexibility for evolving API schemas; update the Form class definition (class
Form(Model):) to declare these attributes with appropriate typing and
defaults/Optionals and import any needed types (Optional, datetime, Enum) so
IDEs and static analysis pick up common form fields.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@mpt_api_client/resources/helpdesk/forms.py`:
- Around line 11-12: The Form model currently just subclasses Model with no
typed attributes; add explicit typed fields (e.g., name: str, description:
Optional[str], status: Optional[str] or an Enum, id: Optional[int/str>,
created_at: Optional[datetime]) to the Form class to improve IDE/type-checker
support and documentation while keeping flexibility for evolving API schemas;
update the Form class definition (class Form(Model):) to declare these
attributes with appropriate typing and defaults/Optionals and import any needed
types (Optional, datetime, Enum) so IDEs and static analysis pick up common form
fields.

In `@tests/unit/resources/helpdesk/test_forms.py`:
- Around line 18-27: The tests test_endpoint and test_async_endpoint create an
unnecessary intermediate boolean variable `result`; remove `result` and assert
the path directly by replacing the two blocks with direct assertions (e.g. use
`assert forms_service.path == "/public/v1/helpdesk/forms"` and `assert
async_forms_service.path == "/public/v1/helpdesk/forms"`), eliminating the
redundant `result` assignment and `assert result is True`.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 4bef60f5-0553-41ea-b59b-66a9197de78e

📥 Commits

Reviewing files that changed from the base of the PR and between 0f6655f and a05f28f.

📒 Files selected for processing (8)
  • mpt_api_client/resources/helpdesk/forms.py
  • mpt_api_client/resources/helpdesk/helpdesk.py
  • tests/e2e/helpdesk/forms/__init__.py
  • tests/e2e/helpdesk/forms/conftest.py
  • tests/e2e/helpdesk/forms/test_async_forms.py
  • tests/e2e/helpdesk/forms/test_sync_forms.py
  • tests/unit/resources/helpdesk/test_forms.py
  • tests/unit/resources/helpdesk/test_helpdesk.py

@jentyk jentyk marked this pull request as ready for review March 24, 2026 10:24
@jentyk jentyk requested a review from a team as a code owner March 24, 2026 10:24
@jentyk jentyk requested review from albertsola and svazquezco March 24, 2026 10:24
@jentyk jentyk force-pushed the feat/MPT-18374 branch 2 times, most recently from ab8ec41 to ea01cda Compare March 24, 2026 15:35
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
tests/e2e/helpdesk/forms/test_async_forms.py (1)

53-56: Strengthen delete test with a post-delete check.

This currently passes if delete returns without raising, even if the record still exists. Add a follow-up read assertion to validate effect.

Proposed test hardening
 `@pytest.mark.skip`(reason="Unskip after MPT-19124 completed")
 async def test_delete_form(async_mpt_ops, async_created_form):
-    await async_mpt_ops.helpdesk.forms.delete(async_created_form.id)  # act
+    await async_mpt_ops.helpdesk.forms.delete(async_created_form.id)
+    with pytest.raises(MPTAPIError):
+        await async_mpt_ops.helpdesk.forms.get(async_created_form.id)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/e2e/helpdesk/forms/test_async_forms.py` around lines 53 - 56, The
delete test (test_delete_form) only calls
async_mpt_ops.helpdesk.forms.delete(async_created_form.id) and must be hardened
by adding a post-delete verification: after calling
async_mpt_ops.helpdesk.forms.delete, attempt to fetch the same form (e.g.,
async_mpt_ops.helpdesk.forms.read or get with async_created_form.id) and assert
the expected failure (raise of a NotFound/404 exception or a None/absent result)
to confirm the record was actually removed; update the test to await that read
call and assert the proper absent/exception behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/e2e/helpdesk/forms/test_async_forms.py`:
- Around line 53-56: The delete test (test_delete_form) only calls
async_mpt_ops.helpdesk.forms.delete(async_created_form.id) and must be hardened
by adding a post-delete verification: after calling
async_mpt_ops.helpdesk.forms.delete, attempt to fetch the same form (e.g.,
async_mpt_ops.helpdesk.forms.read or get with async_created_form.id) and assert
the expected failure (raise of a NotFound/404 exception or a None/absent result)
to confirm the record was actually removed; update the test to await that read
call and assert the proper absent/exception behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 2469cf58-e696-43b3-802c-5fab3eea8b17

📥 Commits

Reviewing files that changed from the base of the PR and between ab8ec41 and ea01cda.

📒 Files selected for processing (8)
  • mpt_api_client/resources/helpdesk/forms.py
  • mpt_api_client/resources/helpdesk/helpdesk.py
  • tests/e2e/helpdesk/forms/__init__.py
  • tests/e2e/helpdesk/forms/conftest.py
  • tests/e2e/helpdesk/forms/test_async_forms.py
  • tests/e2e/helpdesk/forms/test_sync_forms.py
  • tests/unit/resources/helpdesk/test_forms.py
  • tests/unit/resources/helpdesk/test_helpdesk.py
✅ Files skipped from review due to trivial changes (5)
  • tests/unit/resources/helpdesk/test_forms.py
  • tests/e2e/helpdesk/forms/test_sync_forms.py
  • tests/e2e/helpdesk/forms/init.py
  • tests/e2e/helpdesk/forms/conftest.py
  • mpt_api_client/resources/helpdesk/forms.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/unit/resources/helpdesk/test_helpdesk.py

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@mpt_api_client/resources/helpdesk/helpdesk.py`:
- Around line 48-52: The Helpdesk and AsyncHelpdesk classes now exceed the
WPS214 method limit due to the new forms property; to fix CI, add a per-class
suppression for the wemake rule by annotating the Helpdesk and AsyncHelpdesk
class definitions with a noqa for WPS214 (e.g., append "# noqa: WPS214" to each
class line) or alternatively refactor by consolidating service accessors (e.g.,
create a single services container or a single getter method that returns
FormsService and the other services) so the number of explicit
methods/properties drops below the WPS214 threshold; update the class
declarations or refactor the accessors accordingly referencing the
Helpdesk/AsyncHelpdesk classes and the forms property.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 428f686f-6d76-4299-9745-10659db201a4

📥 Commits

Reviewing files that changed from the base of the PR and between ea01cda and 2d8c233.

📒 Files selected for processing (8)
  • mpt_api_client/resources/helpdesk/forms.py
  • mpt_api_client/resources/helpdesk/helpdesk.py
  • tests/e2e/helpdesk/forms/__init__.py
  • tests/e2e/helpdesk/forms/conftest.py
  • tests/e2e/helpdesk/forms/test_async_forms.py
  • tests/e2e/helpdesk/forms/test_sync_forms.py
  • tests/unit/resources/helpdesk/test_forms.py
  • tests/unit/resources/helpdesk/test_helpdesk.py
✅ Files skipped from review due to trivial changes (3)
  • tests/e2e/helpdesk/forms/init.py
  • tests/e2e/helpdesk/forms/conftest.py
  • mpt_api_client/resources/helpdesk/forms.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • tests/unit/resources/helpdesk/test_helpdesk.py
  • tests/e2e/helpdesk/forms/test_sync_forms.py
  • tests/e2e/helpdesk/forms/test_async_forms.py

@sonarqubecloud
Copy link

@d3rky d3rky merged commit 3d19416 into main Mar 25, 2026
4 checks passed
@d3rky d3rky deleted the feat/MPT-18374 branch March 25, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants