From c159589304662c927c3c0ef26df5172422a71318 Mon Sep 17 00:00:00 2001 From: jomae Date: Tue, 28 May 2024 02:45:07 +0000 Subject: [PATCH] 1.6.1dev: fix `TestNewReport` failing with PostgreSQL and MySQL (refs #13752) git-svn-id: http://trac.edgewall.org/intertrac/log:/branches/1.6-stable@17812 af82e41b-90c4-0310-8c96-b1721e28e2e2 --- trac/tests/functional/tester.py | 1 + trac/ticket/tests/functional/main.py | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/trac/tests/functional/tester.py b/trac/tests/functional/tester.py index f4ddac093f..ef405a3909 100755 --- a/trac/tests/functional/tester.py +++ b/trac/tests/functional/tester.py @@ -423,6 +423,7 @@ def create_report(self, title, query, description): tc.formvalue('edit_report', 'query', query) tc.submit() tc.notfind(internal_error) + tc.find(r'>\s*The report has been created\.\s*<') url = b.get_url() reportnum = None diff --git a/trac/ticket/tests/functional/main.py b/trac/ticket/tests/functional/main.py index 2738bc6769..4b4cdcec0f 100755 --- a/trac/ticket/tests/functional/main.py +++ b/trac/ticket/tests/functional/main.py @@ -690,6 +690,18 @@ def runTest(self): class TestNewReport(FunctionalTestCaseSetup): def runTest(self): """Create a new report""" + env = self._testenv.get_trac_environment() + schema = env.config.get('trac', 'database').split(':', 1)[0] + if schema == 'sqlite': + delta_days = "julianday('now') - " \ + "julianday(changetime / 1000000, 'unixepoch')" + elif schema == 'postgres': + delta_days = \ + "(date_part('epoch', now()) - changetime / 1000000) / 86400" + elif schema == 'mysql': + delta_days = "(unix_timestamp() - changetime / 1000000) / 86400" + else: + raise AssertionError(repr(schema)) self._tester.create_report( 'Closed tickets, modified in the past 7 days by owner.', """ SELECT DISTINCT p.value AS __color__, @@ -698,18 +710,16 @@ def runTest(self): reporter, time AS created, changetime AS modified, t.description AS _description, priority, - round(julianday('now') - - julianday(changetime, 'unixepoch')) as days, + round({delta_days}) as days, resolution, owner as __group__ FROM ticket t LEFT JOIN enum p ON p.name = t.priority AND p.type = 'priority' - WHERE ((julianday('now') - - julianday(changetime, 'unixepoch')) < 7) + WHERE {delta_days} < 7 AND status = 'closed' ORDER BY __group__, changetime, p.value - """, + """.format(delta_days=delta_days), 'List of all tickets that are closed, and have been modified in' ' the past 7 days, grouped by owner.\n\n(So they have probably' ' been closed this week.)')