def test_start_can_block_until_sigint_received(self, pause_mock, signal_mock, plugin_manager_mock): octo.run(plugin_dirs=[], block=True) signal_mock.assert_called_with(signal.SIGINT, octo.manager.exit_handler) self.assertTrue(pause_mock.called)
def test_start_initializes_manager_stop_resets_instance( self, plugin_manager_mock): self.assertEqual(octo.instance, None) octo.run(plugin_dirs=[]) self.assertTrue(isinstance(octo.instance, octo.Manager)) octo.stop() self.assertEqual(octo.instance, None)
def main(): """ Main entry point for octo CLI script. Normally, setuptools packaging will create a script which uses this function as it's entry point. (See entry_points in setup.py). """ parser = argparse.ArgumentParser() parser.add_argument('-l', '--log-level', help="Log level to use. Valid values are NONE, " "DEBUG, INFO, WARNING, ERROR and CRITICAL", default="INFO") parser.add_argument('plugin_dirs', metavar='plugin-directory', help="Directory from which to load plugins", nargs='+') args = parser.parse_args() log_level = args.log_level.upper() if log_level != "NONE": logging.basicConfig(level=getattr(logging, log_level)) octo.run(plugin_dirs=args.plugin_dirs, block=True)
def test_stop_raises_exception_when_called_twice(self, plugin_manager_mock): octo.run(plugin_dirs=[]) octo.stop() octo.stop()
def test_start_and_stop_sequence_with_plugins(self, plugin_manager_mock): octo.run(plugin_dirs=[PLUGIN_DIR]) octo.stop()
def test_stop_deletes_manager(self, plugin_manager_mock): octo.run(plugin_dirs=[]) self.assertTrue(isinstance(octo.instance, octo.Manager)) octo.stop() self.assertEqual(octo.instance, None)
def test_stop_calls_instance_stop(self, plugin_manager_mock): octo.run(plugin_dirs=[]) with patch.object(octo, 'instance') as mock_method: octo.stop() self.assertTrue(mock_method.stop.called)
def test_start_calls_instance_start(self, plugin_manager_mock): with patch.object(octo.manager, 'Manager') as mock_method: octo.run(plugin_dirs=[]) self.assertEqual(mock_method.mock_calls, [call(plugin_dirs=[]), call().start()])
def test_start_initializes_manager_stop_resets_instance(self, plugin_manager_mock): self.assertEqual(octo.instance, None) octo.run(plugin_dirs=[]) self.assertTrue(isinstance(octo.instance, octo.Manager)) octo.stop() self.assertEqual(octo.instance, None)
def test_start_calls_instance_start(self, plugin_manager_mock): with patch.object(octo.manager, 'Manager') as mock_method: octo.run(plugin_dirs=[]) self.assertEqual( mock_method.mock_calls, [call(plugin_dirs=[]), call().start()])