Commits

Anonymous committed 9175377

[svn r10557] EstimationToolsPlugin: Support `#` in field values for queries. Closes #9070.

Comments (0)

Files changed (2)

estimationtools/tests/hoursremaining.py

                         tz='')
         self.formatter = Mock(req=self.req)
        
-    def _insert_ticket(self, estimation, status='open'):
+    def _insert_ticket(self, estimation, fields=None):
+        fields = fields or {}
         ticket = Ticket(self.env)
         ticket['summary'] = 'Test Ticket'
         ticket['hours_remaining'] = estimation
         ticket['milestone'] = 'milestone1'
-        ticket['status'] = status
-        return ticket.insert()
+        ticket['status'] = 'open'
+        for field, value in fields.items():
+            ticket[field] = value
+        ticket.insert()
+        return ticket
 
     def test_basic(self):
         hoursRemaining = HoursRemaining(self.env)
         self._insert_ticket('10')
         self._insert_ticket('20.1')
         self._insert_ticket('30')
-        self._insert_ticket('30', status='closed')
+        self._insert_ticket('30', fields={'status': 'closed'})
         result = hoursRemaining.expand_macro(self.formatter, "", "status!=closed, milestone=milestone1")
         self.assertEqual(result, '60.1')
 
             self._insert_ticket('1')
         result = hoursRemaining.expand_macro(self.formatter, "", "milestone=milestone1")
         self.assertEqual(result, '200')
+
+    def test_url_encode(self):
+        hoursRemaining = HoursRemaining(self.env)
+        self._insert_ticket('10', fields={'summary': 'Test#One'})
+        result = hoursRemaining.expand_macro(self.formatter, "", "summary=Test#One")
+        self.assertEquals(result, '10')
+

estimationtools/utils.py

     # set maximum number of returned tickets to 0 to get all tickets at once
     query_args['max'] = 0
     # urlencode the args, converting back a few vital exceptions:
-    query_string = unicode_urlencode(query_args).replace('%21=', '!=').replace('%7C', '|').replace('+', ' ')
+    query_string = unicode_urlencode(query_args)\
+                        .replace('%21=', '!=')\
+                        .replace('%7C', '|')\
+                        .replace('+', ' ')\
+                        .replace('%23', '#')
     env.log.debug("query_string: %s" % query_string)
     query = Query.from_string(env, query_string)