summaryrefslogtreecommitdiffstats
path: root/debian/patches/0022-Fix-findln-by-timestamp-test.patch
blob: 14e996c14c7f1953c231c8e4053e61407ce5cad2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
From ee77de8e8b2f9820303d9d049ad39ccf9fcc6ba3 Mon Sep 17 00:00:00 2001
From: xin liang <xliang@suse.com>
Date: Sun, 7 Apr 2024 09:46:13 +0800
Subject: [PATCH] Dev: unittest: Adjust unit test

Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1068562
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/crmsh/+bug/2060536
Forwarded: https://github.com/ClusterLabs/crmsh/pull/1379/commits/ee77de8e8b2f9820303d9d049ad39ccf9fcc6ba3
Last-Update: 2024-04-10
---
 test/unittests/test_report_utils.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

--- a/test/unittests/test_report_utils.py
+++ b/test/unittests/test_report_utils.py
@@ -816,7 +816,8 @@
 
     def test_findln_by_timestamp(self):
         target_time = "Apr 03 13:10"
-        target_time_stamp = crmutils.parse_to_timestamp(target_time+' 2023')
+        this_year = datetime.datetime.now().year
+        target_time_stamp = crmutils.parse_to_timestamp(target_time+' '+str(this_year))
         with open('pacemaker.log') as f:
             data = f.read()
         constants.STAMP_TYPE = utils.determin_log_format(data)
@@ -828,7 +829,7 @@
         assert result_pre_line_stamp < target_time_stamp
 
         target_time = "Apr 03 11:01:19"
-        target_time_stamp = crmutils.parse_to_timestamp(target_time+' 2023')
+        target_time_stamp = crmutils.parse_to_timestamp(target_time+' '+str(this_year))
         result_line = utils.findln_by_timestamp(data, target_time_stamp, pacemaker_file_path)
         result_time = ' '.join(data.split('\n')[result_line-1].split()[:3])
         self.assertEqual(result_time, target_time)