Skip to content

[MPT-20323] Added endpoints and e2e tests for program programs#302

Merged
robcsegal merged 1 commit intomainfrom
MPT-20323-add-endpoints-and-e-2-e-tests-for-programs
Apr 16, 2026
Merged

[MPT-20323] Added endpoints and e2e tests for program programs#302
robcsegal merged 1 commit intomainfrom
MPT-20323-add-endpoints-and-e-2-e-tests-for-programs

Conversation

@robcsegal
Copy link
Copy Markdown
Contributor

@robcsegal robcsegal commented Apr 15, 2026

This pull request introduces a new "Program" resource to the API client, including both sync and async support, resource mixins for publish/unpublish actions, and comprehensive tests. It also updates configuration and test files to integrate the new resource.

New Program Resource Integration

  • Added Program and AsyncProgram modules to the client, exposing them through the main MPTClient and AsyncMPTClient interfaces. [1] [2] [3] [4] [5] [6] [7] [8] [9]

Program Service and Model

  • Implemented ProgramsService and AsyncProgramsService with full CRUD, file upload, publish/unpublish, and settings update capabilities for the Program model. The model includes attributes such as name, website, eligibility, and vendor.
  • Added a PublishableMixin and AsyncPublishableMixin to encapsulate publish/unpublish logic for resources, and exposed them in the package. [1] [2]

Testing

  • Added end-to-end and unit tests covering all major Program resource actions, including create, update, get, filter/select, delete, publish, and unpublish, for both sync and async clients. [1] [2] [3] [4] [5]
  • Updated test configuration and ignores to include the new resource. [1] [2]

These changes collectively provide a robust, fully tested "Program" resource in the API client with all standard and custom actions.

Closes MPT-20323

Release Notes

  • Added Program and AsyncProgram resource classes with full API client integration
  • Implemented ProgramsService and AsyncProgramsService providing CRUD operations, file upload support, and settings management
  • Added PublishableMixin and AsyncPublishableMixin to encapsulate publish/unpublish operations for the Program resource
  • Exposed new program property on both MPTClient and AsyncMPTClient for accessing program operations
  • Added update_settings() method to manage program-specific configuration via dedicated API endpoint
  • Comprehensive end-to-end test coverage for create, read, update, delete, filter, select, publish, and unpublish operations in both sync and async contexts
  • Unit tests for service methods, mixin functionality, and model field handling
  • Updated test configuration with new program test identifier and Flake8 ignore rules for program test files

@robcsegal robcsegal requested a review from a team as a code owner April 15, 2026 21:23
@robcsegal robcsegal requested review from albertsola and d3rky April 15, 2026 21:23
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 15, 2026

📝 Walkthrough

Walkthrough

This pull request introduces a new Program resource to the MPT API client. It adds client accessor properties, defines the Program resource package with service classes and publishable mixins, updates test configuration, and includes comprehensive unit and end-to-end tests for the new functionality.

Changes

Cohort / File(s) Summary
Configuration Updates
e2e_config.test.json, pyproject.toml
Added program test ID to E2E configuration and extended Flake8 per-file ignore rules for program test files.
Client Resource Exposure
mpt_api_client/mpt_client.py, mpt_api_client/resources/__init__.py
Added program property accessors to MPTClient and AsyncMPTClient classes, and re-exported Program and AsyncProgram from the resources module.
Program Resource Implementation
mpt_api_client/resources/program/__init__.py, mpt_api_client/resources/program/program.py, mpt_api_client/resources/program/programs.py, mpt_api_client/resources/program/mixins/__init__.py, mpt_api_client/resources/program/mixins/publishable_mixin.py
Implemented new Program resource package with Program and AsyncProgram resource classes, ProgramsService and AsyncProgramsService service classes with update_settings() method, and PublishableMixin / AsyncPublishableMixin for publish() and unpublish() operations.
Unit Tests
tests/unit/resources/program/*, tests/unit/test_mpt_client.py
Added unit test coverage for Program resource classes, services (including update_settings and file uploads), publishable mixins, and extended client tests to validate program accessor.
E2E Tests
tests/e2e/program/conftest.py, tests/e2e/program/program/conftest.py, tests/e2e/program/program/test_async_program.py, tests/e2e/program/program/test_sync_program.py
Added end-to-end test fixtures and test suites for synchronous and asynchronous Program operations including create, update, get, filter/select, delete, publish, and unpublish.

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 (MPT-20323) in the required format at the beginning.
Test Coverage Required ✅ Passed The PR modifies 9 code files and includes 8 comprehensive test files covering new Program resource functionality.
Single Commit Required ✅ Passed The PR contains exactly one commit (458aeea: Added endpoints and e2e tests for program programs) as verified by git log output, satisfying the clean git history requirement.

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

@sonarqubecloud
Copy link
Copy Markdown

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/program/program/test_sync_program.py (1)

55-61: Strengthen the delete test with a post-delete assertion.

Right now this only verifies the call path. Consider asserting a follow-up get fails to confirm the resource is actually gone.

Suggested enhancement
 def test_delete_program(mpt_vendor, created_program):
-    program_data = created_program
-
-    result = mpt_vendor.program.programs
-
-    result.delete(program_data.id)
+    mpt_vendor.program.programs.delete(created_program.id)
+    with pytest.raises(MPTAPIError):
+        mpt_vendor.program.programs.get(created_program.id)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/e2e/program/program/test_sync_program.py` around lines 55 - 61, The
test_delete_program currently only calls result.delete(program_data.id); after
that call, perform a follow-up verification by attempting to retrieve the
deleted program with result.get(program_data.id) and assert the expected failure
(e.g., raise a NotFound/HTTP 404 exception or return None) to confirm the
resource was actually removed; update the test_delete_program to catch the
expected exception or assert the not-found response accordingly.
tests/e2e/program/program/test_async_program.py (1)

55-61: Strengthen the delete test to assert actual deletion.

The test currently passes if delete() does not raise, but it does not verify that the resource is truly gone. Prefer asserting the post-delete read fails.

Suggested refactor
 async def test_delete_program(async_mpt_vendor, created_program):
-    program_data = created_program
-
-    result = async_mpt_vendor.program.programs
-
-    await result.delete(program_data.id)
+    await async_mpt_vendor.program.programs.delete(created_program.id)
+    with pytest.raises(MPTAPIError):
+        await async_mpt_vendor.program.programs.get(created_program.id)

Based on learnings: “Reserve isolated fixtures for destructive tests that require per-test creation and cleanup.”

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

In `@tests/e2e/program/program/test_async_program.py` around lines 55 - 61, The
test_delete_program currently only calls
async_mpt_vendor.program.programs.delete(created_program.id) and doesn't verify
deletion; update test_delete_program to assert the resource is gone by
attempting to read/fetch the program after deletion (e.g., call
async_mpt_vendor.program.programs.get or fetch by id) and assert it raises the
expected NotFound/HTTPError or returns a 404/None result; also switch to an
isolated/per-test fixture for created_program if this is destructive to avoid
affecting other tests. Use the symbols test_delete_program,
async_mpt_vendor.program.programs, delete, and created_program.id to locate and
change the test.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pyproject.toml`:
- Line 151: Add the missing production per-file-ignores entry for the program
resource by adding the pattern "mpt_api_client/resources/program/*.py: WPS202
WPS210 WPS218" to the pyproject.toml alongside the existing
"tests/unit/resources/program/*.py: WPS202 WPS210 WPS218" entry; ensure the new
entry uses the same three rules (WPS202, WPS210, WPS218) and matches the
formatting of the other resource production entries (e.g., accounts, billing) so
lint configuration remains consistent.

---

Nitpick comments:
In `@tests/e2e/program/program/test_async_program.py`:
- Around line 55-61: The test_delete_program currently only calls
async_mpt_vendor.program.programs.delete(created_program.id) and doesn't verify
deletion; update test_delete_program to assert the resource is gone by
attempting to read/fetch the program after deletion (e.g., call
async_mpt_vendor.program.programs.get or fetch by id) and assert it raises the
expected NotFound/HTTPError or returns a 404/None result; also switch to an
isolated/per-test fixture for created_program if this is destructive to avoid
affecting other tests. Use the symbols test_delete_program,
async_mpt_vendor.program.programs, delete, and created_program.id to locate and
change the test.

In `@tests/e2e/program/program/test_sync_program.py`:
- Around line 55-61: The test_delete_program currently only calls
result.delete(program_data.id); after that call, perform a follow-up
verification by attempting to retrieve the deleted program with
result.get(program_data.id) and assert the expected failure (e.g., raise a
NotFound/HTTP 404 exception or return None) to confirm the resource was actually
removed; update the test_delete_program to catch the expected exception or
assert the not-found response accordingly.
🪄 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: e17c454b-59b5-4e89-8ff4-f4ae535aa5ee

📥 Commits

Reviewing files that changed from the base of the PR and between 9f3cf9c and 458aeea.

📒 Files selected for processing (18)
  • e2e_config.test.json
  • mpt_api_client/mpt_client.py
  • mpt_api_client/resources/__init__.py
  • mpt_api_client/resources/program/__init__.py
  • mpt_api_client/resources/program/mixins/__init__.py
  • mpt_api_client/resources/program/mixins/publishable_mixin.py
  • mpt_api_client/resources/program/program.py
  • mpt_api_client/resources/program/programs.py
  • pyproject.toml
  • tests/e2e/program/__init__.py
  • tests/e2e/program/conftest.py
  • tests/e2e/program/program/conftest.py
  • tests/e2e/program/program/test_async_program.py
  • tests/e2e/program/program/test_sync_program.py
  • tests/unit/resources/program/mixin/test_publishable_mixin.py
  • tests/unit/resources/program/test_program.py
  • tests/unit/resources/program/test_programs.py
  • tests/unit/test_mpt_client.py

Comment thread pyproject.toml
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