Beispiel #1
0
    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])
Beispiel #2
0
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()
Beispiel #3
0
 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()
Beispiel #4
0
    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 = Ticket(self.env)
        tkt1.populate({
            'summary': 'Foo',
            'milestone': 'Test',
            'owner': 'foman',
            'status': 'new'
        })
        tkt1.insert()
        tkt2 = Ticket(self.env)
        tkt2.populate({
            'summary': 'Bar',
            'milestone': 'Test',
            'status': 'closed',
            'owner': 'barman'
        })
        tkt2.insert()
        tkt3 = Ticket(self.env)
        tkt3.populate({
            'summary': 'Sum',
            'milestone': 'Test',
            'owner': 'suman',
            'status': 'reopened'
        })
        tkt3.insert()
        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])
Beispiel #5
0
 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))
Beispiel #6
0
 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))
Beispiel #7
0
 def test_get_search_results_matches_all_terms(self):
     req = MockRequest(self.env)
     milestone = Milestone(self.env, ' '.join(self.terms))
     results = self.mmodule.get_search_results(req, self.terms,
                                               ['milestone'])
     results = list(results)
     self.assertEqual(1, len(results))
     self.assertEqual(5, len(results[0]))
     self.assertEqual(
         '/trac.cgi/milestone/' + milestone.name.replace(' ', '%20'),
         results[0][0])
     self.assertEqual('Milestone ' + milestone.name, results[0][1])
     self.assertEqual(milestone.due, results[0][2])
     self.assertEqual('', results[0][3])
     self.assertEqual(milestone.description, results[0][4])
Beispiel #8
0
    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()
Beispiel #9
0
    def test_get_search_results_matches_all_terms(self):
        req = MockRequest(self.env)
        milestone = Milestone(self.env, ' '.join(self.terms))
        results = self.mmodule.get_search_results(req, self.terms,
                                                  ['milestone'])
        results = list(results)
        self.assertEqual(1, len(results))
        self.assertEqual(5, len(results[0]))
        self.assertEqual(
            '/trac.cgi/milestone/' + milestone.name.replace(' ', '%20'),
            results[0][0])
        self.assertEqual('Milestone ' + milestone.name, results[0][1])
        self.assertEqual(milestone.due, results[0][2])
        self.assertEqual('', results[0][3])
        shorten_desc = 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 a ..."""
        self.assertEqual(shorten_desc, results[0][4])
Beispiel #10
0
 def insert_milestone(self, name, due=None):
     milestone = Milestone(self.env)
     milestone.name = name
     milestone.due = due
     milestone.insert()
     return milestone