Skip to content

Conversation

@albertsola
Copy link
Contributor

@albertsola albertsola commented Dec 18, 2025

Summary by CodeRabbit

  • New Features

    • Streamlined file upload capability for batch notifications via improved service configuration.
  • Tests

    • Added comprehensive end-to-end test coverage for batch operations including creation, retrieval, filtering, and file uploads.
    • Enhanced category notification tests with improved fixture-based validation.

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

@coderabbitai
Copy link

coderabbitai bot commented Dec 18, 2025

Walkthrough

Configuration and service refactoring to enable file upload capability in batch notifications. Batches service now uses CreateFileMixin/AsyncCreateFileMixin instead of explicit create methods. E2E test fixtures and tests added for batch operations and category retrieval. Unit test coverage for create-with-file flows removed.

Changes

Cohort / File(s) Summary
Configuration
e2e_config.test.json
Added two new config keys: notifications.batch.id and notifications.category.id
Service refactoring
mpt_api_client/resources/notifications/batches.py
BatchesService and AsyncBatchesService now inherit CreateFileMixin and AsyncCreateFileMixin respectively; explicit create methods removed; BatchesServiceConfig updated with _upload_file_key = "attachment" and _upload_data_key = "batch"
E2E test fixtures
tests/e2e/notifications/batch/conftest.py, tests/e2e/notifications/conftest.py
Added fixtures: batch_service, async_batch_service, batch_id, batch_data, and category_id to support batch and category e2e tests
E2E batch tests
tests/e2e/notifications/batch/test_async_batches.py, tests/e2e/notifications/batch/test_batches.py
New test modules covering batch creation, retrieval by ID, filtering via RQL, create-with-file, and attachment download placeholder tests (several marked as skipped)
E2E category tests
tests/e2e/notifications/categories/test_async_categories.py, tests/e2e/notifications/categories/test_sync_categories.py
Tests refactored to use category_id fixture for lookups; skip decorators removed; replaced created_category parameter with category_id in test signatures; post-delete verification assertions removed
Unit tests
tests/unit/resources/notifications/test_batches.py
Removed test coverage for attachment retrieval and create-with-file flows; retained only method existence checks

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Service refactoring (batches.py): Verify mixin inheritance pattern, configuration keys (_upload_file_key, _upload_data_key), and that mixin-delegated behavior matches previous explicit create logic
  • E2E test fixture additions: Confirm fixture dependencies and payloads (especially batch_data construction with generated contact email)
  • E2E test parameter changes: Validate that switching from created_category to category_id in category tests aligns with external config-based IDs and doesn't break test isolation
  • Unit test removal: Ensure removed test coverage (attachment retrieval, create-with-file validation) is intentionally replaced by e2e tests and not leaving gaps

Possibly related PRs

Suggested reviewers

  • d3rky
  • svazquezco
  • alephsur
  • ruben-sebrango
  • jentyk

Poem

🐰 Mixins hop in, custom code hops out,
Batches get files without a doubt,
E2E tests now dance with fixtures neat,
Attachment uploads, soon complete! 📧✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ 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 accurately describes the main objective of the pull request: adding end-to-end tests for notification batches.
✨ 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-14934/Add-E2E-tests-for-notifications-batches-endpoints

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions
Copy link

github-actions bot commented Dec 18, 2025

Warnings
⚠️

This PR contains 2 commits.

Please squash them into a single commit to keep the git history clean and easy to follow.

Multiple commits are acceptable only in the following cases:

  1. One commit is a technical refactoring, and another introduces business logic changes.
  2. You are doing a complex multi-step refactoring (although in this case we still recommend splitting it into separate PRs).

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

Generated by 🚫 dangerJS against 0a8eb2e

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

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f96cd68 and 0a8eb2e.

📒 Files selected for processing (9)
  • e2e_config.test.json (1 hunks)
  • mpt_api_client/resources/notifications/batches.py (3 hunks)
  • tests/e2e/notifications/batch/conftest.py (1 hunks)
  • tests/e2e/notifications/batch/test_async_batches.py (1 hunks)
  • tests/e2e/notifications/batch/test_batches.py (1 hunks)
  • tests/e2e/notifications/categories/test_async_categories.py (2 hunks)
  • tests/e2e/notifications/categories/test_sync_categories.py (2 hunks)
  • tests/e2e/notifications/conftest.py (1 hunks)
  • tests/unit/resources/notifications/test_batches.py (0 hunks)
💤 Files with no reviewable changes (1)
  • tests/unit/resources/notifications/test_batches.py
🧰 Additional context used
🧠 Learnings (2)
📚 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/notifications/batch/test_batches.py
  • tests/e2e/notifications/batch/test_async_batches.py
  • tests/e2e/notifications/categories/test_sync_categories.py
  • tests/e2e/notifications/batch/conftest.py
  • tests/e2e/notifications/conftest.py
  • tests/e2e/notifications/categories/test_async_categories.py
📚 Learning: 2025-11-27T00:05:36.356Z
Learnt from: robcsegal
Repo: softwareone-platform/mpt-api-python-client PR: 131
File: tests/e2e/conftest.py:0-0
Timestamp: 2025-11-27T00:05:36.356Z
Learning: When reviewing PRs that add fixtures to a parent conftest that may duplicate fixtures in child conftest files, do not suggest removing the duplicates from child conftest files that are outside the scope of the PR's changes.

Applied to files:

  • tests/e2e/notifications/conftest.py
🧬 Code graph analysis (6)
tests/e2e/notifications/batch/test_batches.py (4)
mpt_api_client/rql/query_builder.py (1)
  • RQLQuery (115-524)
tests/e2e/notifications/batch/conftest.py (3)
  • batch_service (5-6)
  • batch_data (20-26)
  • batch_id (15-16)
mpt_api_client/models/model.py (1)
  • id (119-121)
tests/e2e/conftest.py (1)
  • logo_fd (111-113)
tests/e2e/notifications/categories/test_sync_categories.py (4)
tests/e2e/notifications/categories/test_async_categories.py (2)
  • test_get_category (25-30)
  • test_filter_categories (46-52)
tests/e2e/conftest.py (1)
  • mpt_client (43-44)
tests/e2e/notifications/conftest.py (1)
  • category_id (5-6)
mpt_api_client/models/model.py (1)
  • id (119-121)
tests/e2e/notifications/batch/conftest.py (2)
tests/e2e/conftest.py (4)
  • mpt_ops (31-32)
  • async_mpt_ops (36-39)
  • e2e_config (89-92)
  • short_uuid (101-102)
tests/e2e/notifications/conftest.py (1)
  • category_id (5-6)
tests/e2e/notifications/conftest.py (1)
tests/e2e/conftest.py (1)
  • e2e_config (89-92)
mpt_api_client/resources/notifications/batches.py (3)
mpt_api_client/http/mixins.py (5)
  • AsyncCreateFileMixin (187-216)
  • AsyncGetMixin (380-395)
  • CollectionMixin (509-575)
  • CreateFileMixin (115-144)
  • GetMixin (361-377)
mpt_api_client/models/file_model.py (1)
  • FileModel (6-55)
mpt_api_client/models/model.py (1)
  • Model (65-125)
tests/e2e/notifications/categories/test_async_categories.py (5)
tests/e2e/notifications/categories/test_sync_categories.py (3)
  • test_create_category (20-23)
  • test_get_category (26-31)
  • test_filter_categories (48-54)
tests/e2e/notifications/categories/conftest.py (1)
  • category_data (5-10)
tests/e2e/conftest.py (1)
  • async_mpt_vendor (24-27)
tests/e2e/notifications/conftest.py (1)
  • category_id (5-6)
mpt_api_client/models/model.py (1)
  • id (119-121)
🪛 Ruff (0.14.8)
tests/e2e/notifications/batch/test_batches.py

33-33: Unused noqa directive (unknown: AAA01)

Remove unused noqa directive

(RUF100)

tests/e2e/notifications/categories/test_async_categories.py

20-20: Unused noqa directive (unknown: AAA01)

Remove unused noqa directive

(RUF100)

⏰ 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 (16)
mpt_api_client/resources/notifications/batches.py (4)

28-28: Excellent refactoring to standardize file upload handling.

The integration of CreateFileMixin[Batch] cleanly delegates file upload logic to a reusable mixin, replacing the previous explicit implementation. The mixin is properly positioned first in the inheritance chain and correctly parameterized.


54-54: Async mixin integration mirrors sync implementation well.

The AsyncCreateFileMixin[Batch] integration maintains consistency with the synchronous service, providing the same file upload capabilities in an async context.


4-10: The imports are correct. This is a new file, not modifications to existing code.

The entire batches.py file was created in this commit, including the get_batch_attachment methods that use FileModel. The FileModel import on line 10 is appropriately included as part of the new file and is not fixing a missing import. All imports are properly ordered and necessary for the new service classes and methods.

Likely an incorrect or invalid review comment.


23-24: The multipart form data key configuration requires verification against the SoftwareOne MPT notifications batches API specification.

The configuration defines _upload_file_key = "attachment" and _upload_data_key = "batch" for multipart uploads to the /public/v1/notifications/batches endpoint. These keys must match the exact parameter names expected by the API. Verify these values against the official SoftwareOne Marketplace Platform API documentation for the notifications batches endpoint, or confirm through integration tests that the API accepts requests structured with these keys.

e2e_config.test.json (1)

49-50: LGTM!

The new configuration entries properly support the E2E test fixtures for batch and category operations.

tests/e2e/notifications/conftest.py (1)

1-6: LGTM!

The fixture correctly extracts the category ID from the E2E configuration, enabling tests to reference a stable category without dynamic creation.

tests/e2e/notifications/batch/test_batches.py (4)

6-11: LGTM!

The skip marker is appropriate given the constraint that batches cannot be deleted.


13-16: LGTM!

The test correctly validates batch retrieval by ID.


19-23: LGTM!

The test correctly validates RQL-based filtering by batch ID.


26-30: LGTM!

The skip marker is appropriate, and the test demonstrates the new file upload capability for batch creation.

tests/e2e/notifications/batch/test_async_batches.py (1)

1-36: LGTM!

The async batch tests correctly mirror the synchronous versions with proper async/await usage. The async comprehension on line 20 is appropriately used for the async iterator.

tests/e2e/notifications/batch/conftest.py (1)

1-26: LGTM!

The fixtures are well-structured and follow the established patterns in the project. The batch_data fixture properly generates unique test data using the short_uuid to avoid conflicts.

tests/e2e/notifications/categories/test_async_categories.py (2)

25-30: LGTM!

The refactoring to use a stable category_id from config is appropriate for E2E tests and avoids the overhead of creating/deleting categories.


46-52: LGTM!

The refactoring to filter directly by category_id using RQL is more efficient than the previous approach. The async comprehension is properly used.

tests/e2e/notifications/categories/test_sync_categories.py (2)

26-31: LGTM!

The refactoring to use category_id from config aligns with the async test changes and provides a more stable test approach.


48-54: LGTM!

The RQL-based filtering correctly uses category_id, mirroring the improvements in the async version.

Comment on lines +33 to +36
@pytest.mark.skip(reason="Batches attachments not implemented") # noqa: AAA01
def test_download_attachment():
# TODO - Implement get and download E2E tests for attachment
raise NotImplementedError
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove unused noqa directive.

The # noqa: AAA01 directive references an unknown linting code and should be removed.

🔎 Apply this diff to remove the unused directive:
-@pytest.mark.skip(reason="Batches attachments not implemented")  # noqa: AAA01
+@pytest.mark.skip(reason="Batches attachments not implemented")
 def test_download_attachment():
     # TODO - Implement get and download E2E tests for attachment
     raise NotImplementedError
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@pytest.mark.skip(reason="Batches attachments not implemented") # noqa: AAA01
def test_download_attachment():
# TODO - Implement get and download E2E tests for attachment
raise NotImplementedError
@pytest.mark.skip(reason="Batches attachments not implemented")
def test_download_attachment():
# TODO - Implement get and download E2E tests for attachment
raise NotImplementedError
🧰 Tools
🪛 Ruff (0.14.8)

33-33: Unused noqa directive (unknown: AAA01)

Remove unused noqa directive

(RUF100)

🤖 Prompt for AI Agents
In tests/e2e/notifications/batch/test_batches.py around lines 33 to 36, the test
function has an unused lint suppression comment "# noqa: AAA01" that references
a nonexistent rule; remove that noqa directive so the line reads simply
@pytest.mark.skip(reason="Batches attachments not implemented") and keep the
rest of the test (TODO and raise) unchanged.

Comment on lines +20 to 22
def test_create_category(async_created_category, category_data): # noqa: AAA01
assert async_created_category.name == category_data["name"]
assert async_created_category.description == category_data["description"]
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove unused noqa directive.

The # noqa: AAA01 directive references an unknown linting code and should be removed.

🔎 Apply this diff to remove the unused directive:
-def test_create_category(async_created_category, category_data):  # noqa: AAA01
+def test_create_category(async_created_category, category_data):
     assert async_created_category.name == category_data["name"]
     assert async_created_category.description == category_data["description"]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def test_create_category(async_created_category, category_data): # noqa: AAA01
assert async_created_category.name == category_data["name"]
assert async_created_category.description == category_data["description"]
def test_create_category(async_created_category, category_data):
assert async_created_category.name == category_data["name"]
assert async_created_category.description == category_data["description"]
🧰 Tools
🪛 Ruff (0.14.8)

20-20: Unused noqa directive (unknown: AAA01)

Remove unused noqa directive

(RUF100)

🤖 Prompt for AI Agents
In tests/e2e/notifications/categories/test_async_categories.py around lines 20
to 22, the test function declaration contains an unused noqa directive "# noqa:
AAA01"; remove that directive from the function definition so the line reads
without the trailing comment, leaving the test intact and ensuring no unknown
linter code is suppressed.

@sonarqubecloud
Copy link

@d3rky d3rky merged commit 7748860 into main Dec 18, 2025
6 checks passed
@d3rky d3rky deleted the e2e/MPT-14934/Add-E2E-tests-for-notifications-batches-endpoints branch December 18, 2025 15:22
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