示例#1
0
 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)
示例#2
0
 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)
示例#3
0
文件: cli.py 项目: zoni/octo
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)
示例#4
0
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)
示例#5
0
	def test_stop_raises_exception_when_called_twice(self, plugin_manager_mock):
		octo.run(plugin_dirs=[])
		octo.stop()
		octo.stop()
示例#6
0
	def test_start_and_stop_sequence_with_plugins(self, plugin_manager_mock):
		octo.run(plugin_dirs=[PLUGIN_DIR])
		octo.stop()
示例#7
0
	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)
示例#8
0
	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)
示例#9
0
	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)
示例#10
0
	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()])
示例#11
0
	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)
示例#12
0
 def test_stop_raises_exception_when_called_twice(self,
                                                  plugin_manager_mock):
     octo.run(plugin_dirs=[])
     octo.stop()
     octo.stop()
示例#13
0
 def test_start_and_stop_sequence_with_plugins(self, plugin_manager_mock):
     octo.run(plugin_dirs=[PLUGIN_DIR])
     octo.stop()
示例#14
0
 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)
示例#15
0
 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)
示例#16
0
 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()])