Skip to content

Add morango integration tests for syncing new courses#14214

Merged
rtibbles merged 1 commit intolearningequality:release-v0.19.xfrom
bjester:morango-dynamic-filter-tests
Mar 10, 2026
Merged

Add morango integration tests for syncing new courses#14214
rtibbles merged 1 commit intolearningequality:release-v0.19.xfrom
bjester:morango-dynamic-filter-tests

Conversation

@bjester
Copy link
Copy Markdown
Member

@bjester bjester commented Feb 20, 2026

...and verifying the syncing functionality of the partitioning structure

Summary

  • Adds morango integration tests to verify syncing of courses
    • A full facility syncing verification to an existing test
    • A new single-user syncing test for courses
  • Tests verify that models are synced appropriately, including the verification of the models deserialize functionality, but also that the course partitioning structure is functioning appropriately.
  • The test_single_user_course_syncing was bootstrapped with an LLM, then corrected and added upon

References

closes #14131

Reviewer guidance

  • Does the module comment make sense? It is meant to help future devs and LLMs to write accurate tests
  • Do the tests make sense?

...and verifying the syncing functionality of the partitioning structure

Co-authored-by: ozer550 <prathameshd419@gmail.com>
@github-actions github-actions Bot added DEV: backend Python, databases, networking, filesystem... SIZE: medium labels Feb 20, 2026
@bjester bjester requested a review from rtibblesbot February 20, 2026 01:25
Copy link
Copy Markdown
Contributor

@rtibblesbot rtibblesbot left a comment

Choose a reason for hiding this comment

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

Well-structured integration tests for course model syncing — both the full-facility and single-user paths are covered with clear assertions.

CI passing. PR targets release-v0.19.x (not develop), which is fine since no new user-facing strings are added.

  • blocking: None
  • suggestion: One minor suggestion on the generate_base_data bug fix
  • praise: Good bug fix, thorough deserialize verification, helpful module docstring

@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly

How was this generated?

Reviewed the pull request diff checking for:

  • Correctness: bugs, edge cases, undocumented behavior, resource leaks, hardcoded values
  • Design: unnecessary complexity, naming, readability, comment accuracy, redundant state
  • Architecture: duplicated concerns, minimal interfaces, composition over inheritance
  • Testing: behavior-based assertions, mocks only at hard boundaries, accurate coverage
  • Completeness: missing dependencies, unupdated usages, i18n, accessibility, security
  • Principles: DRY (same reason to change), SRP, Rule of Three (no premature abstraction)
  • Checked CI status and linked issue acceptance criteria
  • For UI changes: inspected screenshots for layout, visual completeness, and consistency

)[0]
staff = FacilityUser.objects.using(self.db_alias).filter(
roles__isnull=True, devicepermissions=None
roles__kind=role_kinds.COACH, devicepermissions=None
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

praise: Good catch — the old filter (roles__isnull=True) was identical to the learner filter, so staff and learner could have been the same user. This fix correctly fetches a coach.

staff = FacilityUser.objects.using(self.db_alias).filter(
roles__isnull=True, devicepermissions=None
roles__kind=role_kinds.COACH, devicepermissions=None
)[0]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion: devicepermissions=None excludes device admins, but generateuserdata only creates one coach. If that coach happens to also have device permissions in a future change, this would return an empty queryset and [0] would raise IndexError. Consider adding an error message or using .first() with an assertion, similar to how facility uses .get(). Low priority since the test fixture is controlled.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm not too concerned about this since it's a test fixture. Also, if this were to break, it'd be better to fix what broke this than make this looser. A pure coach, without device permissions, is a worthwhile test fixture.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You're right — a loud failure is better than a loose assertion in a test fixture. Withdrawing this finding.

"""
Tests related specifically to integration with Morango.

When creating models for servers passed into test methods from the `multiple_kolibri_servers`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

praise: This module docstring is a great addition — the create_model vs direct ORM gotcha is exactly the kind of thing that trips people up when writing new integration tests.

s1.db_alias
).get(course_session_id=course_session.id, collection_id=classroom.id)

self.assertIsNone(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

praise: Verifying that deserialize correctly nullifies user FK fields on single-user sync (learner device) while preserving them on the coach device is exactly what the issue asked for — exercises both the partitioning structure and the deserialize logic in a single test.

Copy link
Copy Markdown
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

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

Test changes make sense, this is good to merge.

@rtibbles rtibbles merged commit c15a93e into learningequality:release-v0.19.x Mar 10, 2026
65 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DEV: backend Python, databases, networking, filesystem... SIZE: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants