Ejemplo n.º 1
0
    def test_find_issues(self):
        """Test find_issues."""
        issue0 = MonorailIssue()
        issue0.id = 1

        issue1 = MonorailIssue()
        issue1.id = 2
        self.mock.get_issues.return_value = [
            issue0,
            issue1,
        ]
        issues = self.issue_tracker.find_issues(keywords=['one', 'two'],
                                                only_open=True)
        six.assertCountEqual(self, [1, 2], [issue.id for issue in issues])

        self.mock.get_issues.assert_has_calls([
            mock.call(mock.ANY, '"one" "two"', can='open'),
        ])

        issues = self.issue_tracker.find_issues(keywords=['one', 'two'],
                                                only_open=False)
        six.assertCountEqual(self, [1, 2], [issue.id for issue in issues])

        self.mock.get_issues.assert_has_calls([
            mock.call(mock.ANY, '"one" "two"', can='all'),
        ])
Ejemplo 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)
    def get_original_issue(self, issue_id):
        """Get original issue."""
        issue = Issue()
        issue.open = True
        issue.itm = self
        issue.id = issue_id

        if issue_id == 1337:
            issue.add_cc('*****@*****.**')
            issue.add_label('Restrict-View-Commit')
        elif issue_id == 1338:
            issue.add_cc('*****@*****.**')
            issue.add_cc('*****@*****.**')
        elif issue_id == 1340:
            issue.add_label('reported-2015-01-01')

        return issue
Ejemplo n.º 4
0
def get_original_issue(self, issue_id):
  """Get original issue."""
  issue_id = int(issue_id)

  issue = Issue()
  issue.open = True
  issue.itm = self._itm  # pylint: disable=protected-access
  issue.id = issue_id

  if issue_id == 1337:
    issue.add_cc('*****@*****.**')
    issue.add_label('Restrict-View-Commit')
  elif issue_id == 1338:
    issue.add_cc('*****@*****.**')
    issue.add_cc('*****@*****.**')
  elif issue_id == 1340:
    issue.add_label('reported-2015-01-01')

  return monorail.Issue(issue)
Ejemplo n.º 5
0
def create_generic_issue(created_days_ago=28):
  """Returns a simple issue object for use in tests."""
  issue = Issue()
  issue.cc = []
  issue.comment = ''
  issue.comments = []
  issue.components = []
  issue.labels = []
  issue.open = True
  issue.owner = '*****@*****.**'
  issue.status = 'Assigned'
  issue.id = 1
  issue.itm = create_issue_tracker_manager()

  # Test issue was created 1 week before the current (mocked) time.
  issue.created = (
      test_utils.CURRENT_TIME - datetime.timedelta(days=created_days_ago))

  return monorail.Issue(issue)