# 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
        with utils.temporary_directory() as path:
            om = output_manager.OutputManager(path)
            om.loadfile = self.fake_loadfile

            out = om.handle_modules({'action': 'modules.load'})
            self.assertEqual(out['result_code'], 1)
            self.assertEqual(out['result_str'],
                             'no payload specified')

            out = om.handle_modules({'action': 'modules.load',
                                     'payload': {'gerbil': True}})
            self.assertEqual(out['result_code'], 1)
            self.assertEqual(out['result_str'],
                             'no "path" specified in payload')

            out = om.handle_modules({'action': 'modules.load',
                                     'payload': {'path': '/tmp/no/such'}})
            self.assertEqual(out['result_code'], 1)
            self.assertEqual(out['result_str'],
                             'specified module does not exist')

            self.loadfile_calls = 0
            with utils.temporary_file() as path:
                out = om.handle_modules({'action': 'modules.load',
                                         'payload': {'path': path}})
                self.assertEqual(out['result_code'], 0)
                self.assertEqual(self.loadfile_calls, 1)

    def test_handle_modules_reload(self):
        with utils.temporary_directory() as 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

        with utils.temporary_directory() as path:
            om = output_manager.OutputManager(path)
            om.loadfile = self.fake_loadfile

            out = om.handle_modules({'action': 'modules.load'})
            self.assertEqual(out['result_code'], 1)
            self.assertEqual(out['result_str'],
                             'no payload specified')

            out = om.handle_modules({'action': 'modules.load',
                                     'payload': {'gerbil': True}})
            self.assertEqual(out['result_code'], 1)
            self.assertEqual(out['result_str'],
                             'no "path" specified in payload')

            out = om.handle_modules({'action': 'modules.load',
                                     'payload': {'path': '/tmp/no/such'}})
            self.assertEqual(out['result_code'], 1)
            self.assertEqual(out['result_str'],
                             'specified module does not exist')

            self.loadfile_calls = 0
            with utils.temporary_file() as path:
                out = om.handle_modules({'action': 'modules.load',
                                         'payload': {'path': path}})
                self.assertEqual(out['result_code'], 0)
                self.assertEqual(self.loadfile_calls, 1)

    def test_handle_modules_reload(self):
        with utils.temporary_directory() as path:

            om = output_manager.OutputManager(path)