Пример #1
0
def test_check_app_config(app, client):
    cleantest(app, client)

    # In conftest.py: ENABLE_LOGPARSER=False
    assert not os.path.exists(app.config['STATS_JSON_PATH'])
    check_app_config(app.config)
    strings = []

    assert app.config['LOGPARSER_PID'] is None
    strings.append('logparser_pid: None')

    poll_pid = app.config['POLL_PID']
    if app.config.get('ENABLE_EMAIL', False):
        assert isinstance(poll_pid, int) and poll_pid > 0
    else:
        assert poll_pid is None
    strings.append('poll_pid: %s' % poll_pid)

    req(app, client, view='settings', kws=dict(node=1), ins=strings)
    assert not os.path.exists(app.config['STATS_JSON_PATH'])

    # Test ENABLE_EMAIL = False
    if app.config.get('ENABLE_EMAIL', False):
        app.config['ENABLE_EMAIL'] = False
        check_app_config(app.config)
        assert app.config['LOGPARSER_PID'] is None
        assert app.config['POLL_PID'] is None
        req(app,
            client,
            view='settings',
            kws=dict(node=1),
            ins='poll_pid: None')
Пример #2
0
def test_check_app_config(app, client):
    cleantest(app, client)

    # In conftest.py: ENABLE_LOGPARSER=False
    assert not os.path.exists(app.config['STATS_JSON_PATH'])

    # ['username:[email protected]:6800', ]
    app.config['SCRAPYD_SERVERS'] = app.config['_SCRAPYD_SERVERS']
    check_app_config(app.config)

    strings = []

    assert app.config['LOGPARSER_PID'] is None
    strings.append('logparser_pid: None')

    poll_pid = app.config['POLL_PID']
    if app.config.get('ENABLE_MONITOR', False):
        assert isinstance(poll_pid, int) and poll_pid > 0
    else:
        assert poll_pid is None
    strings.append('poll_pid: %s' % poll_pid)

    req(app, client, view='settings', kws=dict(node=1), ins=strings)
    assert not os.path.exists(app.config['STATS_JSON_PATH'])

    # Test ENABLE_MONITOR = False
    if app.config.get('ENABLE_MONITOR', False):
        app.config['ENABLE_MONITOR'] = False

        # ['username:[email protected]:6800', ]
        app.config['SCRAPYD_SERVERS'] = app.config['_SCRAPYD_SERVERS']
        check_app_config(app.config)

        assert app.config['LOGPARSER_PID'] is None
        assert app.config['POLL_PID'] is None
        req(app,
            client,
            view='settings',
            kws=dict(node=1),
            ins='poll_pid: None')