This repository has been archived on 2022-08-04. You can view files and clone it, but cannot push or open issues or pull requests.
pyurbantz/urbantz/tests/test_exceptions.py

36 lines
984 B
Python

from unittest import TestCase
from urbantz.exceptions import APIError
class TestExceptions(TestCase):
@classmethod
def setUpClass(self):
self.error = APIError({
'code': 9000,
'message': "I'm afraid I can't do that, Dave."
})
def test_init(self):
self.assertEqual(self.error.code, 9000)
self.assertEqual(
self.error.message,
"I'm afraid I can't do that, Dave.",
)
def test_empty(self):
error = APIError({})
self.assertIsNone(error.message)
self.assertIsNone(error.code)
self.assertEqual(str(error), 'Unknown error')
self.assertEqual(repr(error), "<APIError 'Unknown error'>")
def test_repr(self):
self.assertEqual(
repr(self.error),
'<APIError "I\'m afraid I can\'t do that, Dave.">',
)
def test_str(self):
self.assertEqual(str(self.error), "I'm afraid I can't do that, Dave.")