def test_add_reviewer_user_doesnt_exist(self): req = mock.Mock() req.content = ')]}\'my user does not identify a registered user or group'.encode('utf-8') gerrit_con = mock.Mock() gerrit_con.call.return_value = req reviewer = Reviewer(gerrit_con, 'my change id') with self.assertRaises(LookupError): reviewer.add_reviewer('my user')
def test_add_reviewer_unhandled_error(self): req = mock.Mock() req.content = ')]}\'{}'.encode('utf-8') gerrit_con = mock.Mock() gerrit_con.call.return_value = req reviewer = Reviewer(gerrit_con, 'my change id') with self.assertRaises(UnhandledError): reviewer.add_reviewer('my user')
def test_add_reviewer_user_is_already_reviewer(self): req = mock.Mock() req.content = ')]}\'{"reviewers": []}'.encode('utf-8') gerrit_con = mock.Mock() gerrit_con.call.return_value = req reviewer = Reviewer(gerrit_con, 'my change id') with self.assertRaises(AlreadyExists): reviewer.add_reviewer('my user')
def test_add_unhandled(self): """ Test that it raises if gerrit returns an unknown content """ self.req.content = self.build_response({}) reviewer = Reviewer(self.gerrit_con, self.CHANGE_ID) with self.assertRaises(UnhandledError): reviewer.add_reviewer(self.USER)
def test_add_reviewer_unhandled_error(self): req = mock.Mock() req.content = ')]}\'{}'.encode('utf-8') gerrit_con = mock.Mock() gerrit_con.call.return_value = req reviewer = Reviewer(gerrit_con, 'my change id') with self.assertRaises(UnhandledError): reviewer.add_reviewer('my user')
def test_add_reviewer_user_is_already_reviewer(self): req = mock.Mock() req.content = ')]}\'{"reviewers": []}'.encode('utf-8') gerrit_con = mock.Mock() gerrit_con.call.return_value = req reviewer = Reviewer(gerrit_con, 'my change id') with self.assertRaises(AlreadyExists): reviewer.add_reviewer('my user')
def test_add_already_reviewer(self): """ Test that it raises when trying to add a user that is already a reviewer """ self.req.content = self.build_response({"reviewers": []}) reviewer = Reviewer(self.gerrit_con, self.CHANGE_ID) with self.assertRaises(AlreadyExists): reviewer.add_reviewer(self.USER)
def test_add_reviewer_user_doesnt_exist(self): req = mock.Mock() req.content = ')]}\'my user does not identify a registered user or group'.encode( 'utf-8') gerrit_con = mock.Mock() gerrit_con.call.return_value = req reviewer = Reviewer(gerrit_con, 'my change id') with self.assertRaises(LookupError): reviewer.add_reviewer('my user')
def test_add_doesnt_exist(self): """ Test that it raises when trying to add a user as reviewer that doesn't exist """ self.req.content = self.build_response( 'my user does not identify a registered user or group' ) reviewer = Reviewer(self.gerrit_con, self.CHANGE_ID) with self.assertRaises(LookupError): reviewer.add_reviewer(self.USER)
def test_add_reviewer_user_added(self): req = mock.Mock() req.content = ')]}\'{"reviewers": ["my user"]}'.encode('utf-8') gerrit_con = mock.Mock() gerrit_con.call.return_value = req reviewer = Reviewer(gerrit_con, 'my change id') self.assertTrue(reviewer.add_reviewer('my user'))
def test_add_reviewer_user_added(self): req = mock.Mock() req.content = ')]}\'{"reviewers": ["my user"]}'.encode('utf-8') gerrit_con = mock.Mock() gerrit_con.call.return_value = req reviewer = Reviewer(gerrit_con, 'my change id') self.assertTrue(reviewer.add_reviewer('my user'))
def test_add_success(self): """ Test that a user can be added as a reviewer """ self.req.content = self.build_response({"reviewers": [self.USER]}) reviewer = Reviewer(self.gerrit_con, self.CHANGE_ID) self.assertTrue(reviewer.add_reviewer(self.USER))
def add_reviewer(self, account_id): """ Add a reviewer to the change :param account_id: The user account that should be added as a reviewer :type account_id: str :return: You get a True boolean type if the addition of this user was successful :rtype: bool :except: LookupError, AlreadyExists, UnhandledError """ reviewer = Reviewer(self._gerrit_con, self.change_id) return reviewer.add_reviewer(account_id)
def add_reviewer(self, account_id): """ Add a reviewer to the change :param account_id: The user account that should be added as a reviewer :type account_id: str :return: You get a True boolean type if the addition of this user was successful :rtype: bool :except: LookupError, AlreadyExists, UnhandledError """ reviewer = Reviewer(self._gerrit_con, self.change_id) return reviewer.add_reviewer(account_id)