Added exceptions for serialization and deserialization. These will come in handy later

This commit is contained in:
Jeppe Klitgaard 2015-04-11 17:47:25 +02:00
parent 6daca43748
commit 658c451930
2 changed files with 40 additions and 1 deletions

View File

@ -5,5 +5,19 @@ Contains the `Exceptions` used by this library.
class YggdrasilError(Exception):
"""
Base `Exception` for the Yggdrasil authentication service.
Base ``Exception`` for the Yggdrasil authentication service.
"""
class DeserializationError(Exception):
"""
``Exception`` raised when something went wrong during the deserialization
process.
"""
class SerializationError(Exception):
"""
``Exception`` raised when something went wrong during the serialization
process.
"""

View File

@ -1,4 +1,5 @@
from minecraft.exceptions import YggdrasilError
from minecraft.exceptions import DeserializationError, SerializationError
import unittest
@ -13,3 +14,27 @@ class RaiseYggdrasilError(unittest.TestCase):
raise YggdrasilError("Error!")
self.assertEqual(str(e.exception), "Error!")
class RaiseDeserializationError(unittest.TestCase):
def test_raise_deserialization_error(self):
with self.assertRaises(DeserializationError):
raise DeserializationError
def test_raise_deserialization_error_message(self):
with self.assertRaises(DeserializationError) as e:
raise DeserializationError("Error!")
self.assertEqual(str(e.exception), "Error!")
class RaiseSerializationError(unittest.TestCase):
def test_raise_serialization_error(self):
with self.assertRaises(SerializationError):
raise SerializationError
def test_raise_serialization_error_message(self):
with self.assertRaises(SerializationError) as e:
raise SerializationError("Error!")
self.assertEqual(str(e.exception), "Error!")