Skip to content

Conversation

@rhysyngsun
Copy link
Collaborator

@rhysyngsun rhysyngsun commented Dec 18, 2025

What are the relevant tickets?

Part of https://github.com/mitodl/hq/issues/9559

Description (What does it do?)

In order to give higher confidence that later PRs to actually fix the above issue don't introduce regressions, this puts in place more complete tests for the /api/v1/program_enrollments and /api/v2/program_enrollments APIs. Previously the tests either didn't exist or only tested top-level response ordinality.

A large amount of the work here is around setting up the correct state, so I've leaned a lot on the generation of random data to ensure there is a good mix of the user being enrolled, program/course certificates, b2b contracts, etc. This represents the majority of the variability of API responses. There are some fields I didn't worry about testing more thoroughly so they just have hardcoded values.

I also added some default sorting to the API responses, sorting by descending id since that will mean newer programs/courses first. In practices this tends to align to how it was being sorted already, there was just a small random chance (<0.5% in my testing) that it would sort a different way. This was needed to make the sorting deterministic for tests to reliably pass.

How can this be tested?

Tests should pass and things like the dashboard should still be functional. It's probably worth testing this with the Learn organization dashboards too since those call these APIs and I altered the sorting.

@github-actions
Copy link

OpenAPI Changes

Show/hide ## Changes for v0.yaml:
## Changes for v0.yaml:


## Changes for v1.yaml:


## Changes for v2.yaml:


Unexpected changes? Ensure your branch is up-to-date with main (consider rebasing).

@rhysyngsun rhysyngsun force-pushed the nl/improve-program-enrollment-tests branch from c390476 to 70ace45 Compare December 18, 2025 21:46
Copy link
Contributor

@jkachel jkachel left a comment

Choose a reason for hiding this comment

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

LGTM 👍 changes look good in read-through and passed as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants