def test__dispatch_inapp(conf, commands): conf = conf() conf.app_dir = '/mock_dir' mock_func = Mock(return_value=10) commands.table = {'mock': (mock_func, [], 'just for testing')} commands.incouchapp = ['mock'] commands.globalopts = globalopts assert dispatch._dispatch(['mock']) == 10 mock_func.assert_called_with(conf, conf.app_dir)
def test__dispatch_update_commands(conf, commands): conf = conf() mock_func = Mock(return_value=10) mock_mod = Mock() mock_mod.cmdtable = {'mock': (mock_func, [], 'just for testing')} conf.extensions = [mock_mod] commands.table = {} commands.globalopts = globalopts assert dispatch._dispatch(['mock']) == 10 assert commands.table == mock_mod.cmdtable assert mock_func.called
def test__dispatch_unknown_command(): dispatch._dispatch(['unknown_command'])
def test__dispatch_quiet(set_logging_level): assert dispatch._dispatch(['-q']) == 0 set_logging_level.assert_called_with(0)
def test__dispatch_version(): assert dispatch._dispatch(['--version']) == 0
def test__dispatch_verbose(set_logging_level): assert dispatch._dispatch(['-v']) == 0 set_logging_level.assert_called_with(1)
def test__dispatch_help(): assert dispatch._dispatch(['-h']) == 0
def test__dispatch_debug(set_logging_level): assert dispatch._dispatch(['-d']) == 0 set_logging_level.assert_called_with(1)