Exemple #1
0
    def test_commit_with_noexport_is_not_exportable(self):
        # Patch is not tested if the commit is ignored based on the message, hence empty MockLocalWPT.

        commit = MockChromiumCommit(MockHost(),
                                    body='Message\nNo-Export: true')
        github = MockWPTGitHub(pull_requests=[])
        self.assertEqual(
            get_commit_export_state(commit, MockLocalWPT(), github),
            (CommitExportState.IGNORED, ''))

        # The older NOEXPORT tag also makes it non-exportable.
        old_commit = MockChromiumCommit(MockHost(),
                                        body='Message\nNOEXPORT=true')
        self.assertEqual(
            get_commit_export_state(old_commit, MockLocalWPT(), github),
            (CommitExportState.IGNORED, ''))

        # No-Export/NOEXPORT in a revert CL also makes it non-exportable.
        revert = MockChromiumCommit(
            MockHost(), body='Revert of Message\n> No-Export: true')
        self.assertEqual(
            get_commit_export_state(revert, MockLocalWPT(), github),
            (CommitExportState.IGNORED, ''))
        old_revert = MockChromiumCommit(
            MockHost(), body='Revert of Message\n> NOEXPORT=true')
        self.assertEqual(
            get_commit_export_state(old_revert, MockLocalWPT(), github),
            (CommitExportState.IGNORED, ''))
 def test_commit_that_has_merged_pr_and_found_locally(self):
     commit = MockChromiumCommit(MockHost(), change_id='I00decade')
     github = MockWPTGitHub(pull_requests=[
         PullRequest('PR2', 2, 'body\nChange-Id: I00decade', 'closed', []),
     ], merged_index=0)
     self.assertEqual(get_commit_export_state(commit, MockLocalWPT(change_ids=['I00decade']), github, verify_merged_pr=False),
                      (CommitExportState.EXPORTED, ''))
     self.assertEqual(get_commit_export_state(commit, MockLocalWPT(change_ids=['I00decade']), github, verify_merged_pr=True),
                      (CommitExportState.EXPORTED, ''))
 def test_commit_that_has_merged_pr_but_not_found_locally(self):
     commit = MockChromiumCommit(MockHost(), change_id='I00decade')
     github = MockWPTGitHub(pull_requests=[
         PullRequest('PR2', 2, 'body\nChange-Id: I00decade', 'closed', []),
     ], merged_index=0)
     # verify_merged_pr should be False by default.
     self.assertEqual(get_commit_export_state(commit, MockLocalWPT(), github),
                      (CommitExportState.EXPORTED, ''))
     self.assertEqual(get_commit_export_state(commit, MockLocalWPT(test_patch=[(True, '')]), github, verify_merged_pr=True),
                      (CommitExportState.EXPORTABLE_CLEAN, ''))
 def test_commit_that_has_closed_but_not_merged_pr(self):
     commit = MockChromiumCommit(MockHost(), change_id='I00decade')
     github = MockWPTGitHub(pull_requests=[
         PullRequest('PR2', 2, 'body\nChange-Id: I00decade', 'closed', []),
     ])
     # Regardless of verify_merged_pr, abandoned PRs are always exported.
     self.assertEqual(get_commit_export_state(commit, MockLocalWPT(), github, verify_merged_pr=False),
                      (CommitExportState.EXPORTED, ''))
     self.assertEqual(get_commit_export_state(commit, MockLocalWPT(), github, verify_merged_pr=True),
                      (CommitExportState.EXPORTED, ''))
Exemple #5
0
 def test_commit_that_produces_errors(self):
     commit = MockChromiumCommit(MockHost())
     github = MockWPTGitHub(pull_requests=[])
     self.assertEqual(
         get_commit_export_state(
             commit, MockLocalWPT(test_patch=[(False, 'error')]), github),
         (CommitExportState.EXPORTABLE_DIRTY, 'error'))
 def test_commit_that_has_open_pr_is_exportable(self):
     commit = MockChromiumCommit(MockHost(), change_id='I00decade')
     github = MockWPTGitHub(pull_requests=[
         PullRequest('PR2', 2, 'body\nChange-Id: I00decade', 'open', []),
     ])
     self.assertEqual(get_commit_export_state(commit, MockLocalWPT(test_patch=[(True, '')]), github),
                      (CommitExportState.EXPORTABLE_CLEAN, ''))
Exemple #7
0
 def test_get_commit_export_state(self):
     commit = MockChromiumCommit(MockHost())
     github = MockWPTGitHub(pull_requests=[])
     self.assertEqual(
         get_commit_export_state(commit,
                                 MockLocalWPT(test_patch=[(True, '')]),
                                 github),
         (CommitExportState.EXPORTABLE_CLEAN, ''))
 def test_commit_that_starts_with_import_is_exportable(self):
     commit = MockChromiumCommit(MockHost(), subject='Import message')
     github = MockWPTGitHub(pull_requests=[])
     self.assertEqual(
         get_commit_export_state(commit,
                                 MockLocalWPT(test_patch=[(True, '')]),
                                 github),
         (CommitExportState.EXPORTABLE_CLEAN, ''))
    def test_commit_with_noexport_is_not_exportable_mixed_casing(self):
        # Patch is not tested if the commit is ignored based on the message, hence empty MockLocalWPT.
        # Make sure that the casing of the "No export" message isn't considered.

        commit = MockChromiumCommit(MockHost(),
                                    body='Message\nno-EXPORT: true')
        github = MockWPTGitHub(pull_requests=[])
        self.assertEqual(
            get_commit_export_state(commit, MockLocalWPT(), github),
            (CommitExportState.IGNORED, ''))

        commit = MockChromiumCommit(MockHost(), body='Message\nnoexport=TRUE')
        github = MockWPTGitHub(pull_requests=[])
        self.assertEqual(
            get_commit_export_state(commit, MockLocalWPT(), github),
            (CommitExportState.IGNORED, ''))

        commit = MockChromiumCommit(MockHost(),
                                    body='Message\nNO-exPORT: trUE')
        github = MockWPTGitHub(pull_requests=[])
        self.assertEqual(
            get_commit_export_state(commit, MockLocalWPT(), github),
            (CommitExportState.IGNORED, ''))
Exemple #10
0
 def test_commit_that_starts_with_import_is_not_exportable(self):
     commit = MockChromiumCommit(MockHost(), subject='Import message')
     github = MockWPTGitHub(pull_requests=[])
     self.assertEqual(
         get_commit_export_state(commit, MockLocalWPT(), github),
         (CommitExportState.IGNORED, ''))