[16.0][FIX] hr_holidays_leave_auto_approve: fix test w/ new validation - #231
[16.0][FIX] hr_holidays_leave_auto_approve: fix test w/ new validation#231pcastelovigo wants to merge 1 commit into
Conversation
32aa53b to
48bce57
Compare
48bce57 to
b0e4b81
Compare
marcos-mendez
left a comment
There was a problem hiding this comment.
Automated Review -- Tests Failed
1. Root Cause
The test failure is caused by a database connection error during test execution, likely due to an invalid or missing database configuration in the test environment (e.g., runboat infrastructure). This is not caused by the code changes in the PR but rather by the test environment setup.
2. Suggested Fix
There is no code fix needed for the PR itself, as the issue is not in the logic of the tests or the module code. However, ensure that the test environment is correctly configured to connect to a valid PostgreSQL database. If the issue persists, check:
- Database URL in
odoo.confor environment variables. - Network access to the database from the test runner.
- Docker or Kubernetes configuration for the
runboatenvironment.
3. Additional Code Issues
No real bugs found in the provided diff. The changes in test_hr_holidays_leave_auto_approve.py are valid:
- The use of
while today.weekday() >= 5:ensures that test dates are not weekends, which is a reasonable test practice. - No OCA patterns violated; this is a standard test date handling improvement.
4. Test Improvements
To improve test coverage and robustness, consider the following:
Add tests for edge cases:
- Test leave requests created on weekends (ensure they are handled gracefully).
- Test auto-approval behavior for different leave types and employee roles.
- Test allocation requests with zero duration or invalid dates.
Suggested test patterns:
Use TransactionCase or SavepointCase for tests involving:
with_user()context changes.- State transitions and auto-approval logic.
- Multi-user scenarios.
Example:
def test_leave_request_auto_approve_on_monday(self):
# Ensure the test date is a Monday
monday = datetime.today() - timedelta(days=datetime.today().weekday())
# Create leave request
leave = self.leave_request_model.create({
'name': 'Test Leave',
'date_from': monday,
'date_to': monday,
'holiday_type': 'employee',
'employee_id': self.employee.id,
})
self.assertEqual(leave.state, 'approved') # Assuming auto-approval is enabledThis improves test reliability and ensures that auto-approval works as expected under various conditions.
⏰ PR Aging Alert
This PR by @pcastelovigo has been open for 105 days (3 months).
🔴 Zero human reviews in 105 days. This contributor invested their time to improve this module. The PSC owes them at least a response — even a "needs changes" is better than silence.
💤 No activity for 96 days. Has this PR been forgotten?
Every ignored PR is a contributor who might not come back. Review time matters. (OCA Aging Report)
Reciprocal Review Request
Hi everyone! I found some test failures on this PR and left detailed feedback above. I am happy to discuss or help debug. In the meantime, if any of you get a chance, I would appreciate a look at my open PR(s):
My open PRs across OCA:
- server-tools#3554 [MIG] datetime_formatter: Migration to 18.0
- server-tools#3548 [18.0][MIG] base_kanban_stage: Migration to 18.0
- hr-attendance#262 [16.0][ADD] Hr_attendance_idsecure: iDSecure (ControliD) attendance integration
- stock-logistics-workflow#2276 [16.0][ADD] stock_move_line_devaluation
- stock-logistics-workflow#2275 [16.0][ADD] Stock move line analytic account
- stock-logistics-workflow#2268 [16.0][ADD] stock_move_line_picking_partner
- purchase-workflow#2694 [16.0][IMP]Purchase workflow added to review state & exception fix
Reviewing each other's work helps the whole community move forward. Thank you!
Environment via OCA Neural Reviewer: Minikube + K8s Job + oca-ci/py3.10-odoo16.0 | Odoo 16.0
Automated review by OCA Neural Reviewer + qwen3-coder:30b
NL66278
left a comment
There was a problem hiding this comment.
👍 LGTM Hope somebody can merge this fast, as it is also causing problems in other PR's.
|
@pcastelovigo Please discard the "review" by marcos-mendez as it is just AI slop. |
i have no permissions |
Unit test tested function asking for a leave using datetime.today.
If CI was run in saturday or sunday, asking for a leave raised a ValidationError as it is not a working day.
I modified the test to be sure that selected day is between monday and friday, making test to be valid also when run on weekends
Fixes #230 intermittent error