File tree Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ def prepare_send_data(
75
75
if TYPE_CHECKING :
76
76
assert isinstance (post_data , dict )
77
77
for k , v in post_data .items ():
78
- if isinstance (v , bool ):
78
+ if isinstance (v , ( bool , int ) ):
79
79
post_data [k ] = str (int (v ))
80
80
post_data ["file" ] = files .get ("file" )
81
81
post_data ["avatar" ] = files .get ("avatar" )
Original file line number Diff line number Diff line change @@ -378,7 +378,7 @@ def import_group(
378
378
file : BinaryIO ,
379
379
path : str ,
380
380
name : str ,
381
- parent_id : Optional [str ] = None ,
381
+ parent_id : Optional [Union [ int , str ] ] = None ,
382
382
** kwargs : Any ,
383
383
) -> Union [Dict [str , Any ], requests .Response ]:
384
384
"""Import a group from an archive file.
@@ -399,7 +399,7 @@ def import_group(
399
399
A representation of the import status.
400
400
"""
401
401
files = {"file" : ("file.tar.gz" , file , "application/octet-stream" )}
402
- data = {"path" : path , "name" : name }
402
+ data : Dict [ str , Any ] = {"path" : path , "name" : name }
403
403
if parent_id is not None :
404
404
data ["parent_id" ] = parent_id
405
405
Original file line number Diff line number Diff line change @@ -34,3 +34,15 @@ def test_prepare_send_data_str_parentid(self) -> None:
34
34
assert result .json is None
35
35
assert result .content_type .startswith ("multipart/form-data" )
36
36
assert isinstance (result .data , MultipartEncoder )
37
+
38
+ def test_prepare_send_data_int_parentid (self ) -> None :
39
+ file = "12345"
40
+ files = {"file" : ("file.tar.gz" , file , "application/octet-stream" )}
41
+ post_data = {"parent_id" : 12 }
42
+
43
+ result = requests_backend .RequestsBackend .prepare_send_data (
44
+ files = files , post_data = post_data , raw = False
45
+ )
46
+ assert result .json is None
47
+ assert result .content_type .startswith ("multipart/form-data" )
48
+ assert isinstance (result .data , MultipartEncoder )
You can’t perform that action at this time.
0 commit comments