|
@@ -22,7 +22,6 @@ class LeRelationTestCase(TestCase):
|
22
|
22
|
""" Remove the temporary directory created at class setup """
|
23
|
23
|
leapi.test.utils.cleanup(cls.tmpdir)
|
24
|
24
|
|
25
|
|
- # @unittest.skip("Wating LeRelation._prepare_filters() to unskip")
|
26
|
25
|
def test_prepare_filters(self):
|
27
|
26
|
""" Testing the _prepare_filters() method """
|
28
|
27
|
from dyncode import Numero, LeObject, LeRelation
|
|
@@ -80,7 +79,6 @@ class LeRelationTestCase(TestCase):
|
80
|
79
|
|
81
|
80
|
class LeHierarch(LeRelationTestCase):
|
82
|
81
|
|
83
|
|
- # @unittest.skip("Wait for LeRelation._prepare_filters() to unskip")
|
84
|
82
|
@patch('leapi.datasources.dummy.DummyDatasource.select')
|
85
|
83
|
def test_get(self, dsmock):
|
86
|
84
|
""" Tests the LeHierarch.get() method """
|
|
@@ -124,40 +122,67 @@ class LeHierarch(LeRelationTestCase):
|
124
|
122
|
|
125
|
123
|
dsmock.reset_mock()
|
126
|
124
|
|
127
|
|
- @unittest.skip("Wait for LeRelation._prepare_filters() to unskip")
|
128
|
125
|
@patch('leapi.datasources.dummy.DummyDatasource.insert')
|
129
|
126
|
def test_insert(self, dsmock):
|
130
|
127
|
""" Testing LeHierarch insert method """
|
131
|
128
|
from dyncode import LeCrud, Publication, Numero, Personnes, LeObject, Rubrique, LeHierarch, LeRelation
|
132
|
129
|
queries = [
|
133
|
|
- {
|
134
|
|
- 'lesup': Rubrique(7),
|
135
|
|
- 'lesub': Numero(42),
|
136
|
|
- 'nature': 'parent',
|
137
|
|
- },
|
138
|
|
- {
|
139
|
|
- 'lesup': 7,
|
140
|
|
- 'lesub': 42,
|
141
|
|
- 'nature': 'parent',
|
142
|
|
- },
|
143
|
|
- {
|
144
|
|
- 'lesup': LeObject(7),
|
145
|
|
- 'lesub': LeObject(42),
|
146
|
|
- 'nature': 'parent',
|
147
|
|
- },
|
148
|
|
- {
|
149
|
|
- 'lesup': LeObject(7),
|
150
|
|
- 'lesub': 42,
|
151
|
|
- 'nature': 'parent',
|
152
|
|
- }
|
|
130
|
+ (
|
|
131
|
+ {
|
|
132
|
+ 'lesup': Rubrique(7),
|
|
133
|
+ 'lesub': Numero(42),
|
|
134
|
+ 'nature': 'parent',
|
|
135
|
+ },
|
|
136
|
+ {
|
|
137
|
+ 'lesup': Rubrique(7),
|
|
138
|
+ 'lesub': Numero(42),
|
|
139
|
+ 'nature': 'parent',
|
|
140
|
+ }
|
|
141
|
+ ),
|
|
142
|
+ (
|
|
143
|
+ {
|
|
144
|
+ 'lesup': 7,
|
|
145
|
+ 'lesub': 42,
|
|
146
|
+ 'nature': 'parent',
|
|
147
|
+ },
|
|
148
|
+ {
|
|
149
|
+ 'lesup': LeObject(7),
|
|
150
|
+ 'lesub': LeObject(42),
|
|
151
|
+ 'nature': 'parent',
|
|
152
|
+ }
|
|
153
|
+ ),
|
|
154
|
+ (
|
|
155
|
+ {
|
|
156
|
+ 'lesup': LeObject(7),
|
|
157
|
+ 'lesub': LeObject(42),
|
|
158
|
+ 'nature': 'parent',
|
|
159
|
+ },
|
|
160
|
+ {
|
|
161
|
+ 'lesup': LeObject(7),
|
|
162
|
+ 'lesub': LeObject(42),
|
|
163
|
+ 'nature': 'parent',
|
|
164
|
+ }
|
|
165
|
+ ),
|
|
166
|
+ (
|
|
167
|
+ {
|
|
168
|
+ 'lesup': LeObject(7),
|
|
169
|
+ 'lesub': 42,
|
|
170
|
+ 'nature': 'parent',
|
|
171
|
+ },
|
|
172
|
+ {
|
|
173
|
+ 'lesup': LeObject(7),
|
|
174
|
+ 'lesub': LeObject(42),
|
|
175
|
+ 'nature': 'parent',
|
|
176
|
+ }
|
|
177
|
+ )
|
153
|
178
|
]
|
154
|
|
- for query in queries:
|
|
179
|
+ for query, equery in queries:
|
155
|
180
|
LeHierarch.insert(query)
|
156
|
|
- dsmock.assert_called_once_with(LeHierarch, **query)
|
|
181
|
+ dsmock.assert_called_once_with(LeHierarch, **equery)
|
157
|
182
|
dsmock.reset_mock()
|
158
|
183
|
|
159
|
184
|
LeRelation.insert(query, 'LeHierarch')
|
160
|
|
- dsmock.assert_called_once_with(LeHierarch, **query)
|
|
185
|
+ dsmock.assert_called_once_with(LeHierarch, **equery)
|
161
|
186
|
dsmock.reset_mock()
|
162
|
187
|
|
163
|
188
|
|
|
@@ -223,6 +248,9 @@ class LeRel2TypeTestCase(LeRelationTestCase):
|
223
|
248
|
|
224
|
249
|
eres = {'nature': None}
|
225
|
250
|
eres.uopdate(query)
|
|
251
|
+ for fname in ('lesup', 'lesub'):
|
|
252
|
+ if isinstance(eres[fname], int):
|
|
253
|
+ eres[fname] = LeObject(eres[fname])
|
226
|
254
|
|
227
|
255
|
dsmock.assert_called_once_with(Rel_textes2personne, **eres)
|
228
|
256
|
dsmock.reset_mock()
|