|
@@ -23,47 +23,6 @@ class LeObjectTestCase(TestCase):
|
23
|
23
|
""" Remove the temporary directory created at class setup """
|
24
|
24
|
leapi.test.utils.cleanup(cls.tmpdir)
|
25
|
25
|
|
26
|
|
- def test_split_query_filter(self):
|
27
|
|
- """ Tests the _split_filter() classmethod """
|
28
|
|
- import dyncode
|
29
|
|
- query_results = {
|
30
|
|
- 'Hello = world' : ('Hello', '=', 'world'),
|
31
|
|
- 'hello <= "world"': ('hello', '<=', '"world"'),
|
32
|
|
- '_he42_ll-o >= \'world"': ('_he42_ll-o', '>=', '\'world"'),
|
33
|
|
- 'foo in ["foo", 42, \'bar\']': ('foo', ' in ', '["foo", 42, \'bar\']'),
|
34
|
|
- ' bar42 < 42': ('bar42', '<', '42'),
|
35
|
|
- ' _hidden > 1337': ('_hidden', '>', '1337'),
|
36
|
|
- '_42 not in foobar': ('_42', ' not in ', 'foobar'),
|
37
|
|
- 'hello in foo':('hello', ' in ', 'foo'),
|
38
|
|
- "\t\t\thello\t\t\nin\nfoo\t\t\n\t":('hello', ' in ', 'foo'),
|
39
|
|
- "hello \nnot\tin \nfoo":('hello', ' not in ', 'foo'),
|
40
|
|
- 'hello != bar':('hello', '!=', 'bar'),
|
41
|
|
- 'hello = "world>= <= != in not in"': ('hello', '=', '"world>= <= != in not in"'),
|
42
|
|
- 'superior.parent = 13': ('superior.parent', '=', '13'),
|
43
|
|
- }
|
44
|
|
- for query, result in query_results.items():
|
45
|
|
- res = dyncode.LeObject._split_filter(query)
|
46
|
|
- self.assertEqual(res, result, "When parsing the query : '%s' the returned value is different from the expected '%s'"%(query, result))
|
47
|
|
-
|
48
|
|
- def test_invalid_split_query_filter(self):
|
49
|
|
- """ Testing the _split_filter() method with invalid queries """
|
50
|
|
- import dyncode
|
51
|
|
- invalid_queries = [
|
52
|
|
- '42 = 42',
|
53
|
|
- '4hello = foo',
|
54
|
|
- 'foo == bar',
|
55
|
|
- 'hello >> world',
|
56
|
|
- 'hello = ',
|
57
|
|
- ' = world',
|
58
|
|
- '=',
|
59
|
|
- '42',
|
60
|
|
- '"hello" = world',
|
61
|
|
- 'foo.bar = 15',
|
62
|
|
- ]
|
63
|
|
- for query in invalid_queries:
|
64
|
|
- with self.assertRaises(ValueError, msg='But the query was not valid : "%s"'%query):
|
65
|
|
- dyncode.LeObject._split_filter(query)
|
66
|
|
-
|
67
|
26
|
def test_uid2leobj(self):
|
68
|
27
|
""" Testing _Leobject.uid2leobj() """
|
69
|
28
|
import dyncode
|
|
@@ -104,6 +63,7 @@ class LeObjectTestCase(TestCase):
|
104
|
63
|
for (leclass, letype), (rleclass, rletype) in test_v.items():
|
105
|
64
|
self.assertEqual((rletype,rleclass), LeObject._prepare_targets(letype, leclass))
|
106
|
65
|
|
|
66
|
+ @unittest.skip("Obsolete but may be usefull for datasources tests")
|
107
|
67
|
def test_invalid_prepare_targets(self):
|
108
|
68
|
""" Testing _prepare_targets() method with invalid arguments """
|
109
|
69
|
from dyncode import Publication, Numero, LeObject, Personnes
|
|
@@ -129,7 +89,7 @@ class LeObjectTestCase(TestCase):
|
129
|
89
|
for (leclass, letype) in test_v:
|
130
|
90
|
with self.assertRaises(ValueError):
|
131
|
91
|
LeObject._prepare_targets(letype, leclass)
|
132
|
|
-
|
|
92
|
+ @unittest.skip("Obsolete, the method should be deleted soon")
|
133
|
93
|
def test_check_fields(self):
|
134
|
94
|
""" Testing the _check_fields() method """
|
135
|
95
|
from dyncode import Publication, Numero, LeObject, Personnes
|
|
@@ -148,26 +108,6 @@ class LeObjectTestCase(TestCase):
|
148
|
108
|
LeObject._check_fields(None, None, Numero._fields)
|
149
|
109
|
|
150
|
110
|
|
151
|
|
- def test_prepare_filters_invalid(self):
|
152
|
|
- """ Testing the _prepare_filters() method """
|
153
|
|
- from dyncode import Publication, Numero, LeObject, Personnes
|
154
|
|
-
|
155
|
|
- #Numero fields filters but no letype nor leclass given
|
156
|
|
- filters = []
|
157
|
|
- res_filt = []
|
158
|
|
- for field in Numero._fields:
|
159
|
|
- filters.append('%s=1'%field)
|
160
|
|
- res_filt.append((field, '=', '1'))
|
161
|
|
-
|
162
|
|
- with self.assertRaises(leapi.lecrud.LeApiDataCheckError):
|
163
|
|
- LeObject._prepare_filters(filters)
|
164
|
|
-
|
165
|
|
-
|
166
|
|
- #simply invalid filters
|
167
|
|
- filters = ['hello world !']
|
168
|
|
- with self.assertRaises(ValueError):
|
169
|
|
- LeObject._prepare_filters(filters)
|
170
|
|
-
|
171
|
111
|
class LeObjectMockDatasourceTestCase(TestCase):
|
172
|
112
|
""" Testing _LeObject using a mock on the datasource """
|
173
|
113
|
|