def test_get_custodians_page_raises_error_when_required_option_missing( self, mocker, mock_connection): def side_effect(*args, **kwargs): base_err = mocker.MagicMock(spec=HTTPError) base_err.response = mocker.MagicMock(spec=Response) base_err.response.text = "At least one criteria must be specified; holdMembershipUid, holdUid, userUid, or userSearch" raise Py42BadRequestError(base_err) mock_connection.get.side_effect = side_effect service = LegalHoldService(mock_connection) with pytest.raises(Py42LegalHoldCriteriaMissingError): service.get_custodians_page(1)
def test_get_custodians_page_calls_get_with_expected_url_and_params( self, mock_connection): service = LegalHoldService(mock_connection) service.get_custodians_page(20, "membership", "legalhold", "user ID", "username", True, 200) mock_connection.get.assert_called_once_with( "/api/LegalHoldMembership", params={ "legalHoldMembershipUid": "membership", "legalHoldUid": "legalhold", "userUid": "user ID", "user": "******", "activeState": "ACTIVE", "pgNum": 20, "pgSize": 200, }, )
def test_get_custodians_page_raises_error_when_required_option_missing( self, mocker, mock_connection ): text = ( "At least one criteria must be specified; holdMembershipUid, holdUid, " "userUid, or userSearch" ) mock_connection.get.side_effect = create_mock_error( Py42BadRequestError, mocker, text ) service = LegalHoldService(mock_connection) with pytest.raises(Py42LegalHoldCriteriaMissingError) as err: service.get_custodians_page(1) assert ( str(err.value) == "At least one criteria must be specified; " "legal_hold_membership_uid, legal_hold_uid, user_uid, or user." )