#NEWLINE# def testPut( self ) : #NEWLINE# #INDENT# 'Tests UploadFile.put().' #NEWLINE# self . mox . StubOutWithMock ( uploadfile . main_common , 'SanitizeUUID' ) #NEWLINE# self . mox . StubOutWithMock ( uploadfile . models , 'ClientLogFile' ) #NEWLINE# self . mox . StubOutWithMock ( uploadfile . models . Computer , 'get_by_key_name' ) #NEWLINE# self . mox . StubOutWithMock ( uploadfile . deferred , 'defer' ) #NEWLINE# uuid = 'foouuid' #NEWLINE# file_type = 'log' #NEWLINE# file_name = 'file.log' #NEWLINE# file_body = 'asdfasdf' #NEWLINE# key_name = ( '%s_%s' % ( uuid , file_name ) ) #NEWLINE# self . request . body = file_body #NEWLINE# notify_addresses_str = 'foo@example.com,bar@example.com' #NEWLINE# notify_addresses_list = [ 'foo@example.com' , 'bar@example.com' ] #NEWLINE# mock_session = self . mox . CreateMockAnything ( ) #NEWLINE# mock_session . uuid = uuid #NEWLINE# self . MockDoMunkiAuth ( and_return = mock_session ) #NEWLINE# uploadfile . main_common . SanitizeUUID ( uuid ) . AndReturn ( uuid ) #NEWLINE# mock_model = self . mox . CreateMockAnything ( ) #NEWLINE# uploadfile . models . ClientLogFile ( key_name = key_name ) . AndReturn ( mock_model ) #NEWLINE# mock_model . put ( ) . AndReturn ( None ) #NEWLINE# mock_computer = self . mox . CreateMockAnything ( ) #NEWLINE# mock_computer . upload_logs_and_notify = notify_addresses_str #NEWLINE# uploadfile . models . Computer . get_by_key_name ( uuid ) . AndReturn ( mock_computer ) #NEWLINE# mock_computer . put ( ) . AndReturn ( None ) #NEWLINE# uploadfile . deferred . defer ( uploadfile . SendNotificationEmail , notify_addresses_list , mock_computer , uploadfile . settings . SERVER_HOSTNAME ) #NEWLINE# self . mox . ReplayAll ( ) #NEWLINE# self . c . put ( file_type = file_type , file_name = file_name ) #NEWLINE# self . assertEqual ( mock_model . log_file , file_body ) #NEWLINE# self . assertEqual ( mock_model . uuid , uuid ) #NEWLINE# self . assertEqual ( None , mock_computer . upload_logs_and_notify ) #NEWLINE# self . mox . VerifyAll ( )