Skip to content

MPT-19484 unskip tests and refactor fixtures for async and sync cases#267

Merged
jentyk merged 1 commit intomainfrom
feat/MPT-19484
Apr 1, 2026
Merged

MPT-19484 unskip tests and refactor fixtures for async and sync cases#267
jentyk merged 1 commit intomainfrom
feat/MPT-19484

Conversation

@jentyk
Copy link
Copy Markdown
Member

@jentyk jentyk commented Apr 1, 2026

Closes MPT-19484

  • Add pytest fixtures for helpdesk case e2e lifecycle:
    • Sync: queried_case, processed_case
    • Async: async_queried_case, async_processed_case
  • Unskip and refactor async tests to use async fixtures and assert case status values (Querying, Processing, Completed)
  • Unskip and refactor sync tests to use sync fixtures and assert case status values instead of performing inline operations
  • Consolidate case state transitions into reusable fixtures to simplify and DRY test implementations

@jentyk jentyk requested a review from a team as a code owner April 1, 2026 08:35
@jentyk jentyk requested review from alephsur and robcsegal April 1, 2026 08:35
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 1, 2026

📝 Walkthrough

Walkthrough

Adds synchronous and asynchronous pytest fixtures that chain helpdesk case actions (create → query → process), and refactors/enables sync and async tests to consume these fixtures and assert status transitions instead of performing inline API calls.

Changes

Cohort / File(s) Summary
Test fixtures
tests/e2e/helpdesk/cases/conftest.py
Adds four fixtures: queried_case, processed_case (sync) and async_queried_case, async_processed_case (async); each chains query() then process() on a previously created case.
Async tests
tests/e2e/helpdesk/cases/test_async_cases.py
Removes pytest.mark.skip from test_get_case/test_create_case; refactors test_process_case and test_query_case to consume async_processed_case/async_queried_case fixtures and assert status values; converts test_complete_case to call complete(async_processed_case.id) and assert "Completed".
Sync tests
tests/e2e/helpdesk/cases/test_sync_cases.py
Removes pytest.mark.skip from several tests; refactors test_process_case, test_query_case, and test_complete_case to consume processed_case/queried_case fixtures and assert status values instead of invoking inline query/process calls.

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 the Jira issue key MPT-19484 in correct format, referenced at the beginning and in PR objectives.
Test Coverage Required ✅ Passed PR modifies only test files within tests/ folder; no code files outside tests/ were changed.
Single Commit Required ✅ Passed The pull request contains exactly one commit (954a591: "test(helpdesk): unskip tests and refactor fixtures for async and sync cases"), which meets the requirement of maintaining a clean and easy-to-follow git history.

✏️ 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.

Copy link
Copy Markdown

@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

🧹 Nitpick comments (2)
tests/e2e/helpdesk/cases/test_async_cases.py (1)

42-51: Remove unused async_mpt_ops parameter from tests that only validate fixture state.

Same as the sync counterparts—test_process_case and test_query_case don't use async_mpt_ops. Also, correctly declaring these as def (not async def) since they contain no await aligns with the project's testing conventions. Based on learnings, pytest-asyncio resolves async fixtures automatically for sync test functions.

♻️ Proposed fix
-def test_process_case(async_mpt_ops, async_processed_case):
+def test_process_case(async_processed_case):
     result = async_processed_case.to_dict().get("status")

     assert result == "Processing"


-def test_query_case(async_mpt_ops, async_queried_case):
+def test_query_case(async_queried_case):
     result = async_queried_case.to_dict().get("status")

     assert result == "Querying"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/e2e/helpdesk/cases/test_async_cases.py` around lines 42 - 51, The tests
test_process_case and test_query_case declare an unused parameter async_mpt_ops
and are already synchronous functions; remove the unused async_mpt_ops parameter
from both function signatures and keep them as regular def tests so pytest can
resolve the async fixtures (async_processed_case and async_queried_case)
automatically; ensure you only reference the needed fixtures
async_processed_case and async_queried_case in the signatures for
test_process_case and test_query_case respectively.
tests/e2e/helpdesk/cases/test_sync_cases.py (1)

42-51: Remove unused mpt_ops parameter from tests that only validate fixture state.

test_process_case and test_query_case receive mpt_ops but never use it—the tests only assert on the fixture-provided state. Removing unused parameters keeps tests cleaner.

♻️ Proposed fix
-def test_process_case(mpt_ops, processed_case):
+def test_process_case(processed_case):
     result = processed_case.to_dict().get("status")

     assert result == "Processing"


-def test_query_case(mpt_ops, queried_case):
+def test_query_case(queried_case):
     result = queried_case.to_dict().get("status")

     assert result == "Querying"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/e2e/helpdesk/cases/test_sync_cases.py` around lines 42 - 51, Remove the
unused mpt_ops fixture parameter from the two test functions to avoid
unused-argument noise: update the function signatures for test_process_case and
test_query_case to accept only the fixtures they use (processed_case and
queried_case respectively) and leave the assertions unchanged; ensure there are
no other references to mpt_ops inside those functions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/e2e/helpdesk/cases/conftest.py`:
- Line 30: Fix the typo in the query prompt string used by the fixtures: update
the call to mpt_ops.helpdesk.cases.query (both sync and async fixtures) so the
{"queryPrompt": "More detaisl needed"} argument is corrected to {"queryPrompt":
"More details needed"}; search for mpt_ops.helpdesk.cases.query in this file and
replace the misspelled "detaisl" with "details" in each occurrence.

---

Nitpick comments:
In `@tests/e2e/helpdesk/cases/test_async_cases.py`:
- Around line 42-51: The tests test_process_case and test_query_case declare an
unused parameter async_mpt_ops and are already synchronous functions; remove the
unused async_mpt_ops parameter from both function signatures and keep them as
regular def tests so pytest can resolve the async fixtures (async_processed_case
and async_queried_case) automatically; ensure you only reference the needed
fixtures async_processed_case and async_queried_case in the signatures for
test_process_case and test_query_case respectively.

In `@tests/e2e/helpdesk/cases/test_sync_cases.py`:
- Around line 42-51: Remove the unused mpt_ops fixture parameter from the two
test functions to avoid unused-argument noise: update the function signatures
for test_process_case and test_query_case to accept only the fixtures they use
(processed_case and queried_case respectively) and leave the assertions
unchanged; ensure there are no other references to mpt_ops inside those
functions.
🪄 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: 12a9505a-371d-4c56-bc77-b1313038b72a

📥 Commits

Reviewing files that changed from the base of the PR and between 66fad1e and c9e79b4.

📒 Files selected for processing (3)
  • tests/e2e/helpdesk/cases/conftest.py
  • tests/e2e/helpdesk/cases/test_async_cases.py
  • tests/e2e/helpdesk/cases/test_sync_cases.py

Comment thread tests/e2e/helpdesk/cases/conftest.py Outdated
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Apr 1, 2026

Copy link
Copy Markdown

@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/cases/conftest.py (1)

29-30: Consider extracting the repeated query prompt into a module-level constant.

"More details needed" is duplicated in both sync and async fixtures; a shared constant would reduce drift risk.

♻️ Optional refactor
+QUERY_PROMPT = {"queryPrompt": "More details needed"}
+
 `@pytest.fixture`
 def queried_case(mpt_ops, created_case):
-    return mpt_ops.helpdesk.cases.query(created_case.id, {"queryPrompt": "More details needed"})
+    return mpt_ops.helpdesk.cases.query(created_case.id, QUERY_PROMPT)
@@
 `@pytest.fixture`
 async def async_queried_case(async_mpt_ops, async_created_case):
-    return await async_mpt_ops.helpdesk.cases.query(
-        async_created_case.id, {"queryPrompt": "More details needed"}
-    )
+    return await async_mpt_ops.helpdesk.cases.query(async_created_case.id, QUERY_PROMPT)

Also applies to: 45-47

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

In `@tests/e2e/helpdesk/cases/conftest.py` around lines 29 - 30, Extract the
repeated query prompt string ("More details needed") into a module-level
constant (e.g., QUERY_PROMPT_MORE_DETAILS) and use that constant in the
queried_case fixture (function queried_case) and the corresponding async fixture
at lines 45-47 so both fixtures reference the same value; update imports/uses in
this file accordingly to replace the literal with the new constant.
🤖 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/cases/conftest.py`:
- Around line 29-30: Extract the repeated query prompt string ("More details
needed") into a module-level constant (e.g., QUERY_PROMPT_MORE_DETAILS) and use
that constant in the queried_case fixture (function queried_case) and the
corresponding async fixture at lines 45-47 so both fixtures reference the same
value; update imports/uses in this file accordingly to replace the literal with
the new constant.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: 4266b43e-86da-466b-80c0-5fe5ce78166d

📥 Commits

Reviewing files that changed from the base of the PR and between c9e79b4 and 954a591.

📒 Files selected for processing (3)
  • tests/e2e/helpdesk/cases/conftest.py
  • tests/e2e/helpdesk/cases/test_async_cases.py
  • tests/e2e/helpdesk/cases/test_sync_cases.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/e2e/helpdesk/cases/test_sync_cases.py

@jentyk
Copy link
Copy Markdown
Member Author

jentyk commented Apr 1, 2026

@CodeRabbit review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 1, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@jentyk jentyk merged commit b800126 into main Apr 1, 2026
4 checks passed
@jentyk jentyk deleted the feat/MPT-19484 branch April 1, 2026 09:20
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