Skip to content

MPT-20330: Added endpoints and e2e tests for program terms variants#314

Merged
robcsegal merged 1 commit intomainfrom
MPT-20330-add-endpoints-and-e-2-e-tests-for-program-terms-and-conditions-variant
Apr 20, 2026
Merged

MPT-20330: Added endpoints and e2e tests for program terms variants#314
robcsegal merged 1 commit intomainfrom
MPT-20330-add-endpoints-and-e-2-e-tests-for-program-terms-and-conditions-variant

Conversation

@robcsegal
Copy link
Copy Markdown
Contributor

@robcsegal robcsegal commented Apr 20, 2026

This pull request introduces support for managing program term variants in the API client, including both synchronous and asynchronous services, comprehensive unit and end-to-end tests, and updates to test configurations. The changes add the ability to create, update, delete, retrieve, publish, and unpublish term variants, as well as to handle file uploads and online asset URLs.

Program Term Variant Service Implementation:

  • Added TermVariant model and both TermVariantService (sync) and AsyncTermVariantService (async) classes in programs_terms_variant.py, supporting CRUD, file upload/download, and publish/unpublish operations for program term variants.
  • Integrated the new variant services into TermService and AsyncTermService via a .variants(term_id) method, enabling access to term variants from the term services. [1] [2]

Testing Enhancements:

  • Added comprehensive unit tests for the new variant services and model in test_programs_terms_variant.py, verifying endpoints, methods, and model fields.
  • Introduced end-to-end test fixtures and test cases for both synchronous and asynchronous term variant operations, covering creation (by file and by URL), update, delete, retrieval, filtering, and publish/unpublish flows. [1] [2] [3]

Configuration and Integration:

  • Updated e2e_config.test.json to include a program.terms.variant.id for use in E2E tests.
  • Added imports and property tests for the new services in test_programs_terms.py, ensuring correct service instantiation and endpoint parameter handling. [1] [2]

These changes collectively provide a robust foundation for managing program term variants through the API client, with thorough test coverage and seamless integration into existing service structures.

Closes MPT-20330

  • Added TermVariant model representing term-variant metadata (name, type, language code, description, status, asset URL, file info, program_terms_and_conditions, audit)
  • Implemented TermVariantService (sync) and AsyncTermVariantService (async) with full CRUD, file upload/download, online asset (URL) handling, and publish/unpublish operations
  • Exposed variant services via .variants(term_id) on TermService and AsyncTermService
  • Added unit tests for service instantiation, endpoint routing, method availability, and model serialization/behavior
  • Added E2E tests (sync and async) covering create (file and URL), update, delete, retrieve, filter/select, and publish/unpublish flows; included fixtures and teardown handling
  • Updated e2e_config.test.json to include program.terms.variant.id for E2E tests

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

coderabbitai Bot commented Apr 20, 2026

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: 251ffd46-ea98-4c75-860f-f14a9e1f1ec0

📥 Commits

Reviewing files that changed from the base of the PR and between f763bef and 4fde121.

📒 Files selected for processing (8)
  • e2e_config.test.json
  • mpt_api_client/resources/program/programs_terms.py
  • mpt_api_client/resources/program/programs_terms_variant.py
  • tests/e2e/program/program/term/variant/conftest.py
  • tests/e2e/program/program/term/variant/test_async_variant.py
  • tests/e2e/program/program/term/variant/test_sync_variant.py
  • tests/unit/resources/program/test_programs_terms.py
  • tests/unit/resources/program/test_programs_terms_variant.py
✅ Files skipped from review due to trivial changes (3)
  • e2e_config.test.json
  • tests/e2e/program/program/term/variant/conftest.py
  • tests/unit/resources/program/test_programs_terms_variant.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • mpt_api_client/resources/program/programs_terms.py
  • tests/unit/resources/program/test_programs_terms.py
  • mpt_api_client/resources/program/programs_terms_variant.py

📝 Walkthrough

Walkthrough

Adds TermVariant model and sync/async services, exposes .variants(term_id) on TermService/AsyncTermService, updates E2E config with a variant id, and introduces unit and E2E tests covering variant lifecycle and publish/unpublish behavior.

Changes

Cohort / File(s) Summary
Test Configuration
e2e_config.test.json
Added program.terms.variant.id with value PTV-9643-3741-0001-0001 (adjusted JSON to include new field).
Term Service Extension
mpt_api_client/resources/program/programs_terms.py
Added variants(term_id) accessor methods to TermService and AsyncTermService to return variant service instances with correct http_client and endpoint_params.
Variant Resource Module
mpt_api_client/resources/program/programs_terms_variant.py
Introduced TermVariant model, TermVariantServiceConfig, and both TermVariantService and AsyncTermVariantService (collection, file upload/download, modify, publish/unpublish behavior).
E2E Test Fixtures
tests/e2e/program/program/term/variant/conftest.py
Added fixtures: variant_id (reads new config key), invalid_variant_id, and variant_data_factory for generating payloads.
E2E Variant Tests
tests/e2e/program/program/term/variant/test_async_variant.py, tests/e2e/program/program/term/variant/test_sync_variant.py
Added flaky E2E test suites (async & sync) covering create (file and URL), update, delete, get, RQL filter/select, and publish/unpublish flows with teardown handling.
Unit Tests
tests/unit/resources/program/test_programs_terms.py, tests/unit/resources/program/test_programs_terms_variant.py
Added unit tests verifying variants() returns correct service type and endpoint params, variant service paths and methods, and TermVariant model serialization and nested field handling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Jira Issue Key In Title ✅ Passed PR title contains the Jira issue key MPT-20330 in the required MPT-XXXX format.
Test Coverage Required ✅ Passed The PR modifies 3 code/config files and includes comprehensive changes across 5 test files, satisfying the test file requirement.
Single Commit Required ✅ Passed The pull request contains exactly one commit (4fde121 Added endpoints and e2e tests for program terms variants), meeting the requirement for a single commit.

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

@robcsegal robcsegal force-pushed the MPT-20330-add-endpoints-and-e-2-e-tests-for-program-terms-and-conditions-variant branch from f763bef to 4fde121 Compare April 20, 2026 15:22
@sonarqubecloud
Copy link
Copy Markdown

@robcsegal robcsegal merged commit 3acc285 into main Apr 20, 2026
4 checks passed
@robcsegal robcsegal deleted the MPT-20330-add-endpoints-and-e-2-e-tests-for-program-terms-and-conditions-variant branch April 20, 2026 15:35
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