Пример #1
0
def test_config_cli_options():
    # Using the test configuration file in ./config dir of the base 
    # application we can test config options this way.  We are also using the 
    # example plugin for this test
    
    # First it is set by what is in the config file
    eq_(config['example']['foo'], 'some value')

    # Then overridden by cli_opts
    simulate([__file__, 'example', 'example-sub-command', '--foo=bar'])
    
    # now we validate that the config option was set by the cli_opt --foo
    eq_(config['example']['foo'], 'bar')
def test_default_cmd_with_filter():
    args = [
        __file__, 'version_tracker', 'default', '--filter=php', '--release=5'
    ]
    (out_dict, out_txt) = simulate(args)
    res = len(out_dict['packages']) > 1
    ok_(res)

    args = [
        __file__, 'version_tracker', 'default', '--filter=bogus_filter',
        '--release=5'
    ]
    (out_dict, out_txt) = simulate(args)
    res = len(out_dict['packages']) == 0
    ok_(res)
Пример #3
0
def test_genshi():
    orig = namespaces['root'].config['output_handler_override']
    namespaces['root'].config['output_handler_override'] = 'genshi'

    (res, out) = simulate([__file__, 'cmd1'])
    eq_(out, 'one two three ')
    namespaces['root'].config['output_handler_override'] = orig
Пример #4
0
def test_default_cmd_with_filter():
    args = [
        __file__, 'version_tracker', 'default', 
        '--filter=php',
        '--release=5']
    (out_dict, out_txt) = simulate(args)
    res = len(out_dict['packages']) > 1
    ok_(res)
    
    args = [
        __file__, 'version_tracker', 'default', 
        '--filter=bogus_filter',
        '--release=5']
    (out_dict, out_txt) = simulate(args)
    res = len(out_dict['packages']) == 0
    ok_(res)
Пример #5
0
def test_genshi():  
    orig = namespaces['root'].config['output_handler_override']
    namespaces['root'].config['output_handler_override'] = 'genshi'
    
    (res, out) = simulate([__file__, 'cmd1'])
    eq_(out, 'one two three ')
    namespaces['root'].config['output_handler_override'] = orig
Пример #6
0
def test_example_cmd_output():  
    # Simulate returns the result dictionary, and the render output when
    # running the controller command.  This can be used to validate that the
    # command ran successfully.
    (res_dict, output_txt) = simulate([__file__, 'example-command2'])

    # You can test that the rendered output is what we expected
    eq_(output_txt, 'Hello World\n')
    
    # You can test values in the result dictionary directly
    ok_(res_dict['foo'])
Пример #7
0
def test_json_output_handler():  
    # bit of a hack, but this is handled before the nose stuff... so, have to
    # redo it here to make it work
    orig = namespaces['root'].config['output_handler_override']
    namespaces['root'].config['output_handler_override'] = 'json'
    namespaces['root'].config['show_plugin_load'] = False
    
    (res, out_txt) = simulate([__file__, 'cmd1', '--json'])
    res_json = jsonpickle.decode(out_txt)
    eq_(res_json['items'][0], 'one')
    
    namespaces['root'].config['output_handler_override'] = orig
Пример #8
0
def exec_commands_ircbot_parsemsg_hook(config, log, irc, poll_result):
    """
    Parse the result of irc.poll() and execute commands if the msg was
    a command.
    
    """
    
    (from_nick, from_chan, msg, dest) = poll_result
    
    # its a command, 
    if not re.match('^\.[A-z]', msg):
        log.debug('msg did not start with a .command... skipping')
        return
    
    args = msg.split() 
    cmd = args.pop(0) # first part of msg is command, rest args
    if cmd in irc_commands.keys():            
        # need to keep arg order
        args.insert(0, irc_commands[cmd]['func'])
        if irc_commands[cmd]['namespace'] != 'root':
            args.insert(0, irc_commands[cmd]['namespace'])    
        args.insert(0, 'ius-tools')
    
        try:
            # FIX ME: this is a bit of a hack
            nam = namespaces[irc_commands[cmd]['namespace']]
            nam.controller.cli_opts = None
            nam.controller.cli_args = None
            namespaces[irc_commands[cmd]['namespace']] = nam
            (out_dict, out_txt) = simulate(args)
            reply = out_dict['irc_data']
        except IUSToolsArgumentError, e:
            reply = e.msg
            out_dict = {}
            
        # FIX ME: Need to consolidate all this .startswith('#') stuff
        
        # only send to user directly?
        if out_dict.has_key('irc_pm') and out_dict['irc_pm']:    
            if dest.startswith('#'):
                irc.send(from_chan, "%s: check your PM." % from_nick)
                irc.send(from_nick, "%s" % reply)
            else:
                irc.send(from_nick, "%s" % reply)
        else:
            if dest.startswith('#'):
                irc.send(dest, "%s: %s" % (from_nick, reply))
            else:
                irc.send(dest, "%s" % reply)
Пример #9
0
def exec_commands_ircbot_parsemsg_hook(config, log, irc, poll_result):
    """
    Parse the result of irc.poll() and execute commands if the msg was
    a command.
    
    """

    (from_nick, from_chan, msg, dest) = poll_result

    # its a command,
    if not re.match('^\.[A-z]', msg):
        log.debug('msg did not start with a .command... skipping')
        return

    args = msg.split()
    cmd = args.pop(0)  # first part of msg is command, rest args
    if cmd in irc_commands.keys():
        # need to keep arg order
        args.insert(0, irc_commands[cmd]['func'])
        if irc_commands[cmd]['namespace'] != 'root':
            args.insert(0, irc_commands[cmd]['namespace'])
        args.insert(0, 'ius-tools')

        try:
            # FIX ME: this is a bit of a hack
            nam = namespaces[irc_commands[cmd]['namespace']]
            nam.controller.cli_opts = None
            nam.controller.cli_args = None
            namespaces[irc_commands[cmd]['namespace']] = nam
            (out_dict, out_txt) = simulate(args)
            reply = out_dict['irc_data']
        except IUSToolsArgumentError, e:
            reply = e.msg
            out_dict = {}

        # FIX ME: Need to consolidate all this .startswith('#') stuff

        # only send to user directly?
        if out_dict.has_key('irc_pm') and out_dict['irc_pm']:
            if dest.startswith('#'):
                irc.send(from_chan, "%s: check your PM." % from_nick)
                irc.send(from_nick, "%s" % reply)
            else:
                irc.send(from_nick, "%s" % reply)
        else:
            if dest.startswith('#'):
                irc.send(dest, "%s: %s" % (from_nick, reply))
            else:
                irc.send(dest, "%s" % reply)
Пример #10
0
def test_default_cmd_with_package():
    args = [
        __file__, 'version_tracker', 'default', 
        '--package=php52',
        '--release=5']
    (out_dict, out_txt) = simulate(args)
    res = len(out_dict['packages']) == 1
    ok_(res)
    
    args = [
        __file__, 'version_tracker', 'default', 
        '--package=php52',
        '--release=4']
    (out_dict, out_txt) = simulate(args)
    res = len(out_dict['packages']) == 1
    ok_(res)
    
    args = [
        __file__, 'version_tracker', 'default', 
        '--package=bogus_package',
        '--release=5']
    (out_dict, out_txt) = simulate(args)
    res = len(out_dict['packages']) == 0
    ok_(res)
Пример #11
0
def test_default_cmd_with_package():
    args = [
        __file__, 'version_tracker', 'default', '--package=php52',
        '--release=5'
    ]
    (out_dict, out_txt) = simulate(args)
    res = len(out_dict['packages']) == 1
    ok_(res)

    args = [
        __file__, 'version_tracker', 'default', '--package=php52',
        '--release=4'
    ]
    (out_dict, out_txt) = simulate(args)
    res = len(out_dict['packages']) == 1
    ok_(res)

    args = [
        __file__, 'version_tracker', 'default', '--package=bogus_package',
        '--release=5'
    ]
    (out_dict, out_txt) = simulate(args)
    res = len(out_dict['packages']) == 0
    ok_(res)
Пример #12
0
def test_package_repo_index_error():  
    (res_dict, output_txt) = simulate([__file__, 'package-repo'])
Пример #13
0
def test_config_options_per_cli_opts():
    args = ['cement-test', 'nosetests', '--test-option=funions']
    simulate(args)
    eq_(config['test_option'], 'funions')
Пример #14
0
def test_bogus_output_handler():  
    simulate([__file__, 'bogus-cmd1'])
Пример #15
0
def test_default_cmd():      
    (res, out) = simulate([__file__, 'default'])
Пример #16
0
def test_log_to_console():  
    namespaces['root'].config['log_to_console'] = True
    (res, out) = simulate([__file__, 'cmd1'])
    namespaces['root'].config['log_to_console'] = False
Пример #17
0
def test_get_started():
    simulate([__file__, 'get-started'])
Пример #18
0
def test_changelog_index_error():  
    (res_dict, output_txt) = simulate([__file__, 'changelog'])
Пример #19
0
def test_bogus_cmd():  
    simulate([__file__, 'bogus-cmd-does-not-exist'])
Пример #20
0
def test_default_cmd():
    args = [
        __file__, 'version_tracker', 'default', 
        '--release=5']
    (out_dict, out_txt) = simulate(args)
Пример #21
0
def test_log_to_console():
    namespaces['root'].config['log_to_console'] = True
    (res, out) = simulate([__file__, 'cmd1'])
    namespaces['root'].config['log_to_console'] = False
Пример #22
0
def test_output_file():
    (res, out) = simulate([__file__, 'send-to-file'])
Пример #23
0
def test_root_cmd1_help():
    simulate([__file__, 'cmd1-help', '--debug'])
Пример #24
0
def test_bug_index_error():  
    (res_dict, output_txt) = simulate([__file__, 'bug'])
Пример #25
0
def test_changelog():  
    (res_dict, output_txt) = simulate([__file__, 'changelog', 'php52'])

    res = '%changelog' in res_dict['changelog']
    ok_(res)
Пример #26
0
def test_spec_index_error():  
    (res_dict, output_txt) = simulate([__file__, 'spec'])
Пример #27
0
def test_default_namespace_cmd():      
    (res, out) = simulate([__file__, 'example'])
Пример #28
0
def test_bug():  
    (res_dict, output_txt) = simulate([__file__, 'bug', '731697'])
    eq_(res_dict['irc_data'], 
        'LP#731697 - php53 for ius-6 - https://bugs.launchpad.net/bugs/731697')
Пример #29
0
def test_default_cmd():
    args = [__file__, 'version_tracker', 'default', '--release=5']
    (out_dict, out_txt) = simulate(args)
Пример #30
0
def test_spec():  
    (res_dict, output_txt) = simulate([__file__, 'spec', 'ius-release'])

    res = 'ius-release' in res_dict['spec']
    ok_(res)
            
Пример #31
0
def test_testing_age():  
    (res_dict, output_txt) = simulate([__file__, 'testing-age'])

    res = len(res_dict['packages']) > 0
    ok_(res)
Пример #32
0
def test_output_file():  
    (res, out) = simulate([__file__, 'send-to-file'])
Пример #33
0
def test_root_command_that_does_not_exist():  
    (res, out_txt) = simulate([__file__, 'non_existent'])
Пример #34
0
def test_config_options_per_cli_opts():  
    args = ['cement-test', 'nosetests', '--test-option=funions']
    simulate(args)
    eq_(config['test_option'], 'funions')
Пример #35
0
def test_example_namespace():  
    (res, out_txt) = simulate([__file__, 'example', 'cmd1'])
Пример #36
0
def test_default_cmd():
    # The default action is to raise an application error if an unknown 
    # command is called.  This is how we test that the exception is raised.
    simulate([__file__, 'default'])
Пример #37
0
def test_example_namespace():  
    (res, out_txt) = simulate([__file__, 'example', 'cmd1'])
    

        
Пример #38
0
def test_package_repo():  
    (res_dict, output_txt) = simulate([__file__, 'package-repo', 'php52'])
    eq_(res_dict['irc_data'], 
        'https://code.launchpad.net/~ius-coredev/ius/php52')
Пример #39
0
def test_example4_cmd1():
    simulate([__file__, 'example4', 'cmd1'])