Ejemplo n.º 1
0
    def test_delete_reviewer_unauthorized(self):
        req = mock.Mock()
        req.content = ')]}\'delete not permitted'.encode('utf-8')
        gerrit_con = mock.Mock()
        gerrit_con.call.return_value = req

        reviewer = Reviewer(gerrit_con, 'my change id')
        with self.assertRaises(AuthorizationError):
            reviewer.delete_reviewer('my user')
Ejemplo n.º 2
0
    def test_delete_reviewer_unauthorized(self):
        req = mock.Mock()
        req.content = ')]}\'delete not permitted'.encode('utf-8')
        gerrit_con = mock.Mock()
        gerrit_con.call.return_value = req

        reviewer = Reviewer(gerrit_con, 'my change id')
        with self.assertRaises(AuthorizationError):
            reviewer.delete_reviewer('my user')
Ejemplo n.º 3
0
    def test_delete_unauthorized(self):
        """
        Test that it raises when deleting a reviewer is not permitted
        """
        self.req.content = self.build_response('delete not permitted')

        reviewer = Reviewer(self.gerrit_con, self.CHANGE_ID)
        with self.assertRaises(AuthorizationError):
            reviewer.delete_reviewer(self.USER)
Ejemplo n.º 4
0
    def test_delete_fail(self):
        """
        Test that it returns false if removing a reviewer fails
        """
        self.req.status_code = 404

        reviewer = Reviewer(self.gerrit_con, self.CHANGE_ID)
        self.assertFalse(reviewer.delete_reviewer(self.USER))
Ejemplo n.º 5
0
    def test_delete_reviewer_fail(self):
        req = mock.Mock()
        req.content = ')]}\''.encode('utf-8')
        req.status_code = 404
        gerrit_con = mock.Mock()
        gerrit_con.call.return_value = req

        reviewer = Reviewer(gerrit_con, 'my change id')
        self.assertFalse(reviewer.delete_reviewer('my user'))
Ejemplo n.º 6
0
    def test_delete_reviewer_fail(self):
        req = mock.Mock()
        req.content = ')]}\''.encode('utf-8')
        req.status_code = 404
        gerrit_con = mock.Mock()
        gerrit_con.call.return_value = req

        reviewer = Reviewer(gerrit_con, 'my change id')
        self.assertFalse(reviewer.delete_reviewer('my user'))
Ejemplo n.º 7
0
 def delete_reviewer(self, account_id):
     """
     Delete a reviewer from the change
     :param account_id: Remove a user with account-id as reviewer.
     :type account_id: str
     :rtype: bool
     :exception: error.AuthorizationError
     """
     reviewer = Reviewer(self._gerrit_con, self.change_id)
     return reviewer.delete_reviewer(account_id)
Ejemplo n.º 8
0
 def delete_reviewer(self, account_id):
     """
     Delete a reviewer from the change
     :param account_id: Remove a user with account-id as reviewer.
     :type account_id: str
     :rtype: bool
     :exception: error.AuthorizationError
     """
     reviewer = Reviewer(self._gerrit_con, self.change_id)
     return reviewer.delete_reviewer(account_id)
Ejemplo n.º 9
0
    def test_delete_success(self):
        """
        Test that a reviewer can be deleted
        """
        self.req.status_code = 204

        reviewer = Reviewer(self.gerrit_con, self.CHANGE_ID)
        self.assertTrue(reviewer.delete_reviewer(self.USER))
        self.gerrit_con.call.assert_called_with(
            request='delete',
            r_endpoint='/a/changes/{}/reviewers/{}'.format(self.CHANGE_ID, self.USER),
            r_headers={},
        )
Ejemplo n.º 10
0
    def test_delete_reviewer_success(self):
        req = mock.Mock()
        req.content = ')]}\''.encode('utf-8')
        req.status_code = 204
        gerrit_con = mock.Mock()
        gerrit_con.call.return_value = req

        reviewer = Reviewer(gerrit_con, 'my change id')
        self.assertTrue(reviewer.delete_reviewer('my user'))
        gerrit_con.call.assert_called_with(
            request='delete',
            r_endpoint='/a/changes/my change id/reviewers/my user',
            r_headers={},
        )
Ejemplo n.º 11
0
    def test_delete_reviewer_success(self):
        req = mock.Mock()
        req.content = ')]}\''.encode('utf-8')
        req.status_code = 204
        gerrit_con = mock.Mock()
        gerrit_con.call.return_value = req

        reviewer = Reviewer(gerrit_con, 'my change id')
        self.assertTrue(reviewer.delete_reviewer('my user'))
        gerrit_con.call.assert_called_with(
            request='delete',
            r_endpoint='/a/changes/my change id/reviewers/my user',
            r_headers={},
        )