|
@@ -108,5 +108,24 @@ class LodelHookTestCase(unittest.TestCase):
|
108
|
108
|
call('leapi_get_post', lerel, None),
|
109
|
109
|
]
|
110
|
110
|
callhook_mock.assert_has_calls(expected_calls, any_order = False)
|
|
111
|
+
|
|
112
|
+ def test_leapi_update_hook(self):
|
|
113
|
+ """ Testing that leapi_update_* hooks get called when calling update on LeCrud child instance"""
|
|
114
|
+ from leapi.lecrud import _LeCrud
|
|
115
|
+ from dyncode import Numero, Publication, LeRelation, RelTextesPersonneAuteur
|
111
|
116
|
|
112
|
|
- ## @todo Write tests for update, delete and insert hooks
|
|
117
|
+ call_args = {'datas':dict()}
|
|
118
|
+
|
|
119
|
+ leo = Numero
|
|
120
|
+ for leo in [Numero, Publication, RelTextesPersonneAuteur]:
|
|
121
|
+ with patch.object(_LeCrud, 'populate', return_value = None) as osef_mock:
|
|
122
|
+ with patch.object(LodelHook, 'call_hook', return_value = call_args) as callhook_mock:
|
|
123
|
+ inst = leo(42)
|
|
124
|
+ inst.update(**call_args)
|
|
125
|
+ expected_calls = [
|
|
126
|
+ call('leapi_update_pre', inst, call_args),
|
|
127
|
+ call('leapi_update_post', inst, False),
|
|
128
|
+ ]
|
|
129
|
+ callhook_mock.assert_has_calls(expected_calls, any_order = False)
|
|
130
|
+
|
|
131
|
+ ## @todo Write tests for delete and insert hooks
|