#NEWLINE# def test_dashes( self ) : #NEWLINE# #INDENT# ( name , temp0 ) = get_temp_file ( ) #NEWLINE# self . dogshell ( [ 'dashboard' , 'new_file' , name ] ) #NEWLINE# dash = json . load ( temp0 ) #NEWLINE# assert ( 'id' in dash ) , dash #NEWLINE# assert ( 'title' in dash ) , dash #NEWLINE# unique = self . get_unique ( ) #NEWLINE# dash [ 'title' ] = ( 'dash title %s' % unique ) #NEWLINE# ( name , temp1 ) = get_temp_file ( ) #NEWLINE# json . dump ( dash , temp1 ) #NEWLINE# temp1 . flush ( ) #NEWLINE# self . dogshell ( [ 'dashboard' , 'push' , temp1 . name ] ) #NEWLINE# ( out , _ , _ ) = self . dogshell ( [ 'dashboard' , 'show' , str ( dash [ 'id' ] ) ] ) #NEWLINE# out = json . loads ( out ) #NEWLINE# assert ( 'dash' in out ) , out #NEWLINE# assert ( 'id' in out [ 'dash' ] ) , out #NEWLINE# self . assertEquals ( out [ 'dash' ] [ 'id' ] , dash [ 'id' ] ) #NEWLINE# assert ( 'title' in out [ 'dash' ] ) #NEWLINE# self . assertEquals ( out [ 'dash' ] [ 'title' ] , dash [ 'title' ] ) #NEWLINE# new_title = 'new_title' #NEWLINE# new_desc = 'new_desc' #NEWLINE# new_dash = [ { #NEWLINE# #INDENT# 'title' : 'blerg' , #NEWLINE# 'definition' : { #NEWLINE# #INDENT# 'requests' : [ { #NEWLINE# #INDENT# 'q' : 'avg:system.load.15{web,env:prod}' , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ] #NEWLINE# self . dogshell ( [ 'dashboard' , 'update' , str ( dash [ 'id' ] ) , new_title , new_desc ] , stdin = json . dumps ( new_dash ) ) #NEWLINE# ( out , _ , _ ) = self . dogshell ( [ 'dashboard' , 'show' , str ( dash [ 'id' ] ) ] ) #NEWLINE# out = json . loads ( out ) #NEWLINE# assert ( 'dash' in out ) , out #NEWLINE# assert ( 'id' in out [ 'dash' ] ) , out #NEWLINE# self . assertEquals ( out [ 'dash' ] [ 'id' ] , dash [ 'id' ] ) #NEWLINE# assert ( 'title' in out [ 'dash' ] ) , out #NEWLINE# self . assertEquals ( out [ 'dash' ] [ 'title' ] , new_title ) #NEWLINE# assert ( 'description' in out [ 'dash' ] ) , out #NEWLINE# self . assertEquals ( out [ 'dash' ] [ 'description' ] , new_desc ) #NEWLINE# assert ( 'graphs' in out [ 'dash' ] ) , out #NEWLINE# self . assertEquals ( out [ 'dash' ] [ 'graphs' ] , new_dash ) #NEWLINE# ( fd , updated_file ) = tempfile . mkstemp ( ) #NEWLINE# try : #NEWLINE# #INDENT# self . dogshell ( [ 'dashboard' , 'pull' , str ( dash [ 'id' ] ) , updated_file ] ) #NEWLINE# updated_dash = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# with open ( updated_file ) as f : #NEWLINE# #INDENT# updated_dash = json . load ( f ) #NEWLINE# #UNINDENT# assert ( 'dash' in out ) #NEWLINE# self . assertEquals ( out [ 'dash' ] , updated_dash ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# os . unlink ( updated_file ) #NEWLINE# #UNINDENT# self . dogshell ( [ 'dashboard' , 'delete' , str ( dash [ 'id' ] ) ] ) #NEWLINE# ( out , err , return_code ) = self . dogshell ( [ 'dashboard' , 'show' , str ( dash [ 'id' ] ) ] , check_return_code = False ) #NEWLINE# self . assertNotEquals ( return_code , 0 )