Example #1
0
def test_main(c):
    '''loadconfig main unittest'''
    host = 'leon'
    conf_option = '-E="{}"'.format(c.conf)
    with capture_stream() as stdout:
        main([c.prog, conf_option, host])
    exp = d('''\
        export ARGS=""
        export DOCKER__IMAGE="reg.gdl/debian"
        export HOST="leon"
        export PROG="test_loadconfig.py"
        export SYSTEM_PATH="/data/salt/system"
        export VERSION="0.1.7"''')
    ret = '\n'.join(sorted(stdout.getvalue()[:-1].split('\n')))
    assert exp == ret
def test_gevent():
    '''simple gevent test'''
    def first():
        print('1')
        sleep(0)
        print('3')

    def second():
        print('2')
        sleep(0)
        print('4')

    with capture_stream() as stdout:
        joinall([spawn(first), spawn(second)])
    assert ('1\n2\n3\n4\n' == stdout.getvalue())
Example #3
0
def test_main(c):
    '''loadconfig main unittest'''
    host = 'leon'
    conf_option = '-E="{}"'.format(c.conf)
    with capture_stream() as stdout:
        main([c.prog, conf_option, host])
    exp = d('''\
        export ARGS=""
        export DOCKER__IMAGE="reg.gdl/debian"
        export HOST="leon"
        export PROG="test_loadconfig.py"
        export SYSTEM_PATH="/data/salt/system"
        export VERSION="0.1.7"''')
    ret = '\n'.join(sorted(stdout.getvalue()[:-1].split('\n')))
    assert exp == ret