Commits

Anonymous committed 6a97d26

[svn r8886] EstimationToolsPlugin: Added 4 new tests as followup to [8758].

Comments (0)

Files changed (4)

estimationtools/tests/__init__.py

     suite.addTest(makeSuite(estimationtools.tests.hoursremaining.HoursRemainingTestCase))
     import estimationtools.tests.workloadchart
     suite.addTest(makeSuite(estimationtools.tests.workloadchart.WorkloadChartTestCase))
+    import estimationtools.tests.utils
+    suite.addTest(makeSuite(estimationtools.tests.utils.EstimationToolsBaseTestCase))
     return suite

estimationtools/tests/burndownchart.py

         ticket1 = self._insert_ticket('10')
         self._change_ticket_estimations(ticket1, {day2: 'IGNOREME', day3:'5'})
         timetable = chart._calculate_timetable(options, query_args, self.req)
-        self.assertEqual(timetable, {day1: Decimal(10), day2: Decimal(10), day3: Decimal(5)})
+        self.assertEqual(timetable, {day1: Decimal(10), day2: Decimal(10), day3: Decimal(5)})
+
+    def test_url_encode(self):
+        chart = BurndownChart(self.env)
+        t = Ticket(self.env, self._insert_ticket('12'))
+        result = chart.render_macro(self.req, 'BurndownChart',
+                        "milestone=milestone1, startdate=2010-09-15, enddate=2010-09-20")
+        self.failUnless("&chtt=milestone1&" in str(result))
+        result = chart.render_macro(self.req, 'BurndownChart',
+                        "milestone=One & Two, startdate=2010-09-15, enddate=2010-09-20")
+        self.failUnless("&chtt=One+%26+Two&" in str(result))

estimationtools/tests/utils.py

+
+import unittest
+from trac.test import EnvironmentStub, Mock
+
+from estimationtools.utils import EstimationToolsBase
+
+class EstimationToolsBaseTestCase(unittest.TestCase):
+    
+    def test_disabled_without_estimation_field(self):
+        class TestTool(EstimationToolsBase):
+            pass
+        env = EnvironmentStub(enable=['estimationtools.*'])
+        messages = []
+        env.log = Mock(error=lambda msg, *args: messages.append(msg))
+        TestTool(env)
+        self.assertEquals(False, env.is_enabled(TestTool))
+        self.assertEquals(messages,
+                ['EstimationTools (TestTool): Estimation field not configured. Component disabled.'])
+
+    def test_enabled_with_estimation_field(self):
+        class TestTool(EstimationToolsBase):
+            pass
+        env = EnvironmentStub()
+        env.config.set('ticket-custom', 'hours_remaining', 'text')
+        env.config.set('estimation-tools', 'estimation_field', 'hours_remaining')
+        env.config.set('components', 'estimationtools.*', 'enabled')
+        messages = []
+        env.log = Mock(error=lambda msg, *args: messages.append(msg))
+        TestTool(env)
+        self.assertEquals(True, env.is_enabled(TestTool))
+        self.assertEquals(messages, [])

estimationtools/tests/workloadchart.py

                 'chd=t%3A10%2C30%2C20&chf=bg%2Cs%2C00000000&'
                 'chco=ff9900&chl=A+10h%7CC+30h%7CB+20h&chs=400x100&'
                 'cht=p3&chtt=Workload+60h+%28%7E1+workdays+left%29" alt="Workload Chart (client)"/>')
+
+    def test_username_obfuscation(self):
+        workload_chart = WorkloadChart(self.env)
+        self._insert_ticket('10', 'user@example.org')
+        result = workload_chart.render_macro(self.req, "", "milestone=milestone1")
+        self.failUnless("&chl=user%40%E2%80%A6+10h&" in str(result))