From ca1ff19f550bcccfc806de785e24ca19cba1b76f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 4 Feb 2021 15:08:40 +0000 Subject: [PATCH] [FIX] hr_holidays: make ooo tests less dependent on channel_info members ordering Purpose of this test is to avoid failing tests due to list ordering not being always predictable in channel_info. Some out of office tests are dependent on channel_info ordering. Indeed one test relies on members list ordering (using [0] and [1]) instead of fetching the right member in the given result list. In this commit we * ensure members in channel_info effectively match expected members; * check content of the right channel info member instead of relying on list order; LINKS Task ID-2070632 (main task) Task ID-2419762 (followup task) COM PR odoo/odoo#62859 ENT PR odoo/enterprise#15172 UPG PR odoo/upgrade#2005 --- addons/hr_holidays/tests/test_out_of_office.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/hr_holidays/tests/test_out_of_office.py b/addons/hr_holidays/tests/test_out_of_office.py index ad316c7a38d..dae182c7fcd 100644 --- a/addons/hr_holidays/tests/test_out_of_office.py +++ b/addons/hr_holidays/tests/test_out_of_office.py @@ -52,8 +52,11 @@ class TestOutOfOffice(TestHrHolidaysCommon): 'name': 'test' }) channel_info = channel.channel_info()[0] - self.assertFalse(channel_info['members'][0]['out_of_office_date_end'], "current user should not be out of office") - self.assertEqual(channel_info['members'][1]['out_of_office_date_end'], leave_date_end, "correspondent should be out of office") + self.assertEqual(len(channel_info['members']), 2, "Channel info should get info for the 2 members") + partner_info = next(c for c in channel_info['members'] if c['email'] == partner.email) + partner2_info = next(c for c in channel_info['members'] if c['email'] == partner2.email) + self.assertFalse(partner2_info['out_of_office_date_end'], "current user should not be out of office") + self.assertEqual(partner_info['out_of_office_date_end'], leave_date_end, "correspondent should be out of office") @tagged('out_of_office')