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 create_empty_revision_as_user(self, username):
        """Return the id of a newly created empty revision as 'username'.

        :username: username for the author of the revision
        :returns: id of created revision

        """
        with phlsys_conduit.act_as_user_context(self._conduit, username):
            revision = phlcon_differential.create_empty_revision(self._conduit)
        return revision
 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 testCreateUpdateEmptyRevision(self):
        conduit = phlsys_conduit.Conduit(
            self.test_data.TEST_URI, self.test_data.PHAB.user, self.test_data.PHAB.certificate
        )
        author = phldef_conduit.ALICE.user
        with phlsys_conduit.act_as_user_context(conduit, author):
            revision_id = phlcon_differential.create_empty_revision(conduit)

        revision_list = phlcon_differential.query(conduit, [revision_id])
        self.assertEqual(len(revision_list), 1)

        with phlsys_conduit.act_as_user_context(conduit, author):
            phlcon_differential.update_revision_empty(conduit, revision_id)
Esempio n. 5
0
    def testCreateUpdateEmptyRevision(self):
        conduit = phlsys_conduit.Conduit(
            self.test_data.TEST_URI,
            self.test_data.PHAB.user,
            self.test_data.PHAB.certificate)
        author = phldef_conduit.ALICE.user
        with phlsys_conduit.act_as_user_context(conduit, author):
            revision_id = phlcon_differential.create_empty_revision(conduit)

        revision_list = phlcon_differential.query(conduit, [revision_id])
        self.assertEqual(len(revision_list), 1)

        with phlsys_conduit.act_as_user_context(conduit, author):
            phlcon_differential.update_revision_empty(conduit, revision_id)
Esempio n. 6
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)
Esempio n. 7
0
    def create_empty_revision_as_user(self, username):
        """Return the id of a newly created empty revision as 'username'.

        :username: username for the author of the revision
        :returns: id of created revision

        """
        with self._log_context('conduit-createemptyrev',
                               'create as {}'.format(username)) as log:

            as_user_conduit = self._make_as_user_conduit(username)
            revision = phlcon_differential.create_empty_revision(
                as_user_conduit)

            log.append(revision)

        return revision
Esempio n. 8
0
    def create_empty_revision_as_user(self, username):
        """Return the id of a newly created empty revision as 'username'.

        :username: username for the author of the revision
        :returns: id of created revision

        """
        with self._log_context(
                'conduit-createemptyrev',
                'create as {}'.format(username)) as log:

            as_user_conduit = self._make_as_user_conduit(username)
            revision = phlcon_differential.create_empty_revision(
                as_user_conduit)

            log.append(revision)

        return revision
    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)
Esempio n. 12
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)