Skip to content

Conversation

@albertsola
Copy link
Contributor

@albertsola albertsola commented Dec 30, 2025

Summary by CodeRabbit

  • Tests
    • Added comprehensive end-to-end tests (sync and async) for event type operations: retrieval, filtering, updates, and 404 error handling.
    • Added supporting fixtures to supply synchronous and asynchronous test services and sample event type data for the new e2e tests.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 30, 2025

📝 Walkthrough

Walkthrough

Adds pytest fixtures for audit event types and two new end-to-end test modules (sync + async) that exercise get, filter, update, and not-found scenarios for EventType entities.

Changes

Cohort / File(s) Summary
Test Fixtures
tests/e2e/audit/event_types/conftest.py
Adds four pytest fixtures: event_types_service (returns EventTypesService from MPTClient), async_event_types_service (returns AsyncEventTypesService from AsyncMPTClient), event_type (selects the first EventType via iterate()), and event_type_update_data (dict with a new description).
Async Event Types Tests
tests/e2e/audit/event_types/test_async_event_types.py
New async e2e test module with four tests: test_get_event_type, test_filter_event_types (uses RQLQuery and async iteration), test_update_event_type, and test_get_event_type_not_found (expects MPTAPIError 404). Module marked flaky.
Sync Event Types Tests
tests/e2e/audit/event_types/test_sync_event_types.py
New sync e2e test module mirroring async coverage: test_get_event_type, test_filter_event_types (uses RQLQuery), test_update_event_type, and test_get_event_type_not_found (expects MPTAPIError 404). Module-level flaky marker applied.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰
I hopped through fixtures, quick and bright,
Found an event in morning light,
Sync and async tests in tune,
Update, filter — none too soon,
A tiny rabbit cheers: "All set, delight!"

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'MPT-14939 E2E for audit event_types' directly describes the main change: adding end-to-end tests for audit event types.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch e2e/MPT-14939/audit-event-types

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a1beef5 and 3044703.

📒 Files selected for processing (3)
  • tests/e2e/audit/event_types/conftest.py
  • tests/e2e/audit/event_types/test_async_event_types.py
  • tests/e2e/audit/event_types/test_sync_event_types.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/e2e/audit/event_types/test_sync_event_types.py
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: robcsegal
Repo: softwareone-platform/mpt-api-python-client PR: 131
File: tests/e2e/accounts/accounts_users/test_async_accounts_users.py:0-0
Timestamp: 2025-11-27T00:05:54.701Z
Learning: In pytest-asyncio, async fixtures are automatically resolved before being passed to test functions (both sync and async). Test functions receive the yielded value from async fixtures, not coroutines, so fixture parameters should never be awaited. A sync test function can use async fixtures without any special handling.
Learnt from: robcsegal
Repo: softwareone-platform/mpt-api-python-client PR: 160
File: tests/e2e/commerce/agreement/attachment/test_async_agreement_attachment.py:55-58
Timestamp: 2025-12-12T15:02:29.261Z
Learning: In pytest with pytest-asyncio, test functions that use async fixtures but don't perform any await operations themselves should remain synchronous (def, not async def) to avoid linter complaints about unnecessary async functions. The async fixture resolution is handled automatically by pytest-asyncio.
📚 Learning: 2025-12-12T15:02:20.732Z
Learnt from: robcsegal
Repo: softwareone-platform/mpt-api-python-client PR: 160
File: tests/e2e/commerce/agreement/attachment/test_async_agreement_attachment.py:55-58
Timestamp: 2025-12-12T15:02:20.732Z
Learning: In pytest with pytest-asyncio, if a test function uses async fixtures but contains no await, declare the test function as def (synchronous) instead of async def. Pytest-asyncio will resolve the async fixtures automatically; this avoids linter complaints about unnecessary async functions. This pattern applies to any test file under the tests/ directory that uses such fixtures.

Applied to files:

  • tests/e2e/audit/event_types/conftest.py
  • tests/e2e/audit/event_types/test_async_event_types.py
🧬 Code graph analysis (2)
tests/e2e/audit/event_types/conftest.py (3)
mpt_api_client/mpt_client.py (2)
  • AsyncMPTClient (20-71)
  • MPTClient (74-130)
mpt_api_client/resources/audit/event_types.py (3)
  • AsyncEventTypesService (35-42)
  • EventType (13-14)
  • EventTypesService (25-32)
tests/e2e/conftest.py (2)
  • mpt_vendor (19-20)
  • async_mpt_vendor (24-27)
tests/e2e/audit/event_types/test_async_event_types.py (5)
mpt_api_client/exceptions.py (1)
  • MPTAPIError (20-42)
mpt_api_client/resources/audit/event_types.py (2)
  • AsyncEventTypesService (35-42)
  • EventType (13-14)
mpt_api_client/rql/query_builder.py (1)
  • RQLQuery (115-524)
tests/e2e/audit/event_types/conftest.py (2)
  • async_event_types_service (19-20)
  • event_type (24-25)
mpt_api_client/models/model.py (1)
  • id (119-121)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (7)
tests/e2e/audit/event_types/conftest.py (3)

13-15: LGTM!

Standard fixture pattern correctly accessing the event_types service from the vendor client.


18-20: LGTM!

Standard async fixture pattern correctly accessing the async event_types service.


28-32: LGTM!

Test data fixture provides appropriate update payload for e2e testing.

tests/e2e/audit/event_types/test_async_event_types.py (4)

12-18: LGTM!

Test correctly verifies both id and key fields when fetching an event type.


21-29: LGTM!

Test correctly demonstrates filtering with RQLQuery and async iteration. The assertion verifies the filter returns the expected single result.


32-39: LGTM!

Test correctly verifies the update operation, ensuring the event type ID remains unchanged after updating the description.


42-44: LGTM!

Test correctly verifies that fetching a non-existent event type raises the expected MPTAPIError with a 404 status.


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

@github-actions
Copy link

github-actions bot commented Dec 30, 2025

✅ Found Jira issue key in the title: MPT-14939

Generated by 🚫 dangerJS against 3044703

@albertsola albertsola force-pushed the e2e/MPT-14939/audit-event-types branch from bf04eee to 45155b9 Compare December 30, 2025 12:37
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

🧹 Nitpick comments (2)
tests/e2e/audit/event_types/test_async_event_types.py (1)

20-29: Avoid variable shadowing in list comprehension.

The variable event_type in the async comprehension (line 25) shadows the fixture parameter event_type, which reduces clarity. Consider using a different name for the loop variable.

🔎 Proposed fix
 async def test_filter_event_types(
     async_event_types_service: AsyncEventTypesService, event_type: EventType
 ) -> None:
     iterator = async_event_types_service.filter(RQLQuery(id=event_type.id)).iterate()

-    result = [event_type async for event_type in iterator]
+    result = [et async for et in iterator]

     assert len(result) == 1
     assert result[0].id == event_type.id
tests/e2e/audit/event_types/conftest.py (1)

23-28: Consider using iterator pattern for efficiency.

Materializing the entire list of event types is unnecessary when only the first item is needed. Using next(iter(...), None) would be more efficient, especially if the system has many event types.

🔎 Proposed fix
 @pytest.fixture
 def event_type(event_types_service: EventTypesService) -> EventType:
-    event_types = list(event_types_service.iterate())
-    if not event_types:
+    event_type = next(iter(event_types_service.iterate()), None)
+    if event_type is None:
         pytest.skip("No event types found in the system.")
-    return event_types[0]
+    return event_type
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5306629 and bf04eee.

📒 Files selected for processing (3)
  • tests/e2e/audit/event_types/conftest.py
  • tests/e2e/audit/event_types/test_async_event_types.py
  • tests/e2e/audit/event_types/test_sync_event_types.py
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: robcsegal
Repo: softwareone-platform/mpt-api-python-client PR: 131
File: tests/e2e/accounts/accounts_users/test_async_accounts_users.py:0-0
Timestamp: 2025-11-27T00:05:54.701Z
Learning: In pytest-asyncio, async fixtures are automatically resolved before being passed to test functions (both sync and async). Test functions receive the yielded value from async fixtures, not coroutines, so fixture parameters should never be awaited. A sync test function can use async fixtures without any special handling.
📚 Learning: 2025-12-12T15:02:20.732Z
Learnt from: robcsegal
Repo: softwareone-platform/mpt-api-python-client PR: 160
File: tests/e2e/commerce/agreement/attachment/test_async_agreement_attachment.py:55-58
Timestamp: 2025-12-12T15:02:20.732Z
Learning: In pytest with pytest-asyncio, if a test function uses async fixtures but contains no await, declare the test function as def (synchronous) instead of async def. Pytest-asyncio will resolve the async fixtures automatically; this avoids linter complaints about unnecessary async functions. This pattern applies to any test file under the tests/ directory that uses such fixtures.

Applied to files:

  • tests/e2e/audit/event_types/test_sync_event_types.py
  • tests/e2e/audit/event_types/conftest.py
  • tests/e2e/audit/event_types/test_async_event_types.py
🧬 Code graph analysis (3)
tests/e2e/audit/event_types/test_sync_event_types.py (5)
mpt_api_client/exceptions.py (1)
  • MPTAPIError (20-42)
mpt_api_client/resources/audit/event_types.py (2)
  • EventType (13-14)
  • EventTypesService (25-32)
mpt_api_client/rql/query_builder.py (1)
  • RQLQuery (115-524)
tests/e2e/audit/event_types/conftest.py (3)
  • event_types_service (14-15)
  • event_type (24-28)
  • event_type_update_data (32-35)
mpt_api_client/models/model.py (1)
  • id (119-121)
tests/e2e/audit/event_types/conftest.py (3)
mpt_api_client/mpt_client.py (2)
  • AsyncMPTClient (20-71)
  • MPTClient (74-130)
mpt_api_client/resources/audit/event_types.py (3)
  • AsyncEventTypesService (35-42)
  • EventType (13-14)
  • EventTypesService (25-32)
tests/e2e/conftest.py (2)
  • mpt_vendor (19-20)
  • async_mpt_vendor (24-27)
tests/e2e/audit/event_types/test_async_event_types.py (5)
mpt_api_client/exceptions.py (1)
  • MPTAPIError (20-42)
mpt_api_client/resources/audit/event_types.py (2)
  • AsyncEventTypesService (35-42)
  • EventType (13-14)
mpt_api_client/rql/query_builder.py (1)
  • RQLQuery (115-524)
tests/e2e/audit/event_types/conftest.py (3)
  • async_event_types_service (19-20)
  • event_type (24-28)
  • event_type_update_data (32-35)
mpt_api_client/models/model.py (1)
  • id (119-121)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (9)
tests/e2e/audit/event_types/test_async_event_types.py (2)

31-39: LGTM!

The update test correctly verifies that the ID remains unchanged after the update operation.


41-43: LGTM!

The 404 error handling test is correctly implemented with appropriate exception matching.

tests/e2e/audit/event_types/conftest.py (3)

13-15: LGTM!

The sync service fixture is correctly structured.


18-20: LGTM!

The async service fixture is correctly structured.


31-35: LGTM!

The update data fixture provides appropriate test data.

tests/e2e/audit/event_types/test_sync_event_types.py (4)

12-17: LGTM!

The test correctly retrieves an event type and validates both the id and key fields.


19-24: LGTM!

The filter test correctly validates that RQL filtering returns the expected event type.


26-34: LGTM!

The update test correctly verifies that the ID remains unchanged after the update operation.


36-38: LGTM!

The 404 error handling test is correctly implemented with appropriate exception matching.

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: 0

🧹 Nitpick comments (2)
tests/e2e/audit/event_types/test_async_event_types.py (2)

20-29: Consider renaming the loop variable to avoid shadowing the fixture.

On line 25, the list comprehension's loop variable event_type shadows the fixture parameter of the same name. While this doesn't cause runtime issues (the fixture isn't used after line 23), renaming the loop variable (e.g., to et or item) would improve clarity.

🔎 Suggested refactor
-    result = [event_type async for event_type in iterator]
+    result = [et async for et in iterator]
 
     assert len(result) == 1
-    assert result[0].id == event_type.id
+    assert result[0].id == event_type.id

31-39: Consider verifying that the update was applied.

The test asserts the id remains unchanged, but doesn't verify that the description field was actually updated. If this matches the pattern used in sync tests, this is fine; otherwise, consider adding an assertion like assert result.description == event_type_update_data["description"].

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bf04eee and 45155b9.

📒 Files selected for processing (3)
  • tests/e2e/audit/event_types/conftest.py
  • tests/e2e/audit/event_types/test_async_event_types.py
  • tests/e2e/audit/event_types/test_sync_event_types.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/e2e/audit/event_types/test_sync_event_types.py
  • tests/e2e/audit/event_types/conftest.py
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: robcsegal
Repo: softwareone-platform/mpt-api-python-client PR: 131
File: tests/e2e/accounts/accounts_users/test_async_accounts_users.py:0-0
Timestamp: 2025-11-27T00:05:54.701Z
Learning: In pytest-asyncio, async fixtures are automatically resolved before being passed to test functions (both sync and async). Test functions receive the yielded value from async fixtures, not coroutines, so fixture parameters should never be awaited. A sync test function can use async fixtures without any special handling.
Learnt from: robcsegal
Repo: softwareone-platform/mpt-api-python-client PR: 160
File: tests/e2e/commerce/agreement/attachment/test_async_agreement_attachment.py:55-58
Timestamp: 2025-12-12T15:02:29.261Z
Learning: In pytest with pytest-asyncio, test functions that use async fixtures but don't perform any await operations themselves should remain synchronous (def, not async def) to avoid linter complaints about unnecessary async functions. The async fixture resolution is handled automatically by pytest-asyncio.
📚 Learning: 2025-12-12T15:02:20.732Z
Learnt from: robcsegal
Repo: softwareone-platform/mpt-api-python-client PR: 160
File: tests/e2e/commerce/agreement/attachment/test_async_agreement_attachment.py:55-58
Timestamp: 2025-12-12T15:02:20.732Z
Learning: In pytest with pytest-asyncio, if a test function uses async fixtures but contains no await, declare the test function as def (synchronous) instead of async def. Pytest-asyncio will resolve the async fixtures automatically; this avoids linter complaints about unnecessary async functions. This pattern applies to any test file under the tests/ directory that uses such fixtures.

Applied to files:

  • tests/e2e/audit/event_types/test_async_event_types.py
🧬 Code graph analysis (1)
tests/e2e/audit/event_types/test_async_event_types.py (5)
mpt_api_client/exceptions.py (1)
  • MPTAPIError (20-42)
mpt_api_client/resources/audit/event_types.py (2)
  • AsyncEventTypesService (35-42)
  • EventType (13-14)
mpt_api_client/rql/query_builder.py (1)
  • RQLQuery (115-524)
tests/e2e/audit/event_types/conftest.py (3)
  • async_event_types_service (19-20)
  • event_type (24-26)
  • event_type_update_data (30-33)
mpt_api_client/models/model.py (1)
  • id (119-121)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (1)
tests/e2e/audit/event_types/test_async_event_types.py (1)

41-43: LGTM! The 404 error handling test is well-structured.

The test correctly verifies that attempting to fetch a non-existent event type raises MPTAPIError with a 404 status. The regex pattern matches the error message format, and the use of a clearly non-existent ID (EVT-000-000) is appropriate.

@albertsola albertsola force-pushed the e2e/MPT-14939/audit-event-types branch from 45155b9 to a1beef5 Compare December 30, 2025 13:15
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

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 45155b9 and a1beef5.

📒 Files selected for processing (3)
  • tests/e2e/audit/event_types/conftest.py
  • tests/e2e/audit/event_types/test_async_event_types.py
  • tests/e2e/audit/event_types/test_sync_event_types.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/e2e/audit/event_types/test_async_event_types.py
  • tests/e2e/audit/event_types/test_sync_event_types.py
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: robcsegal
Repo: softwareone-platform/mpt-api-python-client PR: 131
File: tests/e2e/accounts/accounts_users/test_async_accounts_users.py:0-0
Timestamp: 2025-11-27T00:05:54.701Z
Learning: In pytest-asyncio, async fixtures are automatically resolved before being passed to test functions (both sync and async). Test functions receive the yielded value from async fixtures, not coroutines, so fixture parameters should never be awaited. A sync test function can use async fixtures without any special handling.
📚 Learning: 2025-12-12T15:02:20.732Z
Learnt from: robcsegal
Repo: softwareone-platform/mpt-api-python-client PR: 160
File: tests/e2e/commerce/agreement/attachment/test_async_agreement_attachment.py:55-58
Timestamp: 2025-12-12T15:02:20.732Z
Learning: In pytest with pytest-asyncio, if a test function uses async fixtures but contains no await, declare the test function as def (synchronous) instead of async def. Pytest-asyncio will resolve the async fixtures automatically; this avoids linter complaints about unnecessary async functions. This pattern applies to any test file under the tests/ directory that uses such fixtures.

Applied to files:

  • tests/e2e/audit/event_types/conftest.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (3)
tests/e2e/audit/event_types/conftest.py (3)

1-10: LGTM!

Imports are well-organized and include all necessary types for the fixtures.


13-20: LGTM!

Both service fixtures follow the standard pattern for exposing sync and async service instances from the client.


29-33: LGTM!

The update data fixture provides appropriate test data for event type updates.

@albertsola albertsola force-pushed the e2e/MPT-14939/audit-event-types branch from a1beef5 to 3044703 Compare December 30, 2025 13:30
@sonarqubecloud
Copy link

@d3rky d3rky merged commit 78d5e8f into main Dec 30, 2025
6 checks passed
@d3rky d3rky deleted the e2e/MPT-14939/audit-event-types branch December 30, 2025 14:36
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.

4 participants