def test_monkey_patch(self): utils.monkey_patch() masakari.tests.unit.monkey_patch_example.CALLED_FUNCTION = [] from masakari.tests.unit.monkey_patch_example import example_a from masakari.tests.unit.monkey_patch_example import example_b self.assertEqual('Example function', example_a.example_function_a()) exampleA = example_a.ExampleClassA() exampleA.example_method() ret_a = exampleA.example_method_add(3, 5) self.assertEqual(ret_a, 8) self.assertEqual('Example function', example_b.example_function_b()) exampleB = example_b.ExampleClassB() exampleB.example_method() ret_b = exampleB.example_method_add(3, 5) self.assertEqual(ret_b, 8) package_a = self.example_package + 'example_a.' self.assertIn(package_a + 'example_function_a', masakari.tests.unit.monkey_patch_example.CALLED_FUNCTION) self.assertIn(package_a + 'ExampleClassA.example_method', masakari.tests.unit.monkey_patch_example.CALLED_FUNCTION) self.assertIn(package_a + 'ExampleClassA.example_method_add', masakari.tests.unit.monkey_patch_example.CALLED_FUNCTION) package_b = self.example_package + 'example_b.' self.assertNotIn(package_b + 'example_function_b', ( masakari.tests.unit.monkey_patch_example.CALLED_FUNCTION)) self.assertNotIn(package_b + 'ExampleClassB.example_method', ( masakari.tests.unit.monkey_patch_example.CALLED_FUNCTION)) self.assertNotIn(package_b + 'ExampleClassB.example_method_add', ( masakari.tests.unit.monkey_patch_example.CALLED_FUNCTION))
def main(): config.parse_args(sys.argv) logging.setup(CONF, "masakari") utils.monkey_patch() objects.register_all() server = service.Service.create(binary='masakari-engine', topic=CONF.masakari_topic) service.serve(server) service.wait()