Skip to content

Commit

Permalink
1.6.1dev: fix TestNewReport failing with PostgreSQL and MySQL (refs…
Browse files Browse the repository at this point in the history
… #13752)

git-svn-id: http://trac.edgewall.org/intertrac/log:/branches/1.6-stable@17812 af82e41b-90c4-0310-8c96-b1721e28e2e2
  • Loading branch information
jomae committed May 28, 2024
1 parent 79279a4 commit c159589
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions trac/tests/functional/tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 15 additions & 5 deletions trac/ticket/tests/functional/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__,
Expand All @@ -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.)')
Expand Down

0 comments on commit c159589

Please sign in to comment.