class TestOpenCenterAgentOutputBroken(unittest.TestCase): def setUp(self): self.agent = OpenCenterAgent( ['-c', 'tests/opencenter-agent-test-output-' 'broken.conf'], 'test') self.output_handler = self.agent.output_handler self.input_handler = self.agent.input_handler self.result = self.agent.input_handler.fetch() self.result['output'] = self.output_handler.dispatch( self.result['input']) self.agent.input_handler.result(self.result) self.input_state = \ self.agent.input_handler.plugins['input']['state'] self.output_state = \ self.agent.output_handler.plugins['output']['state'] def tearDown(self): self.agent._cleanup() def test_input_setup(self): self.assertTrue(self.input_state.input_setup_called) def test_input_fetch(self): self.assertTrue(self.input_state.input_fetch_called) def test_input_result(self): self.assertEqual(self.result['input'], { 'action': 'test', 'id': 'test', 'payload': {} }) def test_input_teardown(self): # Stop it so teardown occurs self.agent.input_handler.stop() self.assertTrue(self.input_state.input_teardown_called) def test_output_setup(self): self.assertTrue(self.output_state.output_setup_called) def test_output_handler(self): self.assertFalse(self.output_state.output_handler_called) def test_output_result(self): self.assertEqual( self.result['output'], { 'result_code': 253, 'result_data': '', 'result_str': 'no dispatcher found for action "test"' }) def test_output_teardown(self): # Stop it so teardown occurs self.agent.output_handler.stop() self.assertTrue(self.output_state.output_teardown_called)
class TestOpenCenterAgentInputBroken(unittest.TestCase): def setUp(self): self.agent = OpenCenterAgent(['-c', 'tests/opencenter-agent-test-input' '-broken.conf'], 'test') self.output_handler = self.agent.output_handler self.input_handler = self.agent.input_handler self.result = self.agent.input_handler.fetch() # TODO: Make not suck plz try: self.result['output'] = self.output_handler.dispatch( self.result['input']) self.agent.input_handler.result(self.result) except KeyError: self.key_error = True self.input_state = \ self.agent.input_handler.plugins['input']['state'] self.output_state = \ self.agent.output_handler.plugins['output']['state'] def tearDown(self): self.agent._cleanup() def test_input_setup(self): self.assertTrue(self.input_state.input_setup_called) def test_input_fetch(self): self.assertTrue(self.input_state.input_fetch_called) def test_input_result(self): self.assertEqual(self.result['input'], {'foo': 'bar'}) def test_input_teardown(self): # Stop it so teardown occurs self.agent.input_handler.stop() self.assertTrue(self.input_state.input_teardown_called) def test_output_setup(self): self.assertTrue(self.output_state.output_setup_called) def test_output_handler(self): # Output plugin never dispatched self.assertFalse(self.output_state.output_handler_called) def test_output_result(self): # Output plugin dispatch failed self.assertTrue(self.key_error) def test_output_teardown(self): # Stop it so teardown occurs self.agent.output_handler.stop() self.assertTrue(self.output_state.output_teardown_called)
class TestOpenCenterAgentWorking(unittest.TestCase): def setUp(self): self.agent = OpenCenterAgent( ['-c', 'tests/' 'opencenter-agent-test-working.conf'], 'test') self.output_handler = self.agent.output_handler self.input_handler = self.agent.input_handler self.result = self.agent.input_handler.fetch() self.result['output'] = self.output_handler.dispatch( self.result['input']) self.agent.input_handler.result(self.result) self.input_state = \ self.agent.input_handler.plugins['input']['state'] self.output_state = \ self.agent.output_handler.plugins['output']['state'] def tearDown(self): self.agent._cleanup() def test_input_setup(self): self.assertTrue(self.input_state.input_setup_called) def test_input_fetch(self): self.assertTrue(self.input_state.input_fetch_called) def test_input_result(self): self.assertEqual(self.result['input'], { 'action': 'test', 'id': 'test', 'payload': {} }) def test_input_teardown(self): # Stop it so teardown occurs self.agent.input_handler.stop() self.assertTrue(self.input_state.input_teardown_called) def test_output_setup(self): self.assertTrue(self.output_state.output_setup_called) def test_output_handler(self): self.assertTrue(self.output_state.output_handler_called) def test_output_result(self): self.assertEqual(self.result['output'], { 'result_code': 0, 'result_data': None, 'result_str': 'success' }) def test_output_teardown(self): # Stop it so teardown occurs self.agent.output_handler.stop() self.assertTrue(self.output_state.output_teardown_called)
class TestOpenCenterAgentInputBroken(unittest.TestCase): def setUp(self): self.agent = OpenCenterAgent( ['-c', 'tests/opencenter-agent-test-input' '-broken.conf'], 'test') self.output_handler = self.agent.output_handler self.input_handler = self.agent.input_handler self.result = self.agent.input_handler.fetch() # TODO: Make not suck plz try: self.result['output'] = self.output_handler.dispatch( self.result['input']) self.agent.input_handler.result(self.result) except KeyError: self.key_error = True self.input_state = \ self.agent.input_handler.plugins['input']['state'] self.output_state = \ self.agent.output_handler.plugins['output']['state'] def tearDown(self): self.agent._cleanup() def test_input_setup(self): self.assertTrue(self.input_state.input_setup_called) def test_input_fetch(self): self.assertTrue(self.input_state.input_fetch_called) def test_input_result(self): self.assertEqual(self.result['input'], {'foo': 'bar'}) def test_input_teardown(self): # Stop it so teardown occurs self.agent.input_handler.stop() self.assertTrue(self.input_state.input_teardown_called) def test_output_setup(self): self.assertTrue(self.output_state.output_setup_called) def test_output_handler(self): # Output plugin never dispatched self.assertFalse(self.output_state.output_handler_called) def test_output_result(self): # Output plugin dispatch failed self.assertTrue(self.key_error) def test_output_teardown(self): # Stop it so teardown occurs self.agent.output_handler.stop() self.assertTrue(self.output_state.output_teardown_called)
class TestOpenCenterAgentOutputBroken(unittest.TestCase): def setUp(self): self.agent = OpenCenterAgent(['-c', 'tests/opencenter-agent-test-output-' 'broken.conf'], 'test') self.output_handler = self.agent.output_handler self.input_handler = self.agent.input_handler self.result = self.agent.input_handler.fetch() self.result['output'] = self.output_handler.dispatch( self.result['input']) self.agent.input_handler.result(self.result) self.input_state = \ self.agent.input_handler.plugins['input']['state'] self.output_state = \ self.agent.output_handler.plugins['output']['state'] def tearDown(self): self.agent._cleanup() def test_input_setup(self): self.assertTrue(self.input_state.input_setup_called) def test_input_fetch(self): self.assertTrue(self.input_state.input_fetch_called) def test_input_result(self): self.assertEqual(self.result['input'], {'action': 'test', 'id': 'test', 'payload': {}}) def test_input_teardown(self): # Stop it so teardown occurs self.agent.input_handler.stop() self.assertTrue(self.input_state.input_teardown_called) def test_output_setup(self): self.assertTrue(self.output_state.output_setup_called) def test_output_handler(self): self.assertFalse(self.output_state.output_handler_called) def test_output_result(self): self.assertEqual(self.result['output'], {'result_code': 253, 'result_data': '', 'result_str': 'no dispatcher found for action "test"'}) def test_output_teardown(self): # Stop it so teardown occurs self.agent.output_handler.stop() self.assertTrue(self.output_state.output_teardown_called)
class TestOpenCenterAgentWorking(unittest.TestCase): def setUp(self): self.agent = OpenCenterAgent(['-c', 'tests/' 'opencenter-agent-test-working.conf'], 'test') self.output_handler = self.agent.output_handler self.input_handler = self.agent.input_handler self.result = self.agent.input_handler.fetch() self.result['output'] = self.output_handler.dispatch( self.result['input']) self.agent.input_handler.result(self.result) self.input_state = \ self.agent.input_handler.plugins['input']['state'] self.output_state = \ self.agent.output_handler.plugins['output']['state'] def tearDown(self): self.agent._cleanup() def test_input_setup(self): self.assertTrue(self.input_state.input_setup_called) def test_input_fetch(self): self.assertTrue(self.input_state.input_fetch_called) def test_input_result(self): self.assertEqual(self.result['input'], {'action': 'test', 'id': 'test', 'payload': {}}) def test_input_teardown(self): # Stop it so teardown occurs self.agent.input_handler.stop() self.assertTrue(self.input_state.input_teardown_called) def test_output_setup(self): self.assertTrue(self.output_state.output_setup_called) def test_output_handler(self): self.assertTrue(self.output_state.output_handler_called) def test_output_result(self): self.assertEqual(self.result['output'], {'result_code': 0, 'result_data': None, 'result_str': 'success'}) def test_output_teardown(self): # Stop it so teardown occurs self.agent.output_handler.stop() self.assertTrue(self.output_state.output_teardown_called)
def setUp(self): self.agent = OpenCenterAgent( ['-c', 'tests/' 'opencenter-agent-test-working.conf'], 'test') self.output_handler = self.agent.output_handler self.input_handler = self.agent.input_handler self.result = self.agent.input_handler.fetch() self.result['output'] = self.output_handler.dispatch( self.result['input']) self.agent.input_handler.result(self.result) self.input_state = \ self.agent.input_handler.plugins['input']['state'] self.output_state = \ self.agent.output_handler.plugins['output']['state']
def setUp(self): self.agent = OpenCenterAgent( ['-c', 'tests/opencenter-agent-test-input' '-broken.conf'], 'test') self.output_handler = self.agent.output_handler self.input_handler = self.agent.input_handler self.result = self.agent.input_handler.fetch() # TODO: Make not suck plz try: self.result['output'] = self.output_handler.dispatch( self.result['input']) self.agent.input_handler.result(self.result) except KeyError: self.key_error = True self.input_state = \ self.agent.input_handler.plugins['input']['state'] self.output_state = \ self.agent.output_handler.plugins['output']['state']
def setUp(self): self.agent = OpenCenterAgent(['-c', 'tests/' 'opencenter-agent-test-working.conf'], 'test') self.output_handler = self.agent.output_handler self.input_handler = self.agent.input_handler self.result = self.agent.input_handler.fetch() self.result['output'] = self.output_handler.dispatch( self.result['input']) self.agent.input_handler.result(self.result) self.input_state = \ self.agent.input_handler.plugins['input']['state'] self.output_state = \ self.agent.output_handler.plugins['output']['state']
def setUp(self): self.agent = OpenCenterAgent(['-c', 'tests/opencenter-agent-test-input' '-broken.conf'], 'test') self.output_handler = self.agent.output_handler self.input_handler = self.agent.input_handler self.result = self.agent.input_handler.fetch() # TODO: Make not suck plz try: self.result['output'] = self.output_handler.dispatch( self.result['input']) self.agent.input_handler.result(self.result) except KeyError: self.key_error = True self.input_state = \ self.agent.input_handler.plugins['input']['state'] self.output_state = \ self.agent.output_handler.plugins['output']['state']
# # OpenCenter is licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. This # version of OpenCenter includes Rackspace trademarks and logos, and in # accordance with Section 6 of the License, the provision of commercial # support services in conjunction with a version of OpenCenter which includes # Rackspace trademarks and logos is prohibited. OpenCenter source code and # details are available at: # https://github.com/rcbops/opencenter or upon # written request. # # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 and a copy, including this # notice, is available in the LICENSE file accompanying this software. # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the # specific language governing permissions and limitations # under the License. # ############################################################################## # # import sys from opencenteragent import OpenCenterAgent if __name__ == '__main__': opencenteragent = OpenCenterAgent(sys.argv[1:]) opencenteragent.dispatch()