def test_is_pull_request_ready_for_automerge_after_tests_no_review(self):
     pull_request = build(builder.pull_request().commit(
         builder.commit().status(Commit.BUILD_SUCCESSFUL)
     ).title("blah blah [shipit]").mergeable(
         MergeableState.MERGEABLE).merged(False).label(builder.label().name(
             github_logic.AutomergeLabel.AFTER_TESTS_AND_APPROVAL.value)))
     self.assertFalse(
         github_logic._is_pull_request_ready_for_automerge(pull_request))
 def test_is_pull_request_ready_for_automerge_no_automerge_label(self):
     pull_request = build(builder.pull_request().commit(
         builder.commit().status(Commit.BUILD_SUCCESSFUL)).review(
             builder.review().submitted_at("2020-01-13T14:59:58Z").state(
                 ReviewState.APPROVED)).mergeable(
                     MergeableState.MERGEABLE).merged(False).label(
                         builder.label().name("random label")))
     self.assertFalse(
         github_logic._is_pull_request_ready_for_automerge(pull_request))
 def test_is_pull_request_ready_for_automerge_immediately_conflicting(self):
     pull_request = build(builder.pull_request().commit(
         builder.commit().status(Commit.BUILD_FAILED)).review(
             builder.review().submitted_at("2020-01-13T14:59:58Z").state(
                 ReviewState.CHANGES_REQUESTED)).mergeable(
                     MergeableState.CONFLICTING).merged(False).label(
                         builder.label().name(github_logic.AutomergeLabel.
                                              IMMEDIATELY.value)))
     self.assertFalse(
         github_logic._is_pull_request_ready_for_automerge(pull_request))
 def test_is_pull_request_ready_for_automerge_after_tests(self):
     pull_request = build(builder.pull_request().commit(
         builder.commit().status(Commit.BUILD_SUCCESSFUL)).review(
             builder.review().submitted_at("2020-01-13T14:59:58Z").state(
                 ReviewState.CHANGES_REQUESTED)).mergeable(
                     MergeableState.MERGEABLE).merged(False).label(
                         builder.label().name(github_logic.AutomergeLabel.
                                              AFTER_TESTS.value)))
     self.assertTrue(
         github_logic._is_pull_request_ready_for_automerge(pull_request))
 def test_is_pull_request_ready_for_automerge_build_pending(self):
     pull_request = build(builder.pull_request().commit(
         builder.commit().status(Commit.BUILD_PENDING)).review(
             builder.review().submitted_at("2020-01-13T14:59:58Z").state(
                 ReviewState.APPROVED)).mergeable(
                     MergeableState.MERGEABLE).merged(False).label(
                         builder.label().name(github_logic.AutomergeLabel.
                                              AFTER_TESTS.value)))
     self.assertFalse(
         github_logic._is_pull_request_ready_for_automerge(pull_request))
 def test_is_pull_request_ready_for_automerge_autofail_if_merged(self):
     pull_request = build(builder.pull_request().commit(
         builder.commit().status(Commit.BUILD_SUCCESSFUL)).review(
             builder.review().submitted_at("2020-01-13T14:59:58Z").state(
                 ReviewState.APPROVED)).mergeable(
                     MergeableState.MERGEABLE).merged(True).closed(
                         False).label(builder.label().name(
                             github_logic.AutomergeLabel.
                             AFTER_TESTS_AND_APPROVAL.value)))
     self.assertFalse(
         github_logic._is_pull_request_ready_for_automerge(pull_request))
 def test_is_pull_request_ready_for_automerge_after_tests_mergeable_is_false(
         self):
     pull_request = build(builder.pull_request().commit(
         builder.commit().status(Commit.BUILD_SUCCESSFUL)).review(
             builder.review().submitted_at("2020-01-13T14:59:58Z").state(
                 ReviewState.APPROVED)).mergeable(
                     MergeableState.CONFLICTING).merged(False).label(
                         builder.label().name(github_logic.AutomergeLabel.
                                              AFTER_TESTS.value)))
     self.assertFalse(
         github_logic._is_pull_request_ready_for_automerge(pull_request))
 def test_is_pull_request_ready_for_automerge_after_approval(self):
     pull_request = build(
         builder.pull_request().commit(
             builder.commit().status(Commit.BUILD_PENDING)
         )  # build hasn't finished, but PR is approved
         .review(builder.review().submitted_at(
             "2020-01-13T14:59:58Z").state(ReviewState.APPROVED)).mergeable(
                 MergeableState.MERGEABLE).merged(False).label(
                     builder.label().name(
                         github_logic.AutomergeLabel.AFTER_APPROVAL.value)))
     self.assertTrue(
         github_logic._is_pull_request_ready_for_automerge(pull_request))
 def test_is_pull_request_ready_for_automerge_after_approval_approved_and_requested_changes(
     self, ):
     author_1 = builder.user().login("author_1")
     author_2 = builder.user().login("author_2")
     pull_request = build(builder.pull_request().commit(
         builder.commit().status(Commit.BUILD_SUCCESSFUL)).reviews([
             builder.review().submitted_at("2020-01-11T14:59:58Z").state(
                 ReviewState.CHANGES_REQUESTED).author(author_1),
             builder.review().submitted_at("2020-01-12T14:59:58Z").state(
                 ReviewState.APPROVED).author(author_2),
         ]).mergeable(MergeableState.MERGEABLE).merged(False).label(
             builder.label().name(github_logic.AutomergeLabel.
                                  AFTER_TESTS_AND_APPROVAL.value)))
     self.assertFalse(
         github_logic._is_pull_request_ready_for_automerge(pull_request))