@@ -457,6 +457,48 @@ def test_independent_buffer(self):
457457 # The buffer is now auto-cleared.
458458 self .assertEqual (str (buf ), '' )
459459
460+ def test_auto_flush_settings_defaults (self ):
461+ for protocol in ('tcp' , 'tcps' , 'http' , 'https' ):
462+ sender = self .builder (protocol , 'localhost' , 9009 )
463+ self .assertTrue (sender .auto_flush )
464+ self .assertEqual (sender .auto_flush_bytes , None )
465+ self .assertEqual (
466+ sender .auto_flush_rows ,
467+ 75000 if protocol .startswith ('http' ) else 600 )
468+ self .assertEqual (sender .auto_flush_interval , datetime .timedelta (seconds = 1 ))
469+
470+ def test_auto_flush_settings_off (self ):
471+ for protocol in ('tcp' , 'tcps' , 'http' , 'https' ):
472+ sender = self .builder (protocol , 'localhost' , 9009 , auto_flush = False )
473+ self .assertFalse (sender .auto_flush )
474+ self .assertEqual (sender .auto_flush_bytes , None )
475+ self .assertEqual (sender .auto_flush_rows , None )
476+ self .assertEqual (sender .auto_flush_interval , None )
477+
478+ def test_auto_flush_settings_on (self ):
479+ for protocol in ('tcp' , 'tcps' , 'http' , 'https' ):
480+ sender = self .builder (protocol , 'localhost' , 9009 , auto_flush = True )
481+ # Same as default.
482+ self .assertEqual (sender .auto_flush_bytes , None )
483+ self .assertEqual (
484+ sender .auto_flush_rows ,
485+ 75000 if protocol .startswith ('http' ) else 600 )
486+ self .assertEqual (sender .auto_flush_interval , datetime .timedelta (seconds = 1 ))
487+
488+ def test_auto_flush_settings_specified (self ):
489+ for protocol in ('tcp' , 'tcps' , 'http' , 'https' ):
490+ sender = self .builder (
491+ protocol ,
492+ 'localhost' ,
493+ 9009 ,
494+ auto_flush_bytes = 1024 ,
495+ auto_flush_rows = 100 ,
496+ auto_flush_interval = datetime .timedelta (milliseconds = 50 ))
497+ self .assertTrue (sender .auto_flush )
498+ self .assertEqual (sender .auto_flush_bytes , 1024 )
499+ self .assertEqual (sender .auto_flush_rows , 100 )
500+ self .assertEqual (sender .auto_flush_interval , datetime .timedelta (milliseconds = 50 ))
501+
460502 def test_auto_flush (self ):
461503 with Server () as server :
462504 with self .builder (
0 commit comments