@@ -710,19 +710,34 @@ def test_perpartition_with_fallback(caplog):
710710 with caplog .at_level (logging .WARNING , logger = "airbyte" ):
711711 with patch .object (SimpleRetriever , "_read_pages" , side_effect = records_list ):
712712 with patch .object (ConcurrentPerPartitionCursor , "DEFAULT_MAX_PARTITIONS_NUMBER" , 2 ):
713- output = list (source .read (logger , {}, catalog , initial_state ))
713+ with patch .object (ConcurrentPerPartitionCursor , "SWITCH_TO_GLOBAL_LIMIT" , 1 ):
714+ output = list (source .read (logger , {}, catalog , initial_state ))
714715
715716 # Check if the warnings were logged
716- expected_warning_messages = [
717- 'The maximum number of partitions has been reached. Dropping the oldest partition: {"partition_field":"1"}. Over limit: 1.' ,
718- 'The maximum number of partitions has been reached. Dropping the oldest partition: {"partition_field":"2"}. Over limit: 2.' ,
719- 'The maximum number of partitions has been reached. Dropping the oldest partition: {"partition_field":"3"}. Over limit: 3.' ,
720- ]
721-
722717 logged_messages = [record .message for record in caplog .records if record .levelname == "WARNING" ]
718+ warning_message = (
719+ "The maximum number of partitions has been reached. Dropping the oldest partition:"
720+ )
721+ expected_warning_over_limit_messages = [
722+ "Over limit: 1" ,
723+ "Over limit: 2" ,
724+ "Over limit: 3" ,
725+ ]
723726
724- for expected_message in expected_warning_messages :
725- assert expected_message in logged_messages
727+ for logged_message in logged_messages :
728+ assert warning_message in logged_message
729+
730+ for expected_warning_over_limit_message in expected_warning_over_limit_messages :
731+ assert (
732+ len (
733+ [
734+ logged_message
735+ for logged_message in logged_messages
736+ if expected_warning_over_limit_message in logged_message
737+ ]
738+ )
739+ > 0
740+ )
726741
727742 # Proceed with existing assertions
728743 final_state = [
0 commit comments