|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | + |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | +# not use this file except in compliance with the License. You may obtain |
| 5 | +# a copy of the License at |
| 6 | +# |
| 7 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | +# License for the specific language governing permissions and limitations |
| 13 | +# under the License. |
| 14 | + |
| 15 | +from __future__ import unicode_literals, absolute_import |
| 16 | + |
| 17 | +import unittest |
| 18 | + |
| 19 | +from linebot.exceptions import LineBotApiError |
| 20 | +from linebot.models import Error, ErrorDetail |
| 21 | + |
| 22 | + |
| 23 | +class TestUtils(unittest.TestCase): |
| 24 | + def test_str(self): |
| 25 | + line_bot_api_error = LineBotApiError( |
| 26 | + 400, |
| 27 | + error=Error(message='The request body has 1 error(s)', |
| 28 | + details=[ErrorDetail(message='May not be empty', |
| 29 | + property='messages[0].text')])) |
| 30 | + self.assertEqual(line_bot_api_error.__str__(), |
| 31 | + 'LineBotApiError: status_code=400, error_response={"details": ' |
| 32 | + '[{"message": "May not be empty", "property": "messages[0].text"}], ' |
| 33 | + '"message": "The request body has 1 error(s)"}') |
| 34 | + |
| 35 | + |
| 36 | +if __name__ == '__main__': |
| 37 | + unittest.main() |
0 commit comments