From 8ddd6f12f2a937d06b545d60f93f6a5d6b3e8a81 Mon Sep 17 00:00:00 2001 From: "Antoine Vandevenne (anv)" Date: Tue, 9 Jan 2024 09:58:56 +0000 Subject: [PATCH] [FIX] payment: fix date for non-deterministic test When `test_display_name_for_empty_payment_details` was tested around midnight, the test would fail because it compares the current date with the token's create date, which would be the day before. closes odoo/odoo#148781 X-original-commit: 87f94715a09b7681bcd92d1cba4f84d30918c502 Signed-off-by: Antoine Vandevenne (anv) --- addons/payment/tests/test_payment_token.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/addons/payment/tests/test_payment_token.py b/addons/payment/tests/test_payment_token.py index 29b5695fe24..2b791c5388c 100644 --- a/addons/payment/tests/test_payment_token.py +++ b/addons/payment/tests/test_payment_token.py @@ -2,6 +2,8 @@ from datetime import date +from freezegun import freeze_time + from odoo.exceptions import AccessError, UserError, ValidationError from odoo.tests import tagged from odoo.tools import mute_logger @@ -37,9 +39,15 @@ class TestPaymentToken(PaymentCommon): token = self._create_token() self.assertEqual(token._build_display_name(), '•••• 1234') + @freeze_time('2024-1-31 10:00:00') def test_display_name_for_empty_payment_details(self): """ Test that the display name is still built for token without payment details. """ token = self._create_token(payment_details='') + self.env.cr.execute( + 'UPDATE payment_token SET create_date = %s WHERE id = %s', + params=(date.today(), token.id), + ) + token.invalidate_recordset(fnames=['create_date']) self.assertEqual( token._build_display_name(), f"Payment details saved on {date.today().strftime('%Y/%m/%d')}",