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 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)