Skip to content

Add unit tests for lunch constraint generator - #6129

Open
amandubey-agastya wants to merge 8 commits into
learning-unlimited:mainfrom
amandubey-agastya:issue-4922-lunch-tests
Open

amandubey-agastya wants to merge 8 commits into
learning-unlimited:mainfrom
amandubey-agastya:issue-4922-lunch-tests

Conversation

@amandubey-agastya

@amandubey-agastya amandubey-agastya commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds unit tests for the lunch constraint generator to verify its initialization, timeslot handling, constraint generation, and autocorrection behavior. Also verifies that lunch timeslots are processed in chronological order.

These tests help improve test coverage and catch regressions in lunch constraint generation.

Related Issue

Closes #4922

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Refactor / cleanup
  • CI/CD or build change

Testing

  • Existing tests pass

  • New tests added (if applicable)

  • Manually verified

  • Ran the lunch constraint generator unit tests.

  • Verified that all 24 tests pass locally.

Checklist

  • Self-reviewed the code
  • Updated documentation (if needed)
  • No new warnings or errors introduced

Summary by CodeRabbit

  • Tests
    • Added comprehensive automated coverage for lunch constraint generation.
    • Added tests for timeslot ordering, token combinations, lunch categories, subjects, sections, failure handling, cleanup, and conditional constraints.
    • Added validation for defaults, fallback class sizes, persistence behavior, statuses, labels, token ordering, and disabled conditions.

Copilot AI left a comment

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.

🟢 Approval recommended

No blocking issues were identified in the test-only changes; tests were not executed during review.

No open issues 🎉

What changed in this PR

Adds unit coverage for LunchConstraintGenerator, supporting issue #4922 without changing production behavior.

Changes:

  • Tests initialization, chronological lunch ordering, and day grouping.
  • Covers lunch category, subject, and section lookup and creation.
  • Checks expression construction, constraint cleanup and generation, and failure callback contents.
File Description
esp/​esp/​program/​controllers/​test_lunch_constraints.py Adds mock-based tests for lunch constraint generation and supporting operations.

Review effort: Balanced

@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 679d3ee1-b5d6-4635-9a4a-c2e94a422f58
Commits

Reviewing files that changed from the base of the PR and between 285d221 and e6b39d7.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review.

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a32768be-661b-43c2-9923-a96885e05a49
📥 Commits

Reviewing files that changed from the base of the PR and between 8e12000 and f15302b.

📒 Files selected for processing: 1
  • esp/esp/program/controllers/test_lunch_constraints.py

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

This change adds unit tests for LunchConstraintGenerator. The tests cover setup, expression construction, lunch-related object handling, cleanup, generation orchestration, and schedule constraint creation.

Changes: Lunch constraint controller tests

Layer / File(s) Summary
Setup and expression tests
esp/esp/program/controllers/test_lunch_constraints.py
Tests cover timeslot grouping and sorting, generator options, binary expression construction, and lunch category and subject reuse or creation.
Section creation, callbacks, and cleanup
esp/esp/program/controllers/test_lunch_constraints.py
Tests cover lunch section creation or reactivation, failure callback contents, and cleanup of generated sections, subjects, expressions, and constraints.
Constraint generation and orchestration
esp/esp/program/controllers/test_lunch_constraints.py
Tests cover generation by day, disabled-generation behavior, requirement and condition creation, persistence, and schedule-test wiring.

Priority: Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Other

Possibly related issues

  • learning-unlimited/ESP-Website#5786 — The issue concerns test placement and naming standards for program code, which overlap with the added controller test file.
Merge Risk: Minimal · previous review f1530

The added lunch-constraint tests are ready to merge after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 29 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: adding unit tests for the lunch constraint generator.
Linked Issues check Passed The PR implements the coding requirements in issue #4922. The new test module covers initialization flags, day and lunch-timeslot grouping and ordering, constraint cleanup, binary expression edge case…
Out of Scope Changes check Passed The PR adds only esp/esp/program/controllers/test_lunch_constraints.py. The test cases directly support the unit-test and regression-coverage objective in issue #4922. No unrelated production, docum…
Full details: Linked Issues check

Explanation

The PR implements the coding requirements in issue #4922. The new test module covers initialization flags, day and lunch-timeslot grouping and ordering, constraint cleanup, binary expression edge cases, lunch category and subject lookup or creation, section creation and reactivation, failure callbacks, and single-day and multi-day constraint generation. The tests also cover conditional generation and persistence details described by the issue. Parent issue #3780 provides context only.

Full details: Out of Scope Changes check

Explanation

The PR adds only esp/esp/program/controllers/test_lunch_constraints.py. The test cases directly support the unit-test and regression-coverage objective in issue #4922. No unrelated production, documentation, or build changes are shown.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@willgearty

Copy link
Copy Markdown
Member

You have not addressed either of the comments from Copilot on your original PR (#6108)

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.

[Bug]: Add unit tests for LunchConstraintGenerator controller (0% coverage)

3 participants