class DefaultTicketGroupStatsProviderTestCase(unittest.TestCase): def setUp(self): self.env = EnvironmentStub(default_data=True) self.milestone1 = Milestone(self.env) self.milestone1.name = 'Test' self.milestone1.insert() self.milestone2 = Milestone(self.env) self.milestone2.name = 'Test2' self.milestone2.insert() tkt1 = insert_ticket(self.env, summary='Foo', milestone='Test', owner='foman', status='new') tkt2 = insert_ticket(self.env, summary='Bar', milestone='Test', status='closed', owner='barman') tkt3 = insert_ticket(self.env, summary='Sum', milestone='Test', owner='suman', status='reopened') self.tkt1 = tkt1 self.tkt2 = tkt2 self.tkt3 = tkt3 prov = DefaultTicketGroupStatsProvider(ComponentManager()) prov.env = self.env prov.config = self.env.config self.stats = prov.get_ticket_group_stats([tkt1.id, tkt2.id, tkt3.id]) def tearDown(self): self.env.reset_db() def test_stats(self): self.assertEqual(self.stats.title, 'ticket status', 'title incorrect') self.assertEqual(self.stats.unit, 'tickets', 'unit incorrect') self.assertEqual(2, len(self.stats.intervals), 'more than 2 intervals') def test_closed_interval(self): closed = self.stats.intervals[0] self.assertEqual('closed', closed['title'], 'closed title incorrect') self.assertEqual('closed', closed['css_class'], 'closed class incorrect') self.assertTrue(closed['overall_completion'], 'closed should contribute to overall completion') self.assertEqual({'status': ['closed'], 'group': ['resolution']}, closed['qry_args'], 'qry_args incorrect') self.assertEqual(1, closed['count'], 'closed count incorrect') self.assertEqual(33, closed['percent'], 'closed percent incorrect') def test_open_interval(self): open = self.stats.intervals[1] self.assertEqual('active', open['title'], 'open title incorrect') self.assertEqual('open', open['css_class'], 'open class incorrect') self.assertFalse(open['overall_completion'], "open shouldn't contribute to overall completion") self.assertEqual({'status': [u'assigned', u'new', u'accepted', u'reopened']}, open['qry_args'], 'qry_args incorrect') self.assertEqual(2, open['count'], 'open count incorrect') self.assertEqual(67, open['percent'], 'open percent incorrect')
def setUp(self): self.env = EnvironmentStub() self.mmodule = MilestoneModule(self.env) self.terms = ['MilestoneAlpha', 'MilestoneBeta', 'MilestoneGamma'] for term in self.terms + [' '.join(self.terms)]: m = Milestone(self.env) m.name = term m.due = datetime_now(utc) m.description = random_sentence() m.insert()
def milestone_setup(tc): from datetime import datetime from trac.util.datefmt import utc boo = Milestone(tc.env) boo.name = 'boo' boo.completed = boo.due = None boo.insert() roo = Milestone(tc.env) roo.name = 'roo' roo.completed = datetime.now(utc) roo.due = None roo.insert()
def test_resource_link_ticket_context_milestone_no_view_perm(self): """Resource link in ticket context with no milestone view permission. """ milestone = Milestone(self.env) milestone.name = 'milestone1' milestone.insert() req = MockRequest(self.env, path_info='/ticket/1', authname='user1') resource = Resource('milestone', 'milestone1') context = web_context(req) link = render_resource_link(self.env, context, resource, format='compact') self.assertEqual('<a class="milestone">milestone1</a>', unicode(link))
def test_resource_link_ticket_context_milestone_exists(self): """Resource link in ticket context for viewable milestone. """ milestone = Milestone(self.env) milestone.name = 'milestone1' milestone.insert() req = MockRequest(self.env, path_info='/ticket/1') resource = Resource('milestone', 'milestone1') context = web_context(req) link = render_resource_link(self.env, context, resource, format='compact') self.assertEqual('<a class="milestone" href="/trac.cgi/milestone/' 'milestone1" title="No date set">milestone1</a>', unicode(link))
def setUp(self): self.env = EnvironmentStub(default_data=True) self.mmodule = MilestoneModule(self.env) self.terms = ['MilestoneAlpha', 'MilestoneBeta', 'MilestoneGamma'] for term in self.terms + [' '.join(self.terms)]: m = Milestone(self.env) m.name = term m.due = datetime_now(utc) m.description = u"""\ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod \ tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim \ veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea \ commodo consequat. Duis aute irure dolor in reprehenderit in voluptate \ velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat \ cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id \ est laborum.""" m.insert()
def insert_milestone(self, name, due=None): milestone = Milestone(self.env) milestone.name = name milestone.due = due milestone.insert() return milestone