1818from azure .iot .device .iothub .sync_handler_manager import MESSAGE , METHOD , TWIN_DP_PATCH
1919from azure .iot .device .iothub .inbox_manager import InboxManager
2020from azure .iot .device .iothub .aio .async_inbox import AsyncClientInbox
21- from tests .unit .helpers import EVENTUAL_TIMEOUT
21+ from tests .unit .helpers import BATCH_COMPLETION_TIMEOUT , PROMPT_TIMEOUT
2222
2323logging .basicConfig (level = logging .DEBUG )
2424
@@ -414,7 +414,7 @@ async def test_handler_invoked(
414414 mock_obj = mocker .MagicMock ()
415415 inbox .put (mock_obj )
416416 # Wait for the handler invocation to complete
417- await async_poll_until (lambda : handler_checker .handler_called , timeout = EVENTUAL_TIMEOUT )
417+ await async_poll_until (lambda : handler_checker .handler_called , timeout = PROMPT_TIMEOUT )
418418
419419 # Handler has been called with the item from the inbox
420420 assert handler_checker .handler_called is True
@@ -443,7 +443,8 @@ async def test_handler_invoked_multiple(
443443 inbox .put (mocker .MagicMock ())
444444 # Wait for all handler invocations to complete
445445 await async_poll_until (
446- lambda : handler_checker .handler_call_count >= 5 , timeout = EVENTUAL_TIMEOUT
446+ lambda : handler_checker .handler_call_count >= 5 ,
447+ timeout = BATCH_COMPLETION_TIMEOUT ,
447448 )
448449
449450 # Handler has been called 5 times
@@ -553,7 +554,7 @@ async def coro_handler(arg):
553554 # Add an item to corresponding inbox, triggering the handler
554555 inbox .put (mocker .MagicMock ())
555556 # Wait for the background exception handler to be called
556- await async_poll_until (lambda : background_exc_spy .call_count >= 1 , timeout = EVENTUAL_TIMEOUT )
557+ await async_poll_until (lambda : background_exc_spy .call_count >= 1 , timeout = PROMPT_TIMEOUT )
557558 # Background exception handler was called
558559 assert background_exc_spy .call_count == 1
559560 e = background_exc_spy .call_args [0 ][0 ]
@@ -570,7 +571,7 @@ async def coro_handler(arg):
570571 # Add an item to corresponding inbox, triggering the handler
571572 inbox .put (mocker .MagicMock ())
572573 # Wait for the background exception handler to be called
573- await async_poll_until (lambda : background_exc_spy .call_count >= 1 , timeout = EVENTUAL_TIMEOUT )
574+ await async_poll_until (lambda : background_exc_spy .call_count >= 1 , timeout = PROMPT_TIMEOUT )
574575 # Background exception handler was called
575576 assert background_exc_spy .call_count == 1
576577 e = background_exc_spy .call_args [0 ][0 ]
@@ -600,7 +601,7 @@ def handler1(arg):
600601 # Wait for handler1 to replace itself with handler2
601602 await async_poll_until (
602603 lambda : getattr (handler_manager , handler_name ) is handler2 ,
603- timeout = EVENTUAL_TIMEOUT ,
604+ timeout = PROMPT_TIMEOUT ,
604605 )
605606 # The set handler (handler1) has been replaced with a new handler (handler2)
606607 assert getattr (handler_manager , handler_name ) is not handler1
@@ -610,15 +611,15 @@ def handler1(arg):
610611 # Wait for handler2 to replace itself with the mock
611612 await async_poll_until (
612613 lambda : getattr (handler_manager , handler_name ) is mock_handler ,
613- timeout = EVENTUAL_TIMEOUT ,
614+ timeout = PROMPT_TIMEOUT ,
614615 )
615616 # The set handler (handler2) has now been replaced by a mock handler
616617 assert getattr (handler_manager , handler_name ) is not handler2
617618 assert getattr (handler_manager , handler_name ) is mock_handler
618619 # Add a new item to the inbox
619620 inbox .put (mocker .MagicMock ())
620621 # Wait for the mock handler invocation to complete
621- await async_poll_until (lambda : mock_handler .call_count >= 1 , timeout = EVENTUAL_TIMEOUT )
622+ await async_poll_until (lambda : mock_handler .call_count >= 1 , timeout = PROMPT_TIMEOUT )
622623 # The mock was now called
623624 assert getattr (handler_manager , handler_name ).call_count == 1
624625
@@ -712,7 +713,7 @@ async def test_handler_invoked(
712713 inbox .put (event )
713714 # Wait for the handler invocation to complete
714715 await async_poll_until (
715- lambda : handler_checker .handler_call_count >= 1 , timeout = EVENTUAL_TIMEOUT
716+ lambda : handler_checker .handler_call_count >= 1 , timeout = PROMPT_TIMEOUT
716717 )
717718
718719 # Handler has been called with the arguments from the event
@@ -723,7 +724,7 @@ async def test_handler_invoked(
723724 non_matching_event = client_event .ClientEvent ("NON_MATCHING_EVENT" )
724725 inbox .put (non_matching_event )
725726 # Wait for the runner to consume the non-matching event
726- await async_poll_until (inbox .empty , timeout = EVENTUAL_TIMEOUT )
727+ await async_poll_until (inbox .empty , timeout = PROMPT_TIMEOUT )
727728
728729 # Handler has not been called again
729730 assert handler_checker .handler_call_count == 1
@@ -751,7 +752,8 @@ async def test_handler_invoked_multiple(
751752 inbox .put (event )
752753 # Wait for all handler invocations to complete
753754 await async_poll_until (
754- lambda : handler_checker .handler_call_count >= 5 , timeout = EVENTUAL_TIMEOUT
755+ lambda : handler_checker .handler_call_count >= 5 ,
756+ timeout = BATCH_COMPLETION_TIMEOUT ,
755757 )
756758
757759 # Handler has been called 5 times
@@ -786,7 +788,7 @@ async def coro_handler(*args):
786788 # Add an item to corresponding inbox, triggering the handler
787789 inbox .put (event )
788790 # Wait for the background exception handler to be called
789- await async_poll_until (lambda : background_exc_spy .call_count >= 1 , timeout = EVENTUAL_TIMEOUT )
791+ await async_poll_until (lambda : background_exc_spy .call_count >= 1 , timeout = PROMPT_TIMEOUT )
790792 # Background exception handler was called
791793 assert background_exc_spy .call_count == 1
792794 e = background_exc_spy .call_args [0 ][0 ]
@@ -803,7 +805,7 @@ async def coro_handler(*args):
803805 # Add an item to corresponding inbox, triggering the handler
804806 inbox .put (event )
805807 # Wait for the background exception handler to be called
806- await async_poll_until (lambda : background_exc_spy .call_count >= 1 , timeout = EVENTUAL_TIMEOUT )
808+ await async_poll_until (lambda : background_exc_spy .call_count >= 1 , timeout = PROMPT_TIMEOUT )
807809 # Background exception handler was called
808810 assert background_exc_spy .call_count == 1
809811 e = background_exc_spy .call_args [0 ][0 ]
@@ -833,7 +835,7 @@ def handler1(*args):
833835 # Wait for handler1 to replace itself with handler2
834836 await async_poll_until (
835837 lambda : getattr (handler_manager , handler_name ) is handler2 ,
836- timeout = EVENTUAL_TIMEOUT ,
838+ timeout = PROMPT_TIMEOUT ,
837839 )
838840 # The set handler (handler1) has been replaced with a new handler (handler2)
839841 assert getattr (handler_manager , handler_name ) is not handler1
@@ -843,15 +845,15 @@ def handler1(*args):
843845 # Wait for handler2 to replace itself with the mock
844846 await async_poll_until (
845847 lambda : getattr (handler_manager , handler_name ) is mock_handler ,
846- timeout = EVENTUAL_TIMEOUT ,
848+ timeout = PROMPT_TIMEOUT ,
847849 )
848850 # The set handler (handler2) has now been replaced by a mock handler
849851 assert getattr (handler_manager , handler_name ) is not handler2
850852 assert getattr (handler_manager , handler_name ) is mock_handler
851853 # Add a new item to the inbox
852854 inbox .put (event )
853855 # Wait for the mock handler invocation to complete
854- await async_poll_until (lambda : mock_handler .call_count >= 1 , timeout = EVENTUAL_TIMEOUT )
856+ await async_poll_until (lambda : mock_handler .call_count >= 1 , timeout = PROMPT_TIMEOUT )
855857 # The mock was now called
856858 assert getattr (handler_manager , handler_name ).call_count == 1
857859
0 commit comments