Full coverage in exceptions.

This commit is contained in:
s3lph 2018-08-28 22:14:03 +02:00
parent 9cd6522b26
commit e29423c32e
4 changed files with 49 additions and 0 deletions

View file

View file

@ -0,0 +1,15 @@
import unittest
from matemat.exceptions import AuthenticationError
class TestAuthenticationError(unittest.TestCase):
def test_msg(self):
e = AuthenticationError('testmsg')
self.assertEqual('testmsg', e.msg)
def test_str(self):
e = AuthenticationError('testmsg')
self.assertEqual('AuthenticationError: testmsg', str(e))

View file

@ -0,0 +1,15 @@
import unittest
from matemat.exceptions import DatabaseConsistencyError
class TestDatabaseConsistencyError(unittest.TestCase):
def test_msg(self):
e = DatabaseConsistencyError('testmsg')
self.assertEqual('testmsg', e.msg)
def test_str(self):
e = DatabaseConsistencyError('testmsg')
self.assertEqual('DatabaseConsistencyError: testmsg', str(e))

View file

@ -0,0 +1,19 @@
import unittest
from matemat.exceptions import HttpException
class TestHttpException(unittest.TestCase):
def test_all_args(self):
e = HttpException(1337, 'Foo Bar', 'Lorem Ipsum Dolor Sit Amet')
self.assertEqual(1337, e.status)
self.assertEqual('Foo Bar', e.title)
self.assertEqual('Lorem Ipsum Dolor Sit Amet', e.message)
def test_default_args(self):
e = HttpException()
self.assertEqual(500, e.status)
self.assertEqual('An error occurred', e.title)
self.assertIsNone(e.message)