#NEWLINE# def test_get_jail_stats( self ) : #NEWLINE# #INDENT# jails = [ 'ssh' ] #NEWLINE# jail_status = { #NEWLINE# #INDENT# 'filter' : { #NEWLINE# #INDENT# 'file_list' : '/var/log/auth.log' , #NEWLINE# 'currently_failed' : '2' , #NEWLINE# 'total_failed' : '62219' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'action' : { #NEWLINE# #INDENT# 'currently_banned' : '2' , #NEWLINE# 'ip_list' : '104.217.154.54 222.186.56.43' , #NEWLINE# 'total_banned' : '4985' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# expected = [ ( 'ssh' , 'fail2ban.action.currently_banned' , '2' ) , ( 'ssh' , 'fail2ban.action.total_banned' , '4985' ) , ( 'ssh' , 'fail2ban.filter.currently_failed' , '2' ) , ( 'ssh' , 'fail2ban.filter.total_failed' , '62219' ) ] #NEWLINE# with mock . patch . object ( self . check , 'get_jail_status' ) as get_jail_status : #NEWLINE# #INDENT# with mock . patch . object ( self . check , 'get_jails' ) as get_jails : #NEWLINE# #INDENT# get_jails . return_value = jails #NEWLINE# get_jail_status . return_value = jail_status #NEWLINE# stats = self . check . get_jail_stats ( ) #NEWLINE# self . assertEquals ( expected , list ( stats ) )