# Path: yithlibraryserver/errors.py
# def password_not_found(msg='Password not found'):
#     return HTTPNotFound(body=json.dumps({'message': msg}),
#                         content_type='application/json')
# 
# def invalid_password_id(msg='Invalid password id'):
#     return HTTPBadRequest(body=json.dumps({'message': msg}),
#                           content_type='application/json')


import unittest
from pyramid.httpexceptions import HTTPBadRequest, HTTPNotFound
from yithlibraryserver.errors import password_not_found, invalid_password_id
#
# This file is part of Yith Library Server.
#
# Yith Library Server is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Yith Library Server is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Yith Library Server.  If not, see <http://www.gnu.org/licenses/>.






class ErrorsTests(unittest.TestCase):

    def test_password_not_found(self):
        result = password_not_found()
        self.assertTrue(isinstance(result, HTTPNotFound))
        self.assertTrue(result.content_type, 'application/json')
        self.assertTrue(result.body, '{"message": "Password not found"}')

        # try a different message

# Path: yithlibraryserver/errors.py
# def password_not_found(msg='Password not found'):
#     return HTTPNotFound(body=json.dumps({'message': msg}),
#                         content_type='application/json')
# 
# def invalid_password_id(msg='Invalid password id'):
#     return HTTPBadRequest(body=json.dumps({'message': msg}),
#                           content_type='application/json')


# Path: yithlibraryserver/tests/test_errors.py
import unittest
from pyramid.httpexceptions import HTTPBadRequest, HTTPNotFound
from yithlibraryserver.errors import password_not_found, invalid_password_id

#
# This file is part of Yith Library Server.
#
# Yith Library Server is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Yith Library Server is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Yith Library Server.  If not, see <http://www.gnu.org/licenses/>.






class ErrorsTests(unittest.TestCase):

    def test_password_not_found(self):
        result = password_not_found()
        self.assertTrue(isinstance(result, HTTPNotFound))
        self.assertTrue(result.content_type, 'application/json')
        self.assertTrue(result.body, '{"message": "Password not found"}')

        # try a different message

        result = password_not_found('test')