summaryrefslogtreecommitdiff
path: root/tests/test_exceptions.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_exceptions.py')
-rw-r--r--tests/test_exceptions.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py
new file mode 100644
index 0000000..7f02aab
--- /dev/null
+++ b/tests/test_exceptions.py
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+
+# pykwalify imports
+from pykwalify import errors
+
+
+class TestCLI(object):
+
+ def test_base_exception(self):
+ # retcode=2 should be schemaerror
+ e = errors.PyKwalifyException(msg="foobar", retcode=2)
+ assert e.__repr__() == "PyKwalifyException(msg='foobar')"
+ assert e.retname == "schemaerror"
+
+ def test_create_sub_class_exceptions(self):
+ u_e = errors.UnknownError()
+ assert u_e.retcode == 1
+
+ s_e = errors.SchemaError()
+ assert s_e.retcode == 2
+
+ c_e = errors.CoreError()
+ assert c_e.retcode == 3
+
+ r_e = errors.RuleError()
+ assert r_e.retcode == 4
+
+ sc_e = errors.SchemaConflict()
+ assert sc_e.retcode == 5