Commits

Olemis Lang committed e9a0d65

GViz providers: RPC test cases for reports meta-data work on Trac=1.0 ... FAILED (failures=11, errors=30)

Comments (0)

Files changed (1)

trac-dev/gviz/tracgviz/testing/test_rpc.py

   from doctest import NORMALIZE_WHITESPACE, ELLIPSIS, REPORT_UDIFF
   from dutest import MultiTestLoader
   from unittest import defaultTestLoader
-  
+
   from __init__ import DocTestRpcLoader, ticket_data
-  
+
   magic_vars = dict(ticket_data=ticket_data)
   l = MultiTestLoader(
         [defaultTestLoader, \
                             optionflags=ELLIPSIS | REPORT_UDIFF | \
                                         NORMALIZE_WHITESPACE) \
         ])
-  
+
   import sys
   return l.loadTestsFromModule(sys.modules[__name__])
 
   ticket workflow. Needed for TracRpc>=1.0.6
   """
   from time import sleep
-  
+
   TICKET_ACTIONS = {'accepted': 'accept', 'closed' : 'resolve',
                     'assigned': 'reassign'}
   sleep(1)
       >>> from trac.versioncontrol.web_ui.changeset import ChangesetModule
       >>> env[ChangesetModule] is None
       True
-      
+
       >>> print_timeline_filters(rpcobj)
       ('milestone', 'Milestones reached')
       ('ticket', 'Tickets opened and closed')
       ('wiki', 'Wiki changes')
-      
+
       # Enable version control ... for a while ;o)
       >>> env.enabled.clear()                     # Clear cache
       >>> env.enable_component('trac.versioncontrol.web_ui.changeset.*')
-      
+
       >>> print_timeline_filters(rpcobj)
       ('changeset', 'Repository changesets')
       ('milestone', 'Milestones reached')
       ('ticket', 'Tickets opened and closed')
       ('wiki', 'Wiki changes')
-      
+
       >>> from trac.core import Component, implements
       >>> from trac.timeline.api import ITimelineEventProvider
       >>> class TestTimelineProvider(Component):
       ... 
       >>> list(TestTimelineProvider(env).get_timeline_filters(req))
       [('test_tracgviz', 'Testing ternary tuples in filters', True)]
-      
+
       >>> env.enable_component(TestTimelineProvider)
       >>> print_timeline_filters(rpcobj)
       ('changeset', 'Repository changesets')
       ('test_tracgviz', 'Testing ternary tuples in filters')
       ('ticket', 'Tickets opened and closed')
       ('wiki', 'Wiki changes')
-      
+
       >>> env.config.set('timeline', 'ticket_show_details', 'true')
       >>> env.config.save()
       >>> print_timeline_filters(rpcobj)
       ('ticket', 'Tickets opened and closed')
       ('ticket_details', 'Ticket updates')
       ('wiki', 'Wiki changes')
-      
+
       # Clean up a little
       >>> env.enabled.clear()                     # Clear cache
       >>> env.rip_component(TestTimelineProvider)
       >>> del TestTimelineProvider
-      
+
       >>> env.disable_component(sel)
       >>> env.config.set('timeline', 'ticket_show_details', 'false')
       >>> env.config.save()
-      
+
       >>> print_timeline_filters(rpcobj)
       ('changeset', 'Repository changesets')
       ('milestone', 'Milestones reached')
       Wiki... imported from ...
       Wiki... imported from ...
       Wiki... imported from ...
-      
+
       >>> cnx.commit()
-      
+
       # Everything Ok ?
       >>> from tracrpc.wiki import WikiRPC
       >>> sorted(WikiRPC(env).getAllPages(req))
       [u'WikiDeletePage', u'WikiFormatting', u'WikiHtml', u'WikiMacros', 
       u'WikiNewPage', u'WikiPageNames', u'WikiProcessors', 
       u'WikiRestructuredText', u'WikiRestructuredTextLinks', u'WikiStart']
-      
+
       >>> print_timeline_events(rpcobj.getEvents(None, None, ['wiki']))   # Default wiki pages
       ['wiki', u'trac', '...', ..., 'http://example.org/trac.cgi/wiki/WikiDeletePage?version=1', '<em>WikiDeletePage</em> created', '']
       ['wiki', u'trac', '...', ..., 'http://example.org/trac.cgi/wiki/WikiFormatting?version=1', '<em>WikiFormatting</em> created', '']
       ['wiki', u'trac', '...', ..., 'http://example.org/trac.cgi/wiki/WikiRestructuredText?version=1', '<em>WikiRestructuredText</em> created', '']
       ['wiki', u'trac', '...', ..., 'http://example.org/trac.cgi/wiki/WikiRestructuredTextLinks?version=1', '<em>WikiRestructuredTextLinks</em> created', '']
       ['wiki', u'trac', '...', ..., 'http://example.org/trac.cgi/wiki/WikiStart?version=1', '<em>WikiStart</em> created', '']
-      
+
       # Remember this glorious moment, then go to sleep
       >>> from time import sleep
       >>> sleep(1)
       >>> from trac.util.datefmt import localtz
       >>> timestamp = datetime.now(localtz)
       >>> sleep(1)
-      
+
       # Adding the best wiki page in the world
       >>> from trac.wiki.model import WikiPage
       >>> page = WikiPage(env, 'TestPage', version=1)
       False
       >>> page.text = 'I love Trac ! Gimme more !'
       >>> page.save('murphy', 'New wiki page', '127.0.0.1')
-      
+
       >>> print_timeline_events(rpcobj.getEvents(timestamp, None, ['wiki']))
       ['wiki', u'murphy', '...', ..., 'http://example.org/trac.cgi/wiki/TestPage?version=1', '<em>TestPage</em> created', '<p>\nNew wiki page\n</p>\n']
-      
+
       >>> from trac.util.datefmt import _epoc
       >>> print_timeline_events(rpcobj.getEvents(_epoc, timestamp, ['wiki']))
       ['wiki', u'trac', '...', ..., 'http://example.org/trac.cgi/wiki/WikiDeletePage?version=1', '<em>WikiDeletePage</em> created', '']
       ['wiki', u'trac', '...', ..., 'http://example.org/trac.cgi/wiki/WikiRestructuredText?version=1', '<em>WikiRestructuredText</em> created', '']
       ['wiki', u'trac', '...', ..., 'http://example.org/trac.cgi/wiki/WikiRestructuredTextLinks?version=1', '<em>WikiRestructuredTextLinks</em> created', '']
       ['wiki', u'trac', '...', ..., 'http://example.org/trac.cgi/wiki/WikiStart?version=1', '<em>WikiStart</em> created', '']
-      
+
       >>> print_timeline_events(rpcobj.getEvents(None, None, ['wiki']))   # All events
       ['wiki', u'trac', '...', ..., 'http://example.org/trac.cgi/wiki/WikiDeletePage?version=1', '<em>WikiDeletePage</em> created', '']
       ['wiki', u'trac', '...', ..., 'http://example.org/trac.cgi/wiki/WikiFormatting?version=1', '<em>WikiFormatting</em> created', '']
       ['milestone', '', '1970-01-01 00:00:00+00:00', 0L, 'http://example.org/trac.cgi/milestone/milestone2', 'Milestone <em>milestone2</em> completed', '']
       ['milestone', '', '1970-01-01 00:00:00+00:00', 0L, 'http://example.org/trac.cgi/milestone/milestone3', 'Milestone <em>milestone3</em> completed', '']
       ['milestone', '', '1970-01-01 00:00:00+00:00', 0L, 'http://example.org/trac.cgi/milestone/milestone4', 'Milestone <em>milestone4</em> completed', '']
-      
+
       # Remember this glorious moment, don't you dare to sleep !
       >>> from trac.util.datefmt import localtz
       >>> timestamp = datetime.now(localtz)
-      
+
       # Now you know what all this is about
       >>> from trac.ticket.model import Milestone
       >>> m = Milestone(env)
       >>> m.name = 'World-wide domination'
       >>> m.description = "I'll rule the world. My Trac is my weapon"
       >>> m.insert()
-      
+
       >>> print_timeline_events(rpcobj.getEvents(None, None, ['milestone']))   # After insert
       ['milestone', '', '1970-01-01 00:00:00+00:00', 0L, 'http://example.org/trac.cgi/milestone/milestone1', 'Milestone <em>milestone1</em> completed', '']
       ['milestone', '', '1970-01-01 00:00:00+00:00', 0L, 'http://example.org/trac.cgi/milestone/milestone2', 'Milestone <em>milestone2</em> completed', '']
       ['milestone', '', '1970-01-01 00:00:00+00:00', 0L, 'http://example.org/trac.cgi/milestone/milestone3', 'Milestone <em>milestone3</em> completed', '']
       ['milestone', '', '1970-01-01 00:00:00+00:00', 0L, 'http://example.org/trac.cgi/milestone/milestone4', 'Milestone <em>milestone4</em> completed', '']
       ['milestone', '', '1970-01-01 00:00:00+00:00', 0L, 'http://example.org/trac.cgi/milestone/World-wide%20domination', 'Milestone <em>World-wide domination</em> completed', "<p>\nI'll rule the world. My Trac is my weapon\n</p>\n"]
-      
+
       # Consider it done ! :P
       >>> m._fetch(m.name)
       >>> m.completed = timestamp.replace(year=timestamp.year - 1)
       >>> m._fetch(m.name)
       >>> m.completed.year == timestamp.year - 1
       True
-      
+
       # Retrieve events since two years ago
       >>> timestamp = timestamp.replace(year=timestamp.year - 2)
-      
+
       >>> print_timeline_events(rpcobj.getEvents(timestamp, None, ['milestone']))
       ['milestone', '', '2...', ..., 'http://example.org/trac.cgi/milestone/World-wide%20domination', 'Milestone <em>World-wide domination</em> completed', "<p>\nI'll rule the world. My Trac is my weapon\n</p>\n"]
-      
+
       >>> from trac.util.datefmt import _epoc
       >>> print_timeline_events(rpcobj.getEvents(_epoc, timestamp, ['milestone']))
       ['milestone', '', '1970-01-01 00:00:00+00:00', 0L, 'http://example.org/trac.cgi/milestone/milestone1', 'Milestone <em>milestone1</em> completed', '']
       ['milestone', '', '1970-01-01 00:00:00+00:00', 0L, 'http://example.org/trac.cgi/milestone/milestone2', 'Milestone <em>milestone2</em> completed', '']
       ['milestone', '', '1970-01-01 00:00:00+00:00', 0L, 'http://example.org/trac.cgi/milestone/milestone3', 'Milestone <em>milestone3</em> completed', '']
       ['milestone', '', '1970-01-01 00:00:00+00:00', 0L, 'http://example.org/trac.cgi/milestone/milestone4', 'Milestone <em>milestone4</em> completed', '']
-      
+
       >>> print_timeline_events(rpcobj.getEvents(None, None, ['milestone']))   # All events
       ['milestone', '', '1970-01-01 00:00:00+00:00', 0L, 'http://example.org/trac.cgi/milestone/milestone1', 'Milestone <em>milestone1</em> completed', '']
       ['milestone', '', '1970-01-01 00:00:00+00:00', 0L, 'http://example.org/trac.cgi/milestone/milestone2', 'Milestone <em>milestone2</em> completed', '']
     '|timeline: Retrieving ticket events' : r"""
       # Open tickets
       >>> from trac.util.datefmt import localtz
-      
+
       >>> from tracrpc.ticket import TicketRPC
       >>> tcktrpc = TicketRPC(env)
       >>> desc = 'God bless the devs who test their Trac ' \
       ...                 dict(type='task', priority='major', \
       ...                       component='component1'))
       1
-      
+
       # Ensure default config is in use
       >>> env.config.set('timeline', 'ticket_show_details', 'false')
       >>> env.config.save()
-      
+
       >>> print_timeline_events(rpcobj.getEvents(None, None, ['ticket']))
       ['newticket', u'murphy', '...', ..., 'http://example.org/trac.cgi/ticket/1', 'Ticket <em title="task: Test TracGViz plugin (new)">#1</em> (Test TracGViz plugin) created', '<p>\nGod bless the devs who test their Trac plugins using dutest<br />\n</p>\n']
       >>> print_timeline_events(rpcobj.getEvents(None, None, ['ticket_details']))
-      
+
       # Another change ...
       >>> id, tcr, tch, attrs = tcktrpc.update(auth_req, 1, \
       ...                               'Wanna do it right away', \
       'time' , datetime.datetime(..., tzinfo=<FixedOffset "UTC" 0:00:00>)
       'type' , u'task'
       'version' , u''
-      
+
       # ... hidden using default configuration ...
       >>> print_timeline_events(rpcobj.getEvents(None, None, ['ticket']))
       ['newticket', u'murphy', '...', ..., 'http://example.org/trac.cgi/ticket/1', 'Ticket <em title="task: Test TracGViz plugin (new)">#1</em> (Test TracGViz plugin) created', '<p>\nGod bless the devs who test their Trac plugins using dutest<br />\n</p>\n']
 
       >>> print_timeline_events(rpcobj.getEvents(None, None, ['ticket_details']))         # Milestone hidden
-      
+
       # ... visible otherwise ;o)
       >>> env.config.set('timeline', 'ticket_show_details', 'true')
       >>> env.config.save()
 
       >>> print_timeline_events(rpcobj.getEvents(None, None, ['ticket_details']))         # Milestone visible
       ['editedticket', u'murphy', '...', ..., 'http://example.org/trac.cgi/ticket/1#comment:1', 'Ticket <em title="task: Test TracGViz plugin (edit)">#1</em> (Test TracGViz plugin) updated', '<i>Milestone</i> changed<br/><p>\nWanna do it right away<br />\n</p>\n']
-      
+
       # Remember this glorious moment, then go to sleep
       >>> from time import sleep
       >>> sleep(1)
       >>> from trac.util.datefmt import localtz
       >>> timestamp = datetime.now(localtz)
       >>> sleep(1)
-      
+
       # About to use ticket actions & workflow. 
       # Flooooooow like the water ! can can can, can can, cacan
       >>> from trac.ticket.model import Ticket
       >>> t = Ticket(env, 1)
-      
+
       # Let's close it, Murphy ! Feel my power !
       >>> from trac.ticket.web_ui import TicketModule
       >>> tmdl = TicketModule(env)
       >>> problems
       []
       >>> tmdl._apply_ticket_changes(t, chgs)
-        
+
       # Performing ticket action ... copycat TicketModule._do_save
       >>> controllers = list(tmdl._get_action_controllers(auth_req, t, \
       ...                           'accept'))
       >>> is_saved = t.save_changes('murphy', comment, when=now, cnum=cnum)
       >>> is_saved
       True
-      
+
       # After saving the changes, apply the side-effects.
       >>> if is_saved:
       ...   for controller in controllers:
       >>> print_timeline_events(rpcobj.getEvents(timestamp, None, ['ticket']))
       >>> print_timeline_events(rpcobj.getEvents(timestamp, None, ['ticket_details']))
       ['editedticket', u'murphy', '...', ..., 'http://example.org/trac.cgi/ticket/1#comment:3', 'Ticket <em title="task: Test TracGViz plugin (edit)">#1</em> (Test TracGViz plugin) updated', '<i>Status</i>, <i>Owner</i> changed<br/><p>\nI accept the challenge<br />\n</p>\n']
-      
+
       >>> from trac.util.datefmt import _epoc
       >>> print_timeline_events(rpcobj.getEvents(_epoc, timestamp, ['ticket']))
       ['newticket', u'murphy', '...', ..., 'http://example.org/trac.cgi/ticket/1', 'Ticket <em title="task: Test TracGViz plugin (new)">#1</em> (Test TracGViz plugin) created', '<p>\nGod bless the devs who test their Trac plugins using dutest<br />\n</p>\n']
 
       >>> print_timeline_events(rpcobj.getEvents(_epoc, timestamp, ['ticket_details']))
       ['editedticket', u'murphy', '...', ..., 'http://example.org/trac.cgi/ticket/1#comment:1', 'Ticket <em title="task: Test TracGViz plugin (edit)">#1</em> (Test TracGViz plugin) updated', '<i>Milestone</i> changed<br/><p>\nWanna do it right away<br />\n</p>\n']
-      
+
       >>> print_timeline_events(rpcobj.getEvents(None, None, ['ticket']))   # All events
       ['newticket', u'murphy', '...', ..., 'http://example.org/trac.cgi/ticket/1', 'Ticket <em title="task: Test TracGViz plugin (new)">#1</em> (Test TracGViz plugin) created', '<p>\nGod bless the devs who test their Trac plugins using dutest<br />\n</p>\n']
 
       >>> print_timeline_events(rpcobj.getEvents(None, None, ['ticket_details']))
       ['editedticket', u'murphy', '...', ..., 'http://example.org/trac.cgi/ticket/1#comment:1', 'Ticket <em title="task: Test TracGViz plugin (edit)">#1</em> (Test TracGViz plugin) updated', '<i>Milestone</i> changed<br/><p>\nWanna do it right away<br />\n</p>\n']
       ['editedticket', u'murphy', '...', ..., 'http://example.org/trac.cgi/ticket/1#comment:3', 'Ticket <em title="task: Test TracGViz plugin (edit)">#1</em> (Test TracGViz plugin) updated', '<i>Status</i>, <i>Owner</i> changed<br/><p>\nI accept the challenge<br />\n</p>\n']
-      
+
       # Be nice. Reset default config.
       # Don't wanna know all the details. I'll rule the world anyway
       # Just a matter of time.
     '|report: Retrieving meta-data about reports' : r"""
       >>> list(rpcobj.getAll())
       [1, 2, 3, 4, 5, 6, 7, 8]
-      
+
       >>> print_report_metadata(rpcobj.get(1))
       Id
       --
       <BLANKLINE>
       Query
       -----
-      <BLANKLINE>
       SELECT p.value AS __color__,
-         id AS ticket, summary, component, version, milestone, t.type AS type,
+         id AS ticket, summary, component, version, milestone, t.type AS type, 
          owner, status,
          time AS created,
          changetime AS _changetime, description AS _description,
         FROM ticket t
         LEFT JOIN enum p ON p.name = t.priority AND p.type = 'priority'
         WHERE status <> 'closed'
-        ORDER BY CAST(p.value AS int), milestone, t.type, time
+        ORDER BY CAST(p.value AS integer), milestone, t.type, time
       <BLANKLINE>
-      
+
       >>> print_report_metadata(rpcobj.get(2))
       Id
       --
       <BLANKLINE>
       Query
       -----
-      <BLANKLINE>
       SELECT p.value AS __color__,
          version AS __group__,
-         id AS ticket, summary, component, version, t.type AS type,
+         id AS ticket, summary, component, version, t.type AS type, 
          owner, status,
          time AS created,
          changetime AS _changetime, description AS _description,
         FROM ticket t
         LEFT JOIN enum p ON p.name = t.priority AND p.type = 'priority'
         WHERE status <> 'closed'
-        ORDER BY (version IS NULL),version, CAST(p.value AS int), t.type, time
+        ORDER BY (version IS NULL),version, CAST(p.value AS integer), t.type, time
       <BLANKLINE>
-      
+
       >>> print_report_metadata(rpcobj.get(3))
       Id
       --
       <BLANKLINE>
       Query
       -----
-      <BLANKLINE>
       SELECT p.value AS __color__,
          'Milestone '||milestone AS __group__,
-         id AS ticket, summary, component, version, t.type AS type,
+         id AS ticket, summary, component, version, t.type AS type, 
          owner, status,
          time AS created,
          changetime AS _changetime, description AS _description,
          reporter AS _reporter
         FROM ticket t
         LEFT JOIN enum p ON p.name = t.priority AND p.type = 'priority'
-        WHERE status <> 'closed'
-        ORDER BY (milestone IS NULL),milestone, CAST(p.value AS int), t.type, time
+        WHERE status <> 'closed' 
+        ORDER BY (milestone IS NULL),milestone, CAST(p.value AS integer), t.type, time
       <BLANKLINE>
-      
+
       >>> print_report_metadata(rpcobj.get(4))
       Id
       --
       <BLANKLINE>
       Query
       -----
-      <BLANKLINE>
-      <BLANKLINE>
       SELECT p.value AS __color__,
          owner AS __group__,
          id AS ticket, summary, component, milestone, t.type AS type, time AS created,
         FROM ticket t
         LEFT JOIN enum p ON p.name = t.priority AND p.type = 'priority'
         WHERE status = 'accepted'
-        ORDER BY owner, CAST(p.value AS int), t.type, time
+        ORDER BY owner, CAST(p.value AS integer), t.type, time
       <BLANKLINE>
-      
+
       >>> print_report_metadata(rpcobj.get(5))
       Id
       --
       <BLANKLINE>
       Query
       -----
-      <BLANKLINE>
       SELECT p.value AS __color__,
          owner AS __group__,
          id AS ticket, summary, component, milestone, t.type AS type, time AS created,
         FROM ticket t
         LEFT JOIN enum p ON p.name = t.priority AND p.type = 'priority'
         WHERE status = 'accepted'
-        ORDER BY owner, CAST(p.value AS int), t.type, time
+        ORDER BY owner, CAST(p.value AS integer), t.type, time
       <BLANKLINE>
-      
+
       >>> print_report_metadata(rpcobj.get(6))
       Id
       --
       <BLANKLINE>
       Query
       -----
-      <BLANKLINE>
       SELECT p.value AS __color__,
          t.milestone AS __group__,
-         (CASE status
+         (CASE status 
             WHEN 'closed' THEN 'color: #777; background: #ddd; border-color: #ccc;'
-            ELSE
+            ELSE 
               (CASE owner WHEN $USER THEN 'font-weight: bold' END)
           END) AS __style__,
-         id AS ticket, summary, component, status,
+         id AS ticket, summary, component, status, 
          resolution,version, t.type AS type, priority, owner,
          changetime AS modified,
          time AS _time,reporter AS _reporter
         FROM ticket t
         LEFT JOIN enum p ON p.name = t.priority AND p.type = 'priority'
-        ORDER BY (milestone IS NULL), milestone DESC, (status = 'closed'),
-              (CASE status WHEN 'closed' THEN changetime ELSE (-1) * CAST(p.value AS int) END) DESC
+        ORDER BY (milestone IS NULL), milestone DESC, (status = 'closed'), 
+              (CASE status WHEN 'closed' THEN changetime ELSE (-1) * CAST(p.value AS integer) END) DESC
       <BLANKLINE>
-      
+
       >>> print_report_metadata(rpcobj.get(7))
       Id
       --
       <BLANKLINE>
       Query
       -----
-      <BLANKLINE>
-      SELECT p.value AS __color__,
-         (CASE status WHEN 'accepted' THEN 'Accepted' ELSE 'Owned' END) AS __group__,
-         id AS ticket, summary, component, version, milestone,
-         t.type AS type, priority, time AS created,
-         changetime AS _changetime, description AS _description,
-         reporter AS _reporter
+      SELECT  __color__, __group,
+             (CASE
+               WHEN __group = 1 THEN 'Accepted'
+               WHEN __group = 2 THEN 'Owned'
+               WHEN __group = 3 THEN 'Reported'
+               ELSE 'Commented' END) AS __group__,
+             ticket, summary, component, version, milestone,
+             type, priority, created, _changetime, _description,
+             _reporter
+      FROM (
+       SELECT DISTINCT CAST(p.value AS integer) AS __color__,
+            (CASE
+               WHEN owner = $USER AND status = 'accepted' THEN 1
+               WHEN owner = $USER THEN 2
+               WHEN reporter = $USER THEN 3
+               ELSE 4 END) AS __group,
+             t.id AS ticket, summary, component, version, milestone,
+             t.type AS type, priority, t.time AS created,
+             t.changetime AS _changetime, description AS _description,
+             reporter AS _reporter
         FROM ticket t
         LEFT JOIN enum p ON p.name = t.priority AND p.type = 'priority'
-        WHERE t.status <> 'closed' AND owner = $USER
-        ORDER BY (status = 'accepted') DESC, CAST(p.value AS int), milestone, t.type, time
+        LEFT JOIN ticket_change tc ON tc.ticket = t.id AND tc.author = $USER
+                                      AND tc.field = 'comment'
+        WHERE t.status <> 'closed'
+              AND (owner = $USER OR reporter = $USER OR author = $USER)
+      ) AS sub
+      ORDER BY __group, __color__, milestone, type, created
       <BLANKLINE>
-      
+
       >>> print_report_metadata(rpcobj.get(8))
       Id
       --
         FROM ticket t
         LEFT JOIN enum p ON p.name = t.priority AND p.type = 'priority'
         WHERE status <> 'closed'
-        ORDER BY (owner = $USER) DESC, CAST(p.value AS int), milestone, t.type, time
+        ORDER BY (COALESCE(owner, '') = $USER) DESC, CAST(p.value AS integer), milestone, t.type, time
       <BLANKLINE>
       """,
     '|report: Executing SQL reports' : r"""
       Column: _changetime Type: string Label: _
       Column: _description Type: string Label: _
       Column: _reporter Type: string Label: _
-      
+
       # Add tickets
       >>> from tracrpc.ticket import TicketRPC
       >>> tcktrpc = TicketRPC(env)
       7
       8
       9
-      
+
       >>> if all(tcktrpc.get(auth_req, tid)[-1].get('status') == 'new' \
       ...            for tid in xrange(1, 10)):
       ...   # RPC considers ticket workflow
       ...   prepare_ticket_workflow(tcktrpc, ticket_data, auth_req)
       ...
-      
+
       # Hack needed for deterministic order when exec-ing report 6
       >>> from time import sleep
       >>> _ = tcktrpc.update(auth_req, 7, "", {'cc' : ' '})
       ...   sleep(1)
       ...   _ = tcktrpc.update(auth_req, tid, "", {'cc' : ' '})
       ... 
-      
+
       # Check everything is ok with tickets
       >>> for tid in xrange(1, 10):
       ...   d = tcktrpc.get(auth_req, tid)[-1]
           u'murphy', u'closed', u'component1', '')
       (u'Ticket 9', u'Description 9', u'minor', '', u'enhancement', 
           u'tester', u'closed', '', u'2.0')
-      
+
       # Now it should work -- well mostly, because not all fields 
       #                       have been included in example tickets.
       >>> cols = auth_rpcobj.enum_columns(1)
       Column: _changetime Value: ... 
       Column: _description Value: Description 5
       Column: _reporter Value: murphy
-      
+
       >>> cols = auth_rpcobj.enum_columns(2)
       >>> print_report_columns(cols)
       Column: __color__ Type: string Label: _
       Column: _changetime Value: ... 
       Column: _description Value: Description 2
       Column: _reporter Value: murphy
-      
+
       >>> cols = auth_rpcobj.enum_columns(3)
       >>> print_report_columns(cols)
       Column: __color__ Type: string Label: _
       Column: _changetime Value: ... 
       Column: _description Value: Description 2
       Column: _reporter Value: murphy
-      
+
       >>> cols = auth_rpcobj.enum_columns(4)
       >>> print_report_columns(cols)
       Column: __color__ Type: string Label: _
       Column: _changetime Value: ... 
       Column: _description Value: Description 2
       Column: _reporter Value: murphy
-      
+
       >>> cols = auth_rpcobj.enum_columns(5)
       >>> print_report_columns(cols)
       Column: __color__ Type: string Label: _
       Column: _description_ Value: Description 2
       Column: _changetime Value: ... 
       Column: _reporter Value: murphy
-      
+
       >>> cols = auth_rpcobj.enum_columns(6)
       >>> print_report_columns(cols)
       Column: __color__ Type: string Label: _
       Column: modified Value: ... 
       Column: _time Value: ... 
       Column: _reporter Value: murphy 
-      
+
       >>> cols = auth_rpcobj.enum_columns(7)
       >>> print_report_columns(cols)
       Column: __color__ Type: string Label: _
       Column: _changetime Value: ... 
       Column: _description Value: Description 5
       Column: _reporter Value: murphy
-      
+
       >>> cols = auth_rpcobj.enum_columns(8)
       >>> print_report_columns(cols)
       Column: __color__ Type: string Label: _
       """,
     '|report: Creating and executing TracQuery reports' : r"""
       >>> clear_perm_cache(env, auth_req)    # Start clean
-      
+
       # Grant `REPORT_CREATE` to `murphy`
       >>> from trac.perm import PermissionSystem, DefaultPermissionPolicy
       >>> ps = PermissionSystem(env)
       >>> auth_req.perm.require('REPORT_CREATE') # Check perm granted
       >>> 'REPORT_CREATE' in auth_req.perm
       True
-      
+
       >>> auth_rpcobj.create('My own query', 'A report defined using ' \
       ...                     'TracQuery expressions (i.e. SQL ' \
       ...                     'stored using query: prefix).', \
       ...                     'col=reporter&col=keywords&col=cc&' \
       ...                     'col=time&col=changetime')
       9
-      
+
       >>> print_report_metadata(rpcobj.get(9))
       Id
       --
       Query
       -----
       query:owner=murphy&status=closed&order=id&col=id&col=summary&col=type&col=status&col=priority&col=milestone&col=component&col=version&col=resolution&col=reporter&col=keywords&col=cc&col=time&col=changetime
-      
+
       # Ticket data is not needed to list columns in result set
       >>> cols = auth_rpcobj.enum_columns(9)
       >>> print_report_columns(cols)
       Column: time Type: number Label: Created
       Column: href Type: string Label: URL
       Column: id Type: number Label: Ticket
-      
+
       # Add tickets
       >>> from tracrpc.ticket import TicketRPC
       >>> tcktrpc = TicketRPC(env)
       7
       8
       9
-      
+
       >>> if all(tcktrpc.get(auth_req, tid)[-1].get('status') == 'new' \
       ...            for tid in xrange(1, 10)):
       ...   # RPC considers ticket workflow
       ...   prepare_ticket_workflow(tcktrpc, ticket_data, auth_req)
       ...
-      
+
       # Check everything is ok with tickets
       >>> for tid in xrange(1, 10):
       ...   d = tcktrpc.get(auth_req, tid)[-1]
           u'murphy', u'closed', u'component1', '')
       (u'Ticket 9', u'Description 9', u'minor', '', u'enhancement', 
           u'tester', u'closed', '', u'2.0')
-      
+
       # Executing the query
       >>> print_report_result(cols, auth_rpcobj.execute(9))
       = Row 0 =
       Column: time Value: ... 
       Column: href Value: http://example.org/trac.cgi/ticket/8
       Column: id Value: 8
-      
+
       >>> ps.revoke_permission('murphy', 'REPORT_CREATE')
       >>> clear_perm_cache(env, auth_req)    # Clear permission cache
       >>> auth_req.perm.require('REPORT_CREATE') 
       """,
     '|report: Require REPORT_SQL_VIEW to view report definition' : r"""
       >>> clear_perm_cache(env, req)    # Start clean
-      
+
       # Revoke `REPORT_SQL_VIEW` permission and query will be hidden
       >>> from trac.perm import PermissionSystem
       >>> ps = PermissionSystem(env)
       Query
       -----
       None
-            
+
       # Grant `REPORT_SQL_VIEW` permission once again and it's shown.
       >>> ps.grant_permission('anonymous', 'REPORT_SQL_VIEW')
       >>> clear_perm_cache(env, req)    # Clear permission cache
         FROM ticket t
         LEFT JOIN enum p ON p.name = t.priority AND p.type = 'priority'
         WHERE status <> 'closed'
-        ORDER BY CAST(p.value AS int), milestone, t.type, time
+        ORDER BY CAST(p.value AS integer), milestone, t.type, time
       <BLANKLINE>
       """
   }