Browse Source

More forgotten files

Yann Weber 8 years ago
parent
commit
cccabc7ce4
2 changed files with 64 additions and 0 deletions
  1. 25
    0
      lodel/leapi/exceptions.py
  2. 39
    0
      tests/leapi/test_leobject.py

+ 25
- 0
lodel/leapi/exceptions.py View File

@@ -0,0 +1,25 @@
1
+#-*- coding: utf-8 -*-
2
+
3
+from lodel.exceptions import LodelExceptions, LodelException
4
+
5
+class LeApiError(LodelException):
6
+    pass
7
+
8
+
9
+##@brief Handles multiple LeAPI errors
10
+class LeApiErrors(LodelExceptions, LeApiError):
11
+    pass
12
+
13
+
14
+##@brief When an error concerns a datas
15
+class LeApiDataCheckError(LeApiError):
16
+    pass
17
+
18
+
19
+class LeApiQueryError(LeApiError):
20
+    pass
21
+
22
+
23
+##@brief Handles mulitple query errors
24
+class LeApiQueryErrors(LodelExceptions, LeApiQueryError):
25
+    pass

+ 39
- 0
tests/leapi/test_leobject.py View File

@@ -0,0 +1,39 @@
1
+import unittest
2
+
3
+import tests.loader_utils
4
+from tests.leapi.query.utils import dyncode_module as dyncode
5
+
6
+from lodel.leapi.leobject import LeApiDataCheckError
7
+from lodel.leapi.query import LeDeleteQuery, LeUpdateQuery, LeGetQuery
8
+from lodel.leapi.exceptions import *
9
+
10
+class LeFilteredQueryTestCase(unittest.TestCase):
11
+
12
+    q_classes = [ LeDeleteQuery, LeUpdateQuery, LeGetQuery ]
13
+
14
+    def test_init(self):
15
+        """ Testing LeObject child class __init__ """
16
+        dyncode.Person(
17
+            lodel_id = '1',
18
+            lastname = "Foo",
19
+            firstname = "Bar",
20
+            alias = "Foobar")
21
+
22
+    def test_init_abstract(self):
23
+        """ Testing init abstract LeObject childs """
24
+        abstract_classes = [
25
+            dyncode.Entitie, dyncode.Indexabs]
26
+        for cls in abstract_classes:
27
+            with self.assertRaises(NotImplementedError):
28
+                cls(lodel_id = 1)
29
+
30
+    def test_init_bad_fields(self):
31
+        """ Testing init with bad arguments """
32
+        with self.assertRaises(LeApiErrors):
33
+            dyncode.Person(
34
+                lodel_id = 1,
35
+                foobar = "barfoo")
36
+        with self.assertRaises(LeApiErrors):
37
+            dyncode.Person(lastname = "foo", firstname = "bar")
38
+
39
+        

Loading…
Cancel
Save