Esempio n. 1
0
def create_generic_issue_comment(comment_body='Comment.',
                                 author='*****@*****.**',
                                 days_ago=21,
                                 labels=None):
  """Return a simple comment used for testing."""
  comment = Comment()
  comment.comment = comment_body
  comment.author = author
  comment.created = test_utils.CURRENT_TIME - datetime.timedelta(days=days_ago)
  comment.labels = labels

  if comment.labels is None:
    comment.labels = []

  return comment
Esempio n. 2
0
    def setUp(self):
        helpers.patch(self, [
            'libs.issue_management.monorail.issue_tracker_manager.'
            'IssueTrackerManager.get_issues',
        ])

        mock_issue = MonorailIssue()
        mock_issue.id = 1337
        mock_issue.summary = 'summary'
        mock_issue.body = 'body'
        mock_issue.owner = 'owner'
        mock_issue.reporter = 'reporter'
        mock_issue.status = 'New'
        mock_issue.add_label('label1')
        mock_issue.add_label('label2')
        mock_issue.add_component('A>B')
        mock_issue.add_component('C>D')
        mock_issue.add_cc('*****@*****.**')

        mock_comment0 = MonorailComment()
        mock_comment0.author = 'author'
        mock_comment0.cc = ['*****@*****.**', '*****@*****.**']
        mock_comment0.labels = ['-label0', 'label1']
        mock_comment0.components = ['-E>F', 'A>B']
        mock_comment0.comment = 'comment'
        mock_comment0.summary = 'summary'
        mock_comment0.status = 'status'
        mock_comment0.owner = 'owner'

        mock_comment1 = MonorailComment()
        mock_comment1.author = 'author'
        mock_comment1.comment = 'comment'

        mock_issue.comments = [
            mock_comment0,
            mock_comment1,
        ]

        mock_issue_merged = MonorailIssue()
        mock_issue_merged.id = 1338
        mock_issue_merged.merged_into = 1337
        mock_issue_merged.merged_into_project = 'project'
        mock_issue_merged.closed = datetime.datetime(2019, 1, 1)

        mock_issue_merged_another_project = MonorailIssue()
        mock_issue_merged_another_project.id = 1339
        mock_issue_merged_another_project.merged_into = 1
        mock_issue_merged_another_project.merged_into_project = 'different-project'

        mock_issues = {
            1337: mock_issue,
            1338: mock_issue_merged,
            1339: mock_issue_merged_another_project,
        }

        self.itm = IssueTrackerManager('project', mock_issues)
        self.issue_tracker = monorail.IssueTracker(self.itm)