Example #1
0
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)
Example #2
0
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)
Example #3
0
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
Example #4
0
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
Example #5
0
def test__dispatch_unknown_command():
    dispatch._dispatch(['unknown_command'])
Example #6
0
def test__dispatch_quiet(set_logging_level):
    assert dispatch._dispatch(['-q']) == 0
    set_logging_level.assert_called_with(0)
Example #7
0
def test__dispatch_version():
    assert dispatch._dispatch(['--version']) == 0
Example #8
0
def test__dispatch_verbose(set_logging_level):
    assert dispatch._dispatch(['-v']) == 0
    set_logging_level.assert_called_with(1)
Example #9
0
def test__dispatch_help():
    assert dispatch._dispatch(['-h']) == 0
Example #10
0
def test__dispatch_debug(set_logging_level):
    assert dispatch._dispatch(['-d']) == 0
    set_logging_level.assert_called_with(1)
Example #11
0
def test__dispatch_unknown_command():
    dispatch._dispatch(['unknown_command'])
Example #12
0
def test__dispatch_quiet(set_logging_level):
    assert dispatch._dispatch(['-q']) == 0
    set_logging_level.assert_called_with(0)
Example #13
0
def test__dispatch_version():
    assert dispatch._dispatch(['--version']) == 0
Example #14
0
def test__dispatch_verbose(set_logging_level):
    assert dispatch._dispatch(['-v']) == 0
    set_logging_level.assert_called_with(1)
Example #15
0
def test__dispatch_help():
    assert dispatch._dispatch(['-h']) == 0
Example #16
0
def test__dispatch_debug(set_logging_level):
    assert dispatch._dispatch(['-d']) == 0
    set_logging_level.assert_called_with(1)