def testIssueViewWithBlocking(self):
        all_related = {
            self.issue1.issue_id: self.issue1,
            self.issue2.issue_id: self.issue2,
            self.issue3.issue_id: self.issue3,
            self.issue4.issue_id: self.issue4,
        }
        # Treat issues 3 and 4 as visible to the current user.
        view2 = tracker_views.IssueView(
            self.issue2,
            self.users_by_id,
            _MakeConfig(),
            open_related={
                self.issue1.issue_id: self.issue1,
                self.issue3.issue_id: self.issue3
            },
            closed_related={self.issue4.issue_id: self.issue4},
            all_related=all_related)
        self.assertEqual(['not too long summary', 'sum 3'],
                         [irv.summary for irv in view2.blocked_on])
        self.assertEqual(
            ['not too long summary', 'sum 4', 'Issue 5001 in codesite.'],
            [irv.summary for irv in view2.blocking])
        self.assertTrue(view2.multiple_blocked_on)

        # Now, treat issues 3 and 4 as not visible to the current user.
        view2 = tracker_views.IssueView(
            self.issue2,
            self.users_by_id,
            _MakeConfig(),
            open_related={self.issue1.issue_id: self.issue1},
            closed_related={},
            all_related=all_related)
        self.assertEqual(['not too long summary', None],
                         [irv.summary for irv in view2.blocked_on])
        self.assertEqual(
            ['not too long summary', None, 'Issue 5001 in codesite.'],
            [irv.summary for irv in view2.blocking])
        self.assertFalse(view2.multiple_blocked_on)

        # Treat nothing as visible to the current user. Can still see dangling ref.
        dref_blocked_on = tracker_pb2.DanglingIssueRef()
        dref_blocked_on.project = 'codesite'
        dref_blocked_on.issue_id = 4999
        self.issue2.dangling_blocked_on_refs.append(dref_blocked_on)
        view2 = tracker_views.IssueView(
            self.issue2,
            self.users_by_id,
            _MakeConfig(),
            open_related={9999: 'some irrelevant issue'},
            closed_related={},
            all_related=all_related)
        self.assertEqual([None, None, 'Issue 4999 in codesite.'],
                         [irv.summary for irv in view2.blocked_on])
        self.assertEqual([None, None, 'Issue 5001 in codesite.'],
                         [irv.summary for irv in view2.blocking])
        self.assertFalse(view2.multiple_blocked_on)
 def testFederatedIssue(self):
     ref = tracker_pb2.DanglingIssueRef(ext_issue_identifier='b/5678')
     view = tracker_views.DanglingIssueRefView(ref)
     self.assertTrue(view.visible)
     self.assertTrue(view.is_open)
     self.assertTrue(view.is_dangling)
     self.assertEqual(view.url,
                      'https://issuetracker.google.com/issues/5678')
     self.assertEqual(view.display_name, 'b/5678')
     self.assertEqual(view.short_name, 'b/5678')
     self.assertEqual(view.summary, 'Google Issue Tracker issue 5678.')
     self.assertEqual(view.issue_ref, 'b/5678')
 def testNormal(self):
     ref = tracker_pb2.DanglingIssueRef(issue_id=123, project='rutabaga')
     view = tracker_views.DanglingIssueRefView(ref)
     self.assertTrue(view.visible)
     self.assertTrue(view.is_open)
     self.assertTrue(view.is_dangling)
     self.assertEqual(
         view.url,
         'https://code.google.com/p/rutabaga/issues/detail?id=123')
     self.assertEqual(view.display_name, 'issue rutabaga:123')
     self.assertEqual(view.short_name, 'issue rutabaga:123')
     self.assertEqual(view.summary, 'Issue 123 in rutabaga.')
     self.assertEqual(view.issue_ref, 'rutabaga:123')
    def setUp(self):
        self.issue1 = _Issue('proj', 1, 'not too long summary', 'New')
        self.issue2 = _Issue('proj', 2, 'sum 2', '')
        self.issue3 = _Issue('proj', 3, 'sum 3', '')
        self.issue4 = _Issue('proj', 4, 'sum 4', '')

        self.issue1.reporter_id = 1002
        self.issue1.owner_id = 2002
        self.issue1.labels.extend(['A', 'B'])
        self.issue1.derived_labels.extend(['C', 'D'])

        self.issue2.reporter_id = 2002
        self.issue2.labels.extend(['foo', 'bar'])
        self.issue2.blocked_on_iids.extend(
            [self.issue1.issue_id, self.issue3.issue_id])
        self.issue2.blocking_iids.extend(
            [self.issue1.issue_id, self.issue4.issue_id])
        dref = tracker_pb2.DanglingIssueRef()
        dref.project = 'codesite'
        dref.issue_id = 5001
        self.issue2.dangling_blocking_refs.append(dref)

        self.issue3.reporter_id = 3002
        self.issue3.labels.extend(['Hot'])

        self.issue4.reporter_id = 3002
        self.issue4.labels.extend(['Foo', 'Bar'])

        self.restricted = _Issue('proj', 7, 'summary 7', '')
        self.restricted.labels.extend(
            ['Restrict-View-Commit', 'Restrict-View-MyCustomPerm'])
        self.restricted.derived_labels.extend([
            'Restrict-AddIssueComment-Commit', 'Restrict-EditIssue-Commit',
            'Restrict-Action-NeededPerm'
        ])

        self.users_by_id = {
            0: 'user 0',
            1002: 'user 1002',
            2002: 'user 2002',
            3002: 'user 3002',
            4002: 'user 4002',
        }
 def testDebugString(self):
     ref = tracker_pb2.DanglingIssueRef(issue_id=123, project='rutabaga')
     view = tracker_views.DanglingIssueRefView(ref)
     self.assertEqual(view.DebugString(),
                      'DanglingIssueRefView(issue rutabaga:123)')
示例#6
0
def MakeDanglingIssueRef(project_name, issue_id):
    """Create a DanglingIssueRef pb."""
    ret = tracker_pb2.DanglingIssueRef()
    ret.project = project_name
    ret.issue_id = issue_id
    return ret