Esempio n. 1
0
def test_logging_basics(assert_lines):

    logging = Section().logging

    assert_lines([
        'disable-logging = true',
        'log-format = %(method) --> %(uri) %(metric.my) %(var.X_REQUEST_ID)',
        'log-date = true',
    ],
                 logging.set_basic_params(
                     no_requests=True,
                     template='%s --> %s %s %s' % (
                         logging.vars.REQ_METHOD,
                         logging.vars.REQ_URI,
                         logging.vars.metric('my'),
                         logging.vars.request_var('X-Request-Id'),
                     ),
                     prefix_date=True))

    assert_lines([
        'logformat-strftime = true',
        'log-date = %%Y-%%M-%%D',
    ],
                 Section().logging.set_basic_params(
                     prefix_date='%Y-%M-%D',
                     apply_strftime=True,
                 ))

    assert_lines([
        'log-reopen = true',
    ],
                 Section().logging.set_file_params(reopen_on_reload=True))

    assert_lines([
        'logto2 = /a/b.log',
    ],
                 Section().logging.log_into('/a/b.log',
                                            before_priv_drop=False))

    assert_lines([
        'log-master = true',
        'log-master-req-stream = true',
    ],
                 Section().logging.set_master_logging_params(
                     enable=True, sock_stream_requests_only=True))

    assert_lines([
        'loggers-list = true',
    ],
                 Section().logging.print_loggers())

    assert_lines([
        'log-route = socket aline',
    ],
                 Section().logging.add_logger_route('socket', 'aline'))
Esempio n. 2
0
def test_section_basics(assert_lines):

    assert_lines('set-placeholder = one=two',
                 Section().set_placeholder('one', 'two'))

    my_section = Section()

    assert_lines('automatically generated', my_section, stamp=True)

    my_section.set_basic_params(strict_config=True)

    assert_lines([
        'uwsgi',
        'strict',
    ], my_section)

    # unset bool
    my_section.set_basic_params(strict_config=False)
    assert_lines([
        'strict',
    ], my_section, assert_in=False)

    # successive unset bool
    my_section.set_basic_params(strict_config=False)

    assert_lines('plugins-list = true', Section().print_plugins())

    # __call__ -> set_basic_params
    assert_lines('workers = 10', Section().workers(count=10))

    # bogus basic params handling. test for no error
    Section(
        params_networking=None,
        params_nonexistent={'a': 'b'},
        dummy_key=1,
    )