def test_A_Breathing(self):
        test_data = phldef_conduit
        conduit = phlsys_conduit.Conduit(
            test_data.TEST_URI,
            test_data.PHAB.user,
            test_data.PHAB.certificate)

        revision_id = phlcon_differential.create_empty_revision(conduit)

        cache = phlcon_reviewstatecache.ReviewStateCache()
        cache.set_conduit(conduit)

        # assert it's in 'needs review'
        self.assertEqual(
            cache.get_status(revision_id),
            phlcon_differential.ReviewStates.needs_review)

        # change real state to 'abandoned'
        phlcon_differential.create_comment(
            conduit,
            revisionId=revision_id,
            action=phlcon_differential.Action.abandon)

        # check that the cache still reports 'needs_review'
        self.assertEqual(
            cache.get_status(revision_id),
            phlcon_differential.ReviewStates.needs_review)

        # refresh the cache
        cache.refresh_active_reviews()

        # check that the cache now reports 'abandoned'
        self.assertEqual(
            cache.get_status(revision_id),
            phlcon_differential.ReviewStates.abandoned)
 def test_A_Breathing(self):
     rev_id = self._createNonEmptyRevision('test_A_Breathing')
     conduit = self.phabConduit
     phlcon_differential.create_inline_comment(
         conduit, rev_id, 'readme', 2, 'this is an inline comment')
     phlcon_differential.create_inline_comment(
         conduit, rev_id, 'readme', 3, 'this another inline comment')
     phlcon_differential.create_comment(
         conduit, rev_id, 'this is a message', attach_inlines=True)
Exemplo n.º 3
0
 def test_A_Breathing(self):
     rev_id = self._createNonEmptyRevision('test_A_Breathing')
     conduit = self.phabConduit
     phlcon_differential.create_inline_comment(
         conduit, rev_id, 'readme', 2, 'this is an inline comment')
     phlcon_differential.create_inline_comment(
         conduit, rev_id, 'readme', 3, 'this another inline comment')
     phlcon_differential.create_comment(
         conduit, rev_id, 'this is a message', attach_inlines=True)
    def create_comment(self, revision, message, silent=False):
        """Make a comment on the specified 'revision'.

        :revision: id of the revision to comment on
        :message: the string message to leave as a comment, may be empty
        :silent: mail notifications won't be sent if False
        :returns: None

        """
        phlcon_differential.create_comment(
            self._conduit, revision, message, silent=silent)
def processUpdatedBranch(
        mailer, conduit, gitContext, review_branch, working_branch):
    abdte = abdt_exception
    if working_branch is None:
        print "create review for " + review_branch.branch
        tryCreateReview(
            mailer, conduit, gitContext, review_branch, mail_on_fail=True)
    else:
        commenter = abdcmnt_commenter.Commenter(conduit, working_branch.id)
        if abdt_naming.isStatusBadPreReview(working_branch):
            hasChanged = not phlgit_branch.is_identical(
                gitContext.clone,
                review_branch.remote_branch,
                working_branch.remote_branch)
            print "try again to create review for " + review_branch.branch
            phlgit_push.delete(
                gitContext.clone,
                working_branch.branch,
                gitContext.remote)
            tryCreateReview(
                mailer,
                conduit,
                gitContext,
                review_branch,
                mail_on_fail=hasChanged)
        else:
            print "update review for " + review_branch.branch
            revision = phlcon_differential.query(
                conduit, [working_branch.id])[0]
            author_user = phlcon_user.query_usernames_from_phids(
                conduit, [revision.authorPHID])[0]
            try:
                updateReview(
                    conduit,
                    gitContext,
                    review_branch,
                    working_branch,
                    author_user)
            except abdte.LandingException as e:
                print "landing exception"
                abdt_workingbranch.pushBadLand(
                    gitContext, review_branch, working_branch)
                commenter.exception(e)
                with phlsys_conduit.act_as_user_context(conduit, author_user):
                    phlcon_differential.create_comment(
                        conduit,
                        working_branch.id,
                        action=phlcon_differential.Action.rethink)
            except abdte.AbdUserException as e:
                print "user exception"
                abdt_workingbranch.pushBadInReview(
                    gitContext, review_branch, working_branch)
                commenter.exception(e)
 def test_B_AcceptedPersistsWhenUpdated(self):
     conduit = self.phabConduit
     author = phldef_conduit.ALICE.user
     reviewer = phldef_conduit.BOB.user
     with phlsys_conduit.act_as_user_context(conduit, author):
         revision = phlcon_differential.create_empty_revision(conduit)
     with phlsys_conduit.act_as_user_context(conduit, reviewer):
         phlcon_differential.create_comment(conduit, revision, action=phlcon_differential.Action.accept)
     with phlsys_conduit.act_as_user_context(conduit, author):
         phlcon_differential.update_revision_empty(conduit, revision)
     self.assertEqual(
         phlcon_differential.get_revision_status(conduit, revision), phlcon_differential.ReviewStates.accepted
     )
Exemplo n.º 7
0
    def create_comment(self, revision, message, silent=False):
        """Make a comment on the specified 'revision'.

        :revision: id of the revision to comment on
        :message: the string message to leave as a comment, may be empty
        :silent: mail notifications won't be sent if False
        :returns: None

        """
        with self._log_context(
                'conduit-comment', 'commented on {}'.format(revision)):
            phlcon_differential.create_comment(
                self._multi_conduit, revision, message, silent=silent)
    def set_requires_revision(self, revisionid):
        """Set an existing Differential revision to 'requires revision'.

        :revisionid: id of the Differential revision to update
        :returns: None

        """
        author_user = self._get_author_user(revisionid)
        with phlsys_conduit.act_as_user_context(self._conduit, author_user):
            phlcon_differential.create_comment(
                self._conduit,
                revisionid,
                action=phlcon_differential.Action.rethink)
    def abandon_revision(self, revisionid):
        """Set an existing Differential revision to 'abandoned'.

        :revisionid: id of the Differential revision to close
        :returns: None

        """
        author_user = self._get_author_user(revisionid)
        with phlsys_conduit.act_as_user_context(self._conduit, author_user):
            phlcon_differential.create_comment(
                self._conduit,
                revisionid,
                action=phlcon_differential.Action.abandon)
    def accept_revision_as_user(self, revisionid, username):
        """Set an existing Differential revision to 'accepted'.

        :revisionid: id of the Differential revision to accept
        :username: username for the reviewer of the revision
        :returns: None

        """
        with phlsys_conduit.act_as_user_context(self._conduit, username):
            phlcon_differential.create_comment(
                self._conduit,
                revisionid,
                action=phlcon_differential.Action.accept)
    def commandeer_revision_as_user(self, revisionid, username):
        """Change the author of a revision to the specified 'username'.

        :revisionid: id of the Differential revision to claim
        :username: username for the author of the revision
        :returns: None

        """
        with phlsys_conduit.act_as_user_context(self._conduit, username):
            phlcon_differential.create_comment(
                self._conduit,
                revisionid,
                action=phlcon_differential.Action.claim)
Exemplo n.º 12
0
    def create_comment(self, revision, message, silent=False):
        """Make a comment on the specified 'revision'.

        :revision: id of the revision to comment on
        :message: the string message to leave as a comment, may be empty
        :silent: mail notifications won't be sent if False
        :returns: None

        """
        with self._log_context('conduit-comment',
                               'commented on {}'.format(revision)):
            phlcon_differential.create_comment(self._multi_conduit,
                                               revision,
                                               message,
                                               silent=silent)
Exemplo n.º 13
0
 def test_B_AcceptedPersistsWhenUpdated(self):
     conduit = self.phabConduit
     author = phldef_conduit.ALICE.user
     reviewer = phldef_conduit.BOB.user
     with phlsys_conduit.act_as_user_context(conduit, author):
         revision = phlcon_differential.create_empty_revision(conduit)
     with phlsys_conduit.act_as_user_context(conduit, reviewer):
         phlcon_differential.create_comment(
             conduit,
             revision,
             action=phlcon_differential.Action.accept)
     with phlsys_conduit.act_as_user_context(conduit, author):
         phlcon_differential.update_revision_empty(conduit, revision)
     self.assertEqual(
         phlcon_differential.get_revision_status(conduit, revision),
         phlcon_differential.ReviewStates.accepted)
    def test_commandeeredUpdate(self):
        self._devCheckoutPushNewBranch("ph-review/commandeeredUpdate/master")
        self._devPushNewFile("NEWFILE")
        self._phabUpdateWithExpectations(total=1, bad=0)

        reviewid = self._getTheOnlyReviewId()
        with phlsys_conduit.act_as_user_context(
                self.conduit,
                phldef_conduit.ALICE.user) as conduit:
            phlcon_differential.create_comment(
                conduit,
                reviewid,
                action=phlcon_differential.Action.claim)

        self._devPushNewFile("NEWFILE2")
        self._phabUpdateWithExpectations(total=1, bad=0)
Exemplo n.º 15
0
    def accept_revision_as_user(self, revisionid, username):
        """Set an existing Differential revision to 'accepted'.

        :revisionid: id of the Differential revision to accept
        :username: username for the reviewer of the revision
        :returns: None

        """
        as_user_conduit = self._make_as_user_conduit(username)
        with self._log_context('conduit-accept',
                               'accept {} as {}'.format(revisionid, username)):

            phlcon_differential.create_comment(
                as_user_conduit,
                revisionid,
                action=phlcon_differential.Action.accept)
Exemplo n.º 16
0
    def commandeer_revision_as_user(self, revisionid, username):
        """Change the author of a revision to the specified 'username'.

        :revisionid: id of the Differential revision to claim
        :username: username for the author of the revision
        :returns: None

        """
        as_user_conduit = self._make_as_user_conduit(username)
        with self._log_context(
                'conduit-commandeer',
                'commandeer {} as {}'.format(revisionid, username)):
            phlcon_differential.create_comment(
                as_user_conduit,
                revisionid,
                action=phlcon_differential.Action.claim)
Exemplo n.º 17
0
    def commandeer_revision_as_user(self, revisionid, username):
        """Change the author of a revision to the specified 'username'.

        :revisionid: id of the Differential revision to claim
        :username: username for the author of the revision
        :returns: None

        """
        as_user_conduit = self._make_as_user_conduit(username)
        with self._log_context(
                'conduit-commandeer',
                'commandeer {} as {}'.format(revisionid, username)):
            phlcon_differential.create_comment(
                as_user_conduit,
                revisionid,
                action=phlcon_differential.Action.claim)
Exemplo n.º 18
0
    def accept_revision_as_user(self, revisionid, username):
        """Set an existing Differential revision to 'accepted'.

        :revisionid: id of the Differential revision to accept
        :username: username for the reviewer of the revision
        :returns: None

        """
        as_user_conduit = self._make_as_user_conduit(username)
        with self._log_context(
                'conduit-accept',
                'accept {} as {}'.format(revisionid, username)):

            phlcon_differential.create_comment(
                as_user_conduit,
                revisionid,
                action=phlcon_differential.Action.accept)
Exemplo n.º 19
0
    def abandon_revision(self, revisionid):
        """Set an existing Differential revision to 'abandoned'.

        :revisionid: id of the Differential revision to close
        :returns: None

        """
        author_user = self._get_author_user(revisionid)
        as_user_conduit = self._make_as_user_conduit(author_user)
        with self._log_context(
                'conduit-abandon',
                'abandon {} as {}'.format(revisionid, author_user)):

            phlcon_differential.create_comment(
                as_user_conduit,
                revisionid,
                action=phlcon_differential.Action.abandon)
Exemplo n.º 20
0
    def abandon_revision(self, revisionid):
        """Set an existing Differential revision to 'abandoned'.

        :revisionid: id of the Differential revision to close
        :returns: None

        """
        author_user = self._get_author_user(revisionid)
        as_user_conduit = self._make_as_user_conduit(author_user)
        with self._log_context(
                'conduit-abandon',
                'abandon {} as {}'.format(revisionid, author_user)):

            phlcon_differential.create_comment(
                as_user_conduit,
                revisionid,
                action=phlcon_differential.Action.abandon)
Exemplo n.º 21
0
    def set_requires_revision(self, revisionid):
        """Set an existing Differential revision to 'requires revision'.

        :revisionid: id of the Differential revision to update
        :returns: None

        """
        author_user = self._get_author_user(revisionid)
        as_user_conduit = self._make_as_user_conduit(author_user)
        with self._log_context(
                'conduit-setrequiresrev',
                'update {} as {}'.format(revisionid, author_user)):

            phlcon_differential.create_comment(
                as_user_conduit,
                revisionid,
                action=phlcon_differential.Action.rethink)
Exemplo n.º 22
0
    def set_requires_revision(self, revisionid):
        """Set an existing Differential revision to 'requires revision'.

        :revisionid: id of the Differential revision to update
        :returns: None

        """
        author_user = self._get_author_user(revisionid)
        as_user_conduit = self._make_as_user_conduit(author_user)
        with self._log_context(
                'conduit-setrequiresrev',
                'update {} as {}'.format(revisionid, author_user)):

            phlcon_differential.create_comment(
                as_user_conduit,
                revisionid,
                action=phlcon_differential.Action.rethink)
    def test_C_CantUpdateClosedReviews(self):
        conduit = self.phabConduit
        author = phldef_conduit.ALICE.user
        reviewer = phldef_conduit.BOB.user
        with phlsys_conduit.act_as_user_context(conduit, author):
            revision = phlcon_differential.create_empty_revision(conduit)
        with phlsys_conduit.act_as_user_context(conduit, reviewer):
            phlcon_differential.create_comment(conduit, revision, action=phlcon_differential.Action.accept)
        with phlsys_conduit.act_as_user_context(conduit, author):
            phlcon_differential.create_comment(conduit, revision, action=phlcon_differential.Action.close)
            self.assertRaises(
                phlcon_differential.UpdateClosedRevisionError,
                phlcon_differential.update_revision_empty,
                conduit,
                revision,
            )

            # expect that we can close a closed revision without errors
            phlcon_differential.close(conduit, revision)
    def test_A_Breathing(self):
        test_data = phldef_conduit
        conduit = phlsys_conduit.Conduit(
            test_data.TEST_URI,
            test_data.PHAB.user,
            test_data.PHAB.certificate)

        revision_id = phlcon_differential.create_empty_revision(conduit)

        cache = phlcon_reviewstatecache.make_from_conduit(conduit)

        # shouldn't have active reviews to start with
        self.assertEqual(set(), cache.active_reviews)

        # assert it's in 'needs review'
        self.assertEqual(
            cache.get_state(revision_id).status,
            phlcon_differential.ReviewStates.needs_review)

        # should now have cached the review
        self.assertEqual(set((revision_id,)), cache.active_reviews)

        # change real state to 'abandoned'
        phlcon_differential.create_comment(
            conduit,
            revisionId=revision_id,
            action=phlcon_differential.Action.abandon)

        # check that the cache still reports 'needs_review'
        self.assertEqual(
            cache.get_state(revision_id).status,
            phlcon_differential.ReviewStates.needs_review)

        # refresh the cache
        cache.refresh_active_reviews()

        # check that the cache now reports 'abandoned'
        self.assertEqual(
            cache.get_state(revision_id).status,
            phlcon_differential.ReviewStates.abandoned)
    def test_A_Breathing(self):
        test_data = phldef_conduit
        conduit = phlsys_conduit.Conduit(test_data.TEST_URI,
                                         test_data.PHAB.user,
                                         test_data.PHAB.certificate)

        revision_id = phlcon_differential.create_empty_revision(conduit)

        cache = phlcon_reviewstatecache.make_from_conduit(conduit)

        # shouldn't have active reviews to start with
        self.assertEqual(set(), cache.active_reviews)

        # assert it's in 'needs review'
        self.assertEqual(
            cache.get_state(revision_id).status,
            phlcon_differential.ReviewStates.needs_review)

        # should now have cached the review
        self.assertEqual(set((revision_id, )), cache.active_reviews)

        # change real state to 'abandoned'
        phlcon_differential.create_comment(
            conduit,
            revisionId=revision_id,
            action=phlcon_differential.Action.abandon)

        # check that the cache still reports 'needs_review'
        self.assertEqual(
            cache.get_state(revision_id).status,
            phlcon_differential.ReviewStates.needs_review)

        # refresh the cache
        cache.refresh_active_reviews()

        # check that the cache now reports 'abandoned'
        self.assertEqual(
            cache.get_state(revision_id).status,
            phlcon_differential.ReviewStates.abandoned)
Exemplo n.º 26
0
    def test_C_CantUpdateClosedReviews(self):
        conduit = self.phabConduit
        author = phldef_conduit.ALICE.user
        reviewer = phldef_conduit.BOB.user
        with phlsys_conduit.act_as_user_context(conduit, author):
            revision = phlcon_differential.create_empty_revision(conduit)
        with phlsys_conduit.act_as_user_context(conduit, reviewer):
            phlcon_differential.create_comment(
                conduit,
                revision,
                action=phlcon_differential.Action.accept)
        with phlsys_conduit.act_as_user_context(conduit, author):
            phlcon_differential.create_comment(
                conduit,
                revision,
                action=phlcon_differential.Action.close)
            self.assertRaises(
                phlcon_differential.UpdateClosedRevisionError,
                phlcon_differential.update_revision_empty,
                conduit,
                revision)

            # expect that we can close a closed revision without errors
            phlcon_differential.close(conduit, revision)
Exemplo n.º 27
0
def process(args):
    conduit = phlsys_makeconduit.make_conduit(args.uri, args.user, args.cert,
                                              args.act_as_user)

    d = {
        'message': args.message,
        'silent': args.silent,
        'action': phlcon_differential.USER_ACTIONS[args.action],
        'attach_inlines': args.attach_inlines
    }

    if args.message_file:
        d['message'] += args.message_file.read()

    ids = args.ids
    if args.ids_file:
        ids.extend([int(i) for i in args.ids_file.read().split()])

    if not ids:
        print("error: you have not specified any revision ids")
        sys.exit(1)

    for i in ids:
        phlcon_differential.create_comment(conduit, i, **d)
Exemplo n.º 28
0
def process(args):
    conduit = phlsys_makeconduit.make_conduit(
        args.uri, args.user, args.cert, args.act_as_user)

    d = {
        'message': args.message,
        'silent': args.silent,
        'action': phlcon_differential.USER_ACTIONS[args.action],
        'attach_inlines': args.attach_inlines
    }

    if args.message_file:
        d['message'] += args.message_file.read()

    ids = args.ids
    if args.ids_file:
        ids.extend([int(i) for i in args.ids_file.read().split()])

    if not ids:
        print("error: you have not specified any revision ids")
        sys.exit(1)

    for i in ids:
        phlcon_differential.create_comment(conduit, i, **d)
Exemplo n.º 29
0
 def _reviewCommentAction(self, revisionid, action):
     phlcon_differential.create_comment(
         self.reviewerConduit, revisionid, action=action)
Exemplo n.º 30
0
    def test_A_Breathing(self):
        # [ A] can describe a conduit with non-empty string
        self.assertIsInstance(self.conduit.describe(), basestring)
        self.assertGreater(len(self.conduit.describe()), 0)

        # generally exercise all of the conduit methods
        alice = self.test_data.ALICE.user
        bob = self.test_data.BOB.user
        revision = self.conduit.create_empty_revision_as_user(bob)
        self.conduit.create_comment(revision, 'test comment')
        self.conduit.create_comment(
            revision, 'silent test comment', silent=True)
        self.conduit.get_commit_message(revision)
        self.assertFalse(self.conduit.is_review_accepted(revision))
        self.assertFalse(self.conduit.is_review_abandoned(revision))
        self.assertTrue(self.conduit.is_review_recently_updated(revision))
        self.conduit.set_requires_revision(revision)
        self.assertFalse(self.conduit.is_review_accepted(revision))
        self.assertFalse(self.conduit.is_review_abandoned(revision))
        self.assertTrue(self.conduit.is_review_recently_updated(revision))
        self.conduit.accept_revision_as_user(revision, alice)
        self._invalidate_cache()
        self.assertTrue(self.conduit.is_review_accepted(revision))
        self.assertFalse(self.conduit.is_review_abandoned(revision))
        self.assertTrue(self.conduit.is_review_recently_updated(revision))
        self.conduit.set_requires_revision(revision)
        self._invalidate_cache()
        self.assertFalse(self.conduit.is_review_accepted(revision))
        self.assertFalse(self.conduit.is_review_abandoned(revision))
        self.assertTrue(self.conduit.is_review_recently_updated(revision))
        self.conduit.accept_revision_as_user(revision, alice)

        # check that the review is still accepted after an update
        self._invalidate_cache()
        self.assertTrue(self.conduit.is_review_accepted(revision))
        self.assertFalse(self.conduit.is_review_abandoned(revision))
        self.assertTrue(self.conduit.is_review_recently_updated(revision))
        self.conduit.update_revision(revision, self.empty_diff, 'update')
        self._invalidate_cache()
        self.assertTrue(self.conduit.is_review_accepted(revision))
        self.assertFalse(self.conduit.is_review_abandoned(revision))
        self.assertTrue(self.conduit.is_review_recently_updated(revision))

        self.conduit.abandon_revision(revision)
        self.conduit.get_commit_message(revision)

        self._invalidate_cache()
        self.assertFalse(self.conduit.is_review_accepted(revision))
        self.assertTrue(self.conduit.is_review_abandoned(revision))
        self.assertTrue(self.conduit.is_review_recently_updated(revision))

        # un-abandon
        as_user_conduit = phlsys_conduit.CallMultiConduitAsUser(
            self.sys_conduit, bob)
        phlcon_differential.create_comment(
            as_user_conduit,
            revision,
            action=phlcon_differential.Action.reclaim)

        self._invalidate_cache()
        self.assertFalse(self.conduit.is_review_accepted(revision))
        self.assertFalse(self.conduit.is_review_abandoned(revision))
        self.assertTrue(self.conduit.is_review_recently_updated(revision))

        self.conduit.commandeer_revision_as_user(revision, alice)
        self.conduit.commandeer_revision_as_user(revision, bob)

        # close non-accepted revision
        # self.conduit.set_requires_revision(revision)
        # self.assertFalse(self.conduit.is_review_accepted(revision))
        # self.conduit.close_revision(revision)
        # self.assertFalse(self.conduit.is_review_accepted(revision))

        # close revision
        self.conduit.accept_revision_as_user(revision, alice)
        self._invalidate_cache()
        self.assertTrue(self.conduit.is_review_accepted(revision))
        self.assertFalse(self.conduit.is_review_abandoned(revision))
        self.assertTrue(self.conduit.is_review_recently_updated(revision))
        self.conduit.close_revision(revision)
        self.conduit.get_commit_message(revision)

        # commandeer closed revision
        # self.conduit.commandeer_revision_as_user(revision, alice)

        # update closed revision
        self._invalidate_cache()
        self.assertRaises(
            abdt_exception.AbdUserException,
            self.conduit.update_revision,
            revision,
            self.empty_diff,
            'update')

        # comment on closed revision
        self.conduit.create_comment(revision, 'test comment')
 def _createComment(self, message, silent=False):
     phlcon_differential.create_comment(
         self._conduit, self._revision_id, message, silent=silent)
Exemplo n.º 32
0
 def _authorCommentAction(self, revisionid, action):
     phlcon_differential.create_comment(
         self.conduit, revisionid, action=action)
Exemplo n.º 33
0
    def testCreateCloseRawDiffRevision(self):
        diff = """
diff --git a/readme b/readme
index d4711bb..ee5b241 100644
--- a/readme
+++ b/readme
@@ -7,3 +7,4 @@ and one more!!
 -- and one last(?) one
 alaric!
 local stuff!
+manual conduit submission
"""
        message = """
add a line to README

Test Plan: I proof-read it and it looked ok
"""

        diff2 = """
diff --git a/readme b/readme
index d4711bb..1c634f5 100644
--- a/readme
+++ b/readme
@@ -7,3 +7,5 @@ and one more!!
 -- and one last(?) one
 alaric!
 local stuff!
+manual conduit submission
+another line
"""

        diff_response = phlcon_differential.create_raw_diff(self.conduit, diff)

        parse_response = phlcon_differential.parse_commit_message(
            self.conduit, message)
        self.assertEqual(len(parse_response.errors), 0)

        create_response = phlcon_differential.create_revision(
            self.conduit, diff_response.id, parse_response.fields)

        query_response_list = phlcon_differential.query(
            self.conduit, [create_response.revisionid])
        self.assertEqual(len(query_response_list), 1)
        self.assertEqual(query_response_list[0].uri, create_response.uri)
        self.assertEqual(query_response_list[0].id, create_response.revisionid)
        self.assertEqual(
            query_response_list[0].status,
            phlcon_differential.ReviewStates.needs_review)

        diff2_response = phlcon_differential.create_raw_diff(
            self.conduit, diff2)

        update_response = phlcon_differential.update_revision(
            self.conduit,
            create_response.revisionid, diff2_response.id,
            parse_response.fields, "updated with new diff")
        self.assertEqual(
            update_response.revisionid, create_response.revisionid)
        self.assertEqual(update_response.uri, create_response.uri)

        comment_response = phlcon_differential.create_comment(
            self.reviewerConduit, create_response.revisionid, action="accept")
        self.assertEqual(
            comment_response.revisionid, create_response.revisionid)
        self.assertEqual(comment_response.uri, create_response.uri)

        query_response_list = phlcon_differential.query(
            self.conduit, [create_response.revisionid])
        self.assertEqual(len(query_response_list), 1)
        self.assertEqual(query_response_list[0].uri, create_response.uri)
        self.assertEqual(query_response_list[0].id, create_response.revisionid)
        self.assertEqual(
            query_response_list[0].status,
            phlcon_differential.ReviewStates.accepted)

        phlcon_differential.close(self.conduit, create_response.revisionid)

        query_response_list = phlcon_differential.query(
            self.conduit, [create_response.revisionid])
        self.assertEqual(len(query_response_list), 1)
        self.assertEqual(query_response_list[0].uri, create_response.uri)
        self.assertEqual(query_response_list[0].id, create_response.revisionid)
        self.assertEqual(
            query_response_list[0].status,
            phlcon_differential.ReviewStates.closed)
Exemplo n.º 34
0
    def test_A_Breathing(self):
        # [ A] can describe a conduit with non-empty string
        self.assertIsInstance(self.conduit.describe(), basestring)
        self.assertGreater(len(self.conduit.describe()), 0)

        # generally exercise all of the conduit methods
        alice = self.test_data.ALICE.user
        bob = self.test_data.BOB.user
        revision = self.conduit.create_empty_revision_as_user(bob)
        self.conduit.create_comment(revision, 'test comment')
        self.conduit.create_comment(
            revision, 'silent test comment', silent=True)
        self.conduit.get_commit_message(revision)
        self.assertFalse(self.conduit.is_review_accepted(revision))
        self.assertFalse(self.conduit.is_review_abandoned(revision))
        self.assertTrue(self.conduit.is_review_recently_updated(revision))
        self.conduit.set_requires_revision(revision)
        self.assertFalse(self.conduit.is_review_accepted(revision))
        self.assertFalse(self.conduit.is_review_abandoned(revision))
        self.assertTrue(self.conduit.is_review_recently_updated(revision))
        self.conduit.accept_revision_as_user(revision, alice)
        self._invalidate_cache()
        self.assertTrue(self.conduit.is_review_accepted(revision))
        self.assertFalse(self.conduit.is_review_abandoned(revision))
        self.assertTrue(self.conduit.is_review_recently_updated(revision))
        self.conduit.set_requires_revision(revision)
        self._invalidate_cache()
        self.assertFalse(self.conduit.is_review_accepted(revision))
        self.assertFalse(self.conduit.is_review_abandoned(revision))
        self.assertTrue(self.conduit.is_review_recently_updated(revision))
        self.conduit.accept_revision_as_user(revision, alice)

        # check that the review is still accepted after an update
        self._invalidate_cache()
        self.assertTrue(self.conduit.is_review_accepted(revision))
        self.assertFalse(self.conduit.is_review_abandoned(revision))
        self.assertTrue(self.conduit.is_review_recently_updated(revision))
        self.conduit.update_revision(revision, self.empty_diff, 'update')
        self._invalidate_cache()
        self.assertTrue(self.conduit.is_review_accepted(revision))
        self.assertFalse(self.conduit.is_review_abandoned(revision))
        self.assertTrue(self.conduit.is_review_recently_updated(revision))

        self.conduit.abandon_revision(revision)
        self.conduit.get_commit_message(revision)

        self._invalidate_cache()
        self.assertFalse(self.conduit.is_review_accepted(revision))
        self.assertTrue(self.conduit.is_review_abandoned(revision))
        self.assertTrue(self.conduit.is_review_recently_updated(revision))

        # un-abandon
        with phlsys_conduit.act_as_user_context(self.sys_conduit, bob):
            phlcon_differential.create_comment(
                self.sys_conduit,
                revision,
                action=phlcon_differential.Action.reclaim)

        self._invalidate_cache()
        self.assertFalse(self.conduit.is_review_accepted(revision))
        self.assertFalse(self.conduit.is_review_abandoned(revision))
        self.assertTrue(self.conduit.is_review_recently_updated(revision))

        self.conduit.commandeer_revision_as_user(revision, alice)
        self.conduit.commandeer_revision_as_user(revision, bob)

        # close non-accepted revision
        # self.conduit.set_requires_revision(revision)
        # self.assertFalse(self.conduit.is_review_accepted(revision))
        # self.conduit.close_revision(revision)
        # self.assertFalse(self.conduit.is_review_accepted(revision))

        # close revision
        self.conduit.accept_revision_as_user(revision, alice)
        self._invalidate_cache()
        self.assertTrue(self.conduit.is_review_accepted(revision))
        self.assertFalse(self.conduit.is_review_abandoned(revision))
        self.assertTrue(self.conduit.is_review_recently_updated(revision))
        self.conduit.close_revision(revision)
        self.conduit.get_commit_message(revision)

        # commandeer closed revision
        # self.conduit.commandeer_revision_as_user(revision, alice)

        # update closed revision
        self._invalidate_cache()
        self.assertRaises(
            abdt_exception.AbdUserException,
            self.conduit.update_revision,
            revision,
            self.empty_diff,
            'update')

        # comment on closed revision
        self.conduit.create_comment(revision, 'test comment')
 def _actOnTheOnlyReview(self, user, action):
     # accept the review
     reviewid = self._getTheOnlyReviewId()
     with phlsys_conduit.act_as_user_context(self.conduit, user):
         phlcon_differential.create_comment(
             self.conduit, reviewid, action=action)
 def test_A_Breathing(self):
     rev_id = self._createNonEmptyRevision("test_A_Breathing")
     conduit = self.phabConduit
     phlcon_differential.create_inline_comment(conduit, rev_id, "readme", 2, "this is an inline comment")
     phlcon_differential.create_inline_comment(conduit, rev_id, "readme", 3, "this another inline comment")
     phlcon_differential.create_comment(conduit, rev_id, "this is a message", attach_inlines=True)
    def testCreateCloseRawDiffRevision(self):
        diff = """
diff --git a/readme b/readme
index d4711bb..ee5b241 100644
--- a/readme
+++ b/readme
@@ -7,3 +7,4 @@ and one more!!
 -- and one last(?) one
 alaric!
 local stuff!
+manual conduit submission
"""
        message = """
add a line to README

Test Plan: I proof-read it and it looked ok
"""

        diff2 = """
diff --git a/readme b/readme
index d4711bb..1c634f5 100644
--- a/readme
+++ b/readme
@@ -7,3 +7,5 @@ and one more!!
 -- and one last(?) one
 alaric!
 local stuff!
+manual conduit submission
+another line
"""

        diff_response = phlcon_differential.create_raw_diff(self.conduit, diff)

        get_diff_response = phlcon_differential._get_diff(
            self.conduit, diff_id=diff_response.id)
        self.assertEqual(get_diff_response.id, diff_response.id)

        parse_response = phlcon_differential.parse_commit_message(
            self.conduit, message)
        self.assertEqual(len(parse_response.errors), 0)

        create_response = phlcon_differential.create_revision(
            self.conduit, diff_response.id, parse_response.fields)

        query_response_list = phlcon_differential.query(
            self.conduit, [create_response.revisionid])
        self.assertEqual(len(query_response_list), 1)
        self.assertEqual(query_response_list[0].uri, create_response.uri)
        self.assertEqual(query_response_list[0].id, create_response.revisionid)
        self.assertEqual(
            query_response_list[0].status,
            phlcon_differential.ReviewStates.needs_review)

        diff2_response = phlcon_differential.create_raw_diff(
            self.conduit, diff2)

        update_response = phlcon_differential.update_revision(
            self.conduit,
            create_response.revisionid, diff2_response.id,
            parse_response.fields, "updated with new diff")
        self.assertEqual(
            update_response.revisionid, create_response.revisionid)
        self.assertEqual(update_response.uri, create_response.uri)

        comment_response = phlcon_differential.create_comment(
            self.reviewerConduit, create_response.revisionid, action="accept")
        self.assertEqual(
            comment_response.revisionid, create_response.revisionid)
        self.assertEqual(comment_response.uri, create_response.uri)

        query_response_list = phlcon_differential.query(
            self.conduit, [create_response.revisionid])
        self.assertEqual(len(query_response_list), 1)
        self.assertEqual(query_response_list[0].uri, create_response.uri)
        self.assertEqual(query_response_list[0].id, create_response.revisionid)
        self.assertEqual(
            query_response_list[0].status,
            phlcon_differential.ReviewStates.accepted)

        phlcon_differential.close(self.conduit, create_response.revisionid)

        query_response_list = phlcon_differential.query(
            self.conduit, [create_response.revisionid])
        self.assertEqual(len(query_response_list), 1)
        self.assertEqual(query_response_list[0].uri, create_response.uri)
        self.assertEqual(query_response_list[0].id, create_response.revisionid)
        self.assertEqual(
            query_response_list[0].status,
            phlcon_differential.ReviewStates.closed)
 def _reviewCommentAction(self, revisionid, action):
     phlcon_differential.create_comment(
         self.reviewerConduit, revisionid, action=action)
 def _authorCommentAction(self, revisionid, action):
     phlcon_differential.create_comment(
         self.conduit, revisionid, action=action)