def testPut(self):
    self.mox.StubOutWithMock(uploadfile.main_common, 'SanitizeUUID')
    self.mox.StubOutWithMock(uploadfile.models, 'ClientLogFile')
    self.mox.StubOutWithMock(uploadfile.models.Computer, 'get_by_key_name')
    self.mox.StubOutWithMock(uploadfile.deferred, 'defer')

    uuid = 'foouuid'
    file_type = 'log'
    file_name = 'file.log'
    file_body = 'asdfasdf'
    key_name = '%s_%s' % (uuid, file_name)
    self.request.body = file_body
    notify_addresses_str = 'foo@example.com,bar@example.com'
    notify_addresses_list = ['foo@example.com', 'bar@example.com']

    mock_session = self.mox.CreateMockAnything()
    mock_session.uuid = uuid
    self.MockDoMunkiAuth(and_return=mock_session)
    uploadfile.main_common.SanitizeUUID(uuid).AndReturn(uuid)

    mock_model = self.mox.CreateMockAnything()
    uploadfile.models.ClientLogFile(key_name=key_name).AndReturn(mock_model)
    mock_model.put().AndReturn(None)

    mock_computer = self.mox.CreateMockAnything()
    mock_computer.upload_logs_and_notify = notify_addresses_str
    uploadfile.models.Computer.get_by_key_name(uuid).AndReturn(mock_computer)
    mock_computer.put().AndReturn(None)

    uploadfile.deferred.defer(
        uploadfile.SendNotificationEmail, notify_addresses_list, mock_computer,
        uploadfile.settings.SERVER_HOSTNAME)

    self.mox.ReplayAll()
    self.c.put(file_type=file_type, file_name=file_name)
    self.assertEqual(mock_model.log_file, file_body)
    self.assertEqual(mock_model.uuid, uuid)
    self.assertEqual(None, mock_computer.upload_logs_and_notify)
    self.mox.VerifyAll()
Tests UploadFile.put().
dataset/ETHPy150Open google/simian/src/tests/simian/mac/munki/handlers/uploadfile_test.py/UploadFileHandlerTest.testPut