From e29423c32e2725aa4f50e2f4730dc87fdf107342 Mon Sep 17 00:00:00 2001 From: s3lph Date: Tue, 28 Aug 2018 22:14:03 +0200 Subject: [PATCH] Full coverage in exceptions. --- matemat/exceptions/test/__init__.py | 0 .../test/test_authentication_error.py | 15 +++++++++++++++ .../test/test_database_consistency_error.py | 15 +++++++++++++++ .../exceptions/test/test_http_exception.py | 19 +++++++++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 matemat/exceptions/test/__init__.py create mode 100644 matemat/exceptions/test/test_authentication_error.py create mode 100644 matemat/exceptions/test/test_database_consistency_error.py create mode 100644 matemat/exceptions/test/test_http_exception.py diff --git a/matemat/exceptions/test/__init__.py b/matemat/exceptions/test/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/matemat/exceptions/test/test_authentication_error.py b/matemat/exceptions/test/test_authentication_error.py new file mode 100644 index 0000000..8c98692 --- /dev/null +++ b/matemat/exceptions/test/test_authentication_error.py @@ -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)) diff --git a/matemat/exceptions/test/test_database_consistency_error.py b/matemat/exceptions/test/test_database_consistency_error.py new file mode 100644 index 0000000..21f7522 --- /dev/null +++ b/matemat/exceptions/test/test_database_consistency_error.py @@ -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)) diff --git a/matemat/exceptions/test/test_http_exception.py b/matemat/exceptions/test/test_http_exception.py new file mode 100644 index 0000000..c9fa669 --- /dev/null +++ b/matemat/exceptions/test/test_http_exception.py @@ -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)