File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed
Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change 1+ from typing import Union
2+
13from aikido_zen .context import get_current_context
24from aikido_zen .helpers .logging import logger
35
46
5- def set_rate_limit_group (group_id : str ):
6- if not group_id or not isinstance ( group_id , str ) :
7+ def set_rate_limit_group (group_id : Union [ str , int ] ):
8+ if not group_id :
79 logger .warning ("Group ID cannot be empty." )
810 return
911
12+ # Check if it's string of number, ensure string.
13+ if not isinstance (group_id , str ) and not isinstance (group_id , int ):
14+ logger .warning ("Group ID must be a string or a number" )
15+ return
16+ group_id = str (group_id )
17+
1018 context = get_current_context ()
1119 if not context :
1220 logger .warning (
Original file line number Diff line number Diff line change @@ -84,8 +84,15 @@ def test_set_rate_limit_group_non_string_group_id(caplog):
8484 context1 = set_context_and_lifecycle ()
8585 assert context1 .rate_limit_group is None
8686 set_rate_limit_group (123 )
87+ assert context1 .rate_limit_group == "123"
88+
89+
90+ def test_set_rate_limit_group_non_string_group_id_non_number (caplog ):
91+ context1 = set_context_and_lifecycle ()
8792 assert context1 .rate_limit_group is None
88- assert "Group ID cannot be empty." in caplog .text
93+ set_rate_limit_group ({"a" : "b" })
94+ assert context1 .rate_limit_group is None
95+ assert "Group ID must be a string or a number" in caplog .text
8996
9097
9198def test_set_rate_limit_group_overwrite_existing_group ():
You can’t perform that action at this time.
0 commit comments