#NEWLINE# def test_monitoring_not_tty( self ) : #NEWLINE# #INDENT# 'Establish that the monitor command prints more useful output\n        for logging if not connected to a tty.\n        ' #NEWLINE# data = { #NEWLINE# #INDENT# 'elapsed' : 1335024000.0 , #NEWLINE# 'failed' : False , #NEWLINE# 'status' : 'pending' , #NEWLINE# #UNINDENT# } #NEWLINE# with client . test_mode as t : #NEWLINE# #INDENT# t . register_json ( '/jobs/42/' , copy ( data ) ) #NEWLINE# def assign_success( * args ) : #NEWLINE# #INDENT# t . clear ( ) #NEWLINE# t . register_json ( '/jobs/42/' , dict ( data , status = 'successful' ) ) #NEWLINE# #UNINDENT# with mock . patch . object ( time , 'sleep' ) as sleep : #NEWLINE# #INDENT# sleep . side_effect = assign_success #NEWLINE# with mock . patch . object ( click , 'echo' ) as echo : #NEWLINE# #INDENT# with mock . patch ( 'tower_cli.models.base.is_tty' ) as tty : #NEWLINE# #INDENT# tty . return_value = False #NEWLINE# self . res . monitor ( 42 , min_interval = 0.21 ) #NEWLINE# #UNINDENT# #UNINDENT# self . assertTrue ( ( echo . call_count >= 1 ) ) #NEWLINE# #UNINDENT# self . assertEqual ( len ( t . requests ) , 2 ) #NEWLINE# self . assertEqual ( t . requests [ 0 ] . url , t . requests [ 1 ] . url )