예제 #1
0
def setup_lp_cli():

    """
    Perform setup of LinchpinContext, lpc.load_config, and LinchPinAPI
    """

    global lpctx
    global lpc

    global target
    global pinfile

    base_path = '{0}'.format(os.path.dirname(
        os.path.realpath(__file__))).rstrip('/')
    lib_path = os.path.realpath(os.path.join(base_path, os.pardir))

    setup_load_config()

    pinfile = 'PinFile'
    mock_path = '{0}/{1}/{2}'.format(lib_path, 'mockdata', provider)

    lpctx = LinchpinCliContext()
    lpctx.load_config(lpconfig=config_path)
    lpctx.load_global_evars()
    lpctx.setup_logging()
    lpctx.workspace = os.path.realpath(mock_path)

    lpc = LinchpinCli(lpctx)
예제 #2
0
def setup_lp_api():
    """
    Perform setup of LinchpinContext, lpc.load_config, and LinchPinAPI
    """

    global lpc
    global lpa

    global target
    global pinfile

    base_path = '{0}'.format(os.path.dirname(
        os.path.realpath(__file__))).rstrip('/')
    lib_path = os.path.realpath(os.path.join(base_path, os.pardir))

    setup_load_config()

    pinfile = 'PinFile'
    mock_path = '{0}/{1}/{2}'.format(lib_path, 'mockdata', provider)

    lpc = LinchpinCliContext()
    lpc.load_config(lpconfig=config_path)
    lpc.load_global_evars()
    lpc.setup_logging()
    lpc.workspace = os.path.realpath(mock_path)

    lpa = LinchpinAPI(lpc)
예제 #3
0
def setup_lp_cli():
    """
    Perform setup of LinchpinContext, lpc.load_config, and LinchPinAPI
    """

    global lpctx
    global lpc

    global target
    global pinfile

    base_path = '{0}'.format(os.path.dirname(
        os.path.realpath(__file__))).rstrip('/')
    lib_path = os.path.realpath(os.path.join(base_path, os.pardir))

    setup_load_config()

    pinfile = 'PinFile'
    mock_path = '{0}/{1}/{2}'.format(lib_path, 'mockdata', provider)

    lpctx = LinchpinCliContext()
    lpctx.load_config(lpconfig=config_path)
    lpctx.load_global_evars()
    lpctx.setup_logging()
    lpctx.workspace = os.path.realpath(mock_path)
    lpctx.pinfile = pinfile
    lpctx.pf_data = None
    lpctx.no_monitor = True
    lpctx.set_evar("no_monitor", True)
    lpctx.set_cfg("progress_bar", "no_progress", str(True))

    lpc = LinchpinCli(lpctx)
    lpc.disable_pbar = True
예제 #4
0
def test_logging_setup():

    lpc = LinchpinCliContext()
    lpc.load_config(config_path)
    lpc.setup_logging()

    assert os.path.isfile(logfile)
예제 #5
0
def setup_lp_fetch_env():
    global lpc
    global lpcli

    global target
    global pinfile
    global mockpath

    base_path = '{0}'.format(os.path.dirname(
        os.path.realpath(__file__))).rstrip('/')
    lib_path = os.path.realpath(os.path.join(base_path, os.pardir))

    setup_load_config()

    pinfile = 'PinFile'
    mock_path = '{0}/{1}/{2}'.format(lib_path, 'mockdata', provider)

    lpc = LinchpinCliContext()
    lpc.load_config(lpconfig=config_path)
    lpc.load_global_evars()
    lpc.setup_logging()
    lpc.workspace = '/tmp/workspace/'
    mockpath = os.path.realpath(mock_path)

    if not os.path.exists(lpc.workspace):
        os.mkdir(lpc.workspace)

    lpcli = LinchpinCli(lpc)
예제 #6
0
def test_logging_setup():

    lpc = LinchpinCliContext()
    lpc.load_config(lpconfig=config_path)
    lpc.set_cfg('logger', 'file', config_data['logger']['file'])
    lpc.setup_logging()

    assert os.path.isfile(logfile)
예제 #7
0
def test_logging_setup():

    lpc = LinchpinCliContext()
    lpc.load_config(lpconfig=config_path)
    lpc.set_cfg('logger',
                'file',
                config_data['logger']['file'])
    lpc.setup_logging()

    assert os.path.isfile(logfile)
예제 #8
0
def test_log_info():

    lvl=logging.INFO
    msg = 'Info Msg'
    regex = '^{0}.*{1}'.format(logging.getLevelName(lvl), msg)

    lpc = LinchpinCliContext()
    lpc.load_config(config_path)
    lpc.setup_logging()
    lpc.log_info(msg)

    with open(logfile) as f:
        line = f.readline()

    assert_regexp_matches(line, regex)
예제 #9
0
def test_log_state():

    lvl=logging.DEBUG
    msg = '{0}: State Msg'.format(logging.getLevelName(lvl))
    regex = '^{0}.*STATE - {1}'.format(logging.getLevelName(lvl), msg)

    lpc = LinchpinCliContext()
    lpc.load_config(config_path)
    lpc.setup_logging()
    lpc.log_state(msg)

    with open(logfile) as f:
        line = f.readline()

    assert_regexp_matches(line, regex)
예제 #10
0
def test_log_debug():

    lvl = logging.DEBUG
    msg = 'Debug Msg'
    regex = '^{0}.*{1}'.format(logging.getLevelName(lvl), msg)

    lpc = LinchpinCliContext()
    lpc.load_config(lpconfig=config_path)
    lpc.set_cfg('logger', 'file', config_data['logger']['file'])
    lpc.setup_logging()
    lpc.log_debug(msg)

    with open(logfile) as f:
        line = f.readline()

    assertRegex(line, regex)
예제 #11
0
def test_log_msg():

    # This test assumes the default message format found around line 139
    # of linchpin/cli/context.py

    lvl=logging.DEBUG
    msg = 'Test Msg'
    regex = '^{0}.*{1}'.format(logging.getLevelName(lvl), msg)

    lpc = LinchpinCliContext()
    lpc.load_config(config_path)
    lpc.setup_logging()
    lpc.log(msg, level=lvl)

    with open(logfile) as f:
        line = f.readline()

    assert_regexp_matches(line, regex)
예제 #12
0
def test_log_debug():

    lvl=logging.DEBUG
    msg = 'Debug Msg'
    regex = '^{0}.*{1}'.format(logging.getLevelName(lvl), msg)

    lpc = LinchpinCliContext()
    lpc.load_config(lpconfig=config_path)
    lpc.set_cfg('logger',
                'file',
                config_data['logger']['file'])
    lpc.setup_logging()
    lpc.log_debug(msg)

    with open(logfile) as f:
        line = f.readline()

    assert_regexp_matches(line, regex)
예제 #13
0
def test_log_msg():

    # This test assumes the default message format found around line 139
    # of linchpin/cli/context.py

    lvl=logging.DEBUG
    msg = 'Test Msg'
    regex = '^{0}.*{1}'.format(logging.getLevelName(lvl), msg)

    lpc = LinchpinCliContext()
    lpc.load_config(lpconfig=config_path)
    lpc.set_cfg('logger',
                'file',
                config_data['logger']['file'])
    lpc.setup_logging()
    lpc.log(msg, level=lvl)

    with open(logfile) as f:
        line = f.readline()

    assert_regexp_matches(line, regex)
예제 #14
0
def setup_lp_fetch_env():
    global lpc
    global lpcli

    global target
    global pinfile
    global mockpath

    base_path = '{0}'.format(os.path.dirname(
        os.path.realpath(__file__))).rstrip('/')
    lib_path = os.path.realpath(os.path.join(base_path, os.pardir))

    setup_load_config()

    lpc = LinchpinCliContext()
    lpc.load_config(lpconfig=config_path)
    lpc.load_global_evars()
    lpc.setup_logging()

    lpc.workspace = tempfile.mkdtemp(prefix='fetch_')
    print('workspace: {0}'.format(lpc.workspace))

    lpcli = LinchpinCli(lpc)
예제 #15
0
def setup_lp_fetch_env():
    global lpc
    global lpcli

    global target
    global pinfile
    global mockpath

    base_path = '{0}'.format(os.path.dirname(
        os.path.realpath(__file__))).rstrip('/')
    lib_path = os.path.realpath(os.path.join(base_path, os.pardir))

    setup_load_config()

    lpc = LinchpinCliContext()
    lpc.load_config(lpconfig=config_path)
    lpc.load_global_evars()
    lpc.setup_logging()

    lpc.workspace = tempfile.mkdtemp(prefix='fetch_')
    print(('workspace: {0}'.format(lpc.workspace)))

    lpcli = LinchpinCli(lpc)