@@ -297,3 +297,124 @@ def test_get_folders(
297297 )
298298
299299 assert result .folders == ["dir1" , "dir2" ]
300+
301+ # ============ Actions ============
302+
303+ def test_actions_get_by_id (
304+ self ,
305+ request_mock : mock .MagicMock ,
306+ resource_client : StorageBoxesClient ,
307+ action_running1 ,
308+ ):
309+ request_mock .return_value = {
310+ "action" : action_running1 ,
311+ }
312+
313+ result = resource_client .actions .get_by_id (22 )
314+
315+ request_mock .assert_called_with (
316+ method = "GET" ,
317+ url = "/storage_boxes/actions/22" ,
318+ )
319+
320+ assert_bound_action (result , resource_client ._parent .actions )
321+
322+ def test_actions_get_list (
323+ self ,
324+ request_mock : mock .MagicMock ,
325+ resource_client : StorageBoxesClient ,
326+ action_running1 ,
327+ ):
328+ request_mock .return_value = {
329+ "actions" : [action_running1 ],
330+ }
331+
332+ result = resource_client .actions .get_list ()
333+
334+ request_mock .assert_called_with (
335+ method = "GET" ,
336+ url = "/storage_boxes/actions" ,
337+ params = {},
338+ )
339+
340+ assert len (result .actions ) == 1
341+ assert_bound_action (result .actions [0 ], resource_client ._parent .actions )
342+
343+ @pytest .mark .parametrize (
344+ "params" ,
345+ [
346+ {"status" : "" , "sort" : "" },
347+ {},
348+ ],
349+ )
350+ def test_actions_get_all (
351+ self ,
352+ request_mock : mock .MagicMock ,
353+ resource_client : StorageBoxesClient ,
354+ action_running1 ,
355+ params ,
356+ ):
357+ request_mock .return_value = {
358+ "actions" : [action_running1 ],
359+ }
360+
361+ result = resource_client .actions .get_all (** params )
362+
363+ request_mock .assert_called_with (
364+ method = "GET" ,
365+ url = "/storage_boxes/actions" ,
366+ params = {** params , "page" : 1 , "per_page" : 50 },
367+ )
368+
369+ assert len (result ) == 1
370+ assert_bound_action (result [0 ], resource_client ._parent .actions )
371+
372+ def test_get_actions_list (
373+ self ,
374+ request_mock : mock .MagicMock ,
375+ resource_client : StorageBoxesClient ,
376+ action_running1 ,
377+ ):
378+ request_mock .return_value = {
379+ "actions" : [action_running1 ],
380+ }
381+
382+ result = resource_client .get_actions_list (StorageBox (id = 42 ))
383+
384+ request_mock .assert_called_with (
385+ method = "GET" ,
386+ url = "/storage_boxes/42/actions" ,
387+ params = {},
388+ )
389+
390+ assert len (result .actions ) == 1
391+ assert_bound_action (result .actions [0 ], resource_client ._parent .actions )
392+
393+ @pytest .mark .parametrize (
394+ "params" ,
395+ [
396+ {"status" : "" , "sort" : "" },
397+ {},
398+ ],
399+ )
400+ def test_get_actions (
401+ self ,
402+ request_mock : mock .MagicMock ,
403+ resource_client : StorageBoxesClient ,
404+ action_running1 ,
405+ params ,
406+ ):
407+ request_mock .return_value = {
408+ "actions" : [action_running1 ],
409+ }
410+
411+ result = resource_client .get_actions (StorageBox (id = 42 ), ** params )
412+
413+ request_mock .assert_called_with (
414+ method = "GET" ,
415+ url = "/storage_boxes/42/actions" ,
416+ params = {** params , "page" : 1 , "per_page" : 50 },
417+ )
418+
419+ assert len (result ) == 1
420+ assert_bound_action (result [0 ], resource_client ._parent .actions )
0 commit comments