# Path: opencenteragent/modules/output_manager.py
# LOG = logging.getLogger('opencenter.output')
# def _ok(code=0, message='success', data={}):
# def _fail(code=1, message='unknown failure', data={}):
# def _xfer_to_eof(fd_in, sock_out):
#     def __init__(self, path, config={}):
#     def register_action(self, plugin, shortpath, action, method,
#                         constraints=[], consequences=[], args={},
#                         timeout=30):
#     def actions(self):
#     def dispatch(self, input_data):
#     def handle_logfile(self, input_data, sock=None):
#     def handle_modules(self, input_data):
# class OutputManager(manager.Manager):
# 
# Path: opencenteragent/utils.py
# def detailed_exception():
# def temporary_file():
# def temporary_directory():


import fixtures
import os
import socket
import testtools
import unittest
from opencenteragent.modules import output_manager
from opencenteragent import utils
                    return len(size)
                return 0

        class ExceptionalSocketLikeObject(object):
            def send(self, data):
                raise Exception('Unexpected banana!')

        f = FileLikeObject(2)
        s = SocketLikeObject(100)
        self.assertTrue(output_manager._xfer_to_eof(f, s))

        f = FileLikeObject(100)
        s = SocketLikeObject(1)
        self.assertFalse(output_manager._xfer_to_eof(f, s))

        f = FileLikeObject(100)
        s = ExceptionalSocketLikeObject()
        self.assertFalse(output_manager._xfer_to_eof(f, s))

    def test_handle_logfile_no_payload(self):
        with utils.temporary_directory() as path:
            om = output_manager.OutputManager(path)
            out = om.handle_logfile({'action': 'modules.load',
                                     'payload': {}})
            self.assertEqual(out['result_code'], 1)

    def test_handle_logfile_no_such_logfile(self):
        with utils.temporary_directory() as path:
            with utils.temporary_directory() as logdir:
                om = output_manager.OutputManager(path)

# Path: opencenteragent/modules/output_manager.py
# LOG = logging.getLogger('opencenter.output')
# def _ok(code=0, message='success', data={}):
# def _fail(code=1, message='unknown failure', data={}):
# def _xfer_to_eof(fd_in, sock_out):
#     def __init__(self, path, config={}):
#     def register_action(self, plugin, shortpath, action, method,
#                         constraints=[], consequences=[], args={},
#                         timeout=30):
#     def actions(self):
#     def dispatch(self, input_data):
#     def handle_logfile(self, input_data, sock=None):
#     def handle_modules(self, input_data):
# class OutputManager(manager.Manager):
# 
# Path: opencenteragent/utils.py
# def detailed_exception():
# def temporary_file():
# def temporary_directory():


# Path: tests/test_modules_output_manager.py
import fixtures
import os
import socket
import testtools
import unittest
from opencenteragent.modules import output_manager
from opencenteragent import utils

                    return len(size)
                return 0

        class ExceptionalSocketLikeObject(object):
            def send(self, data):
                raise Exception('Unexpected banana!')

        f = FileLikeObject(2)
        s = SocketLikeObject(100)
        self.assertTrue(output_manager._xfer_to_eof(f, s))

        f = FileLikeObject(100)
        s = SocketLikeObject(1)
        self.assertFalse(output_manager._xfer_to_eof(f, s))

        f = FileLikeObject(100)
        s = ExceptionalSocketLikeObject()
        self.assertFalse(output_manager._xfer_to_eof(f, s))

    def test_handle_logfile_no_payload(self):
        with utils.temporary_directory() as path:
            om = output_manager.OutputManager(path)
            out = om.handle_logfile({'action': 'modules.load',
                                     'payload': {}})
            self.assertEqual(out['result_code'], 1)

    def test_handle_logfile_no_such_logfile(self):
        with utils.temporary_directory() as path:
            with utils.temporary_directory() as logdir:
                om = output_manager.OutputManager(path)

                om.config = {'main': {'trans_log_dir': logdir}}