Skip to content

Commit

Permalink
1.6.1dev: fix ambiguous column of query which is created by `TestNewR…
Browse files Browse the repository at this point in the history
…eport`, and verify the result of `FunctionalTester.create_report` (closes #13752)

git-svn-id: http://trac.edgewall.org/intertrac/log:/branches/1.6-stable@17810 af82e41b-90c4-0310-8c96-b1721e28e2e2
  • Loading branch information
jomae committed May 27, 2024
1 parent 4708153 commit 79279a4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
33 changes: 27 additions & 6 deletions trac/tests/functional/tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from trac.tests.functional.better_twill import tc, b
from trac.tests.contentgen import random_page, random_sentence, random_word, \
random_unique_camel
from trac.util.html import tag
from trac.util.html import escape_quotes, tag
from trac.util.text import to_utf8, unicode_quote


Expand Down Expand Up @@ -422,11 +422,32 @@ def create_report(self, title, query, description):
tc.formvalue('edit_report', 'description', description)
tc.formvalue('edit_report', 'query', query)
tc.submit()
reportnum = b.get_url().split('/')[-1]
# TODO: verify the url is correct
# TODO: verify the report number is correct
# TODO: verify the report does not cause an internal error
# TODO: verify the title appears on the report list
tc.notfind(internal_error)

url = b.get_url()
reportnum = None
is_query = '/query?' in url
if is_query:
for pair in url.split('?', 1)[1].split('&'):
if pair.startswith('report='):
reportnum = pair.split('=', 1)[1]
break
else:
values = url.split('/')
if values[-2] == 'report':
reportnum = values[-1]
if reportnum is None or not reportnum.isdigit():
raise AssertionError('Unexpected {!r}'.format(url))
reportnum = int(reportnum)
if is_query:
tc.find(r'<h1>%s\s*<' % re.escape(escape_quotes(title)))
else:
tc.notfind('<div class="system-message">')
title_re = ''.join(
re.escape(escape_quotes(item)) if idx % 2 == 0 else r'[^<]*?'
for idx, item
in enumerate(re.split(r'(\$[A-Z_][A-Z0-9_]*)', title)))
tc.find(r'<h1>\{%d\} %s\s*<' % (reportnum, title_re))
return reportnum

def ticket_set_milestone(self, ticketid, milestone):
Expand Down
2 changes: 1 addition & 1 deletion trac/ticket/tests/functional/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ def runTest(self):
id AS ticket,
summary, component, milestone, t.type AS type,
reporter, time AS created,
changetime AS modified, description AS _description,
changetime AS modified, t.description AS _description,
priority,
round(julianday('now') -
julianday(changetime, 'unixepoch')) as days,
Expand Down

0 comments on commit 79279a4

Please sign in to comment.