How to use sap - 10 common examples

To help you get started, we’ve selected a few sap examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SAP / cf-python-logging-support / tests / unit / test_init.py View on Github external
def test_init_called_twice(mocker):
    """ test cf_logging.init can be called only once """
    framework = mocker.Mock(Framework)
    cf_logging._SETUP_DONE = False
    cf_logging.init(framework, level=logging.DEBUG)
    cf_logging.init(framework, level=logging.DEBUG)
github SAP / cf-python-logging-support / tests / test_sanic_logging.py View on Github external
def _set_up_sanic_logging(app, level=logging.DEBUG):
    cf_logging._SETUP_DONE = False
    sanic_logging.init(app, level)
github SAP / cf-python-logging-support / tests / test_job_logging.py View on Github external
def test_log_in_expected_format(log_callback):
    """ Test the cf_logger as a standalone """
    cf_logging.init(level=logging.DEBUG)
    logger, stream = config_logger('cli.test')
    log_callback(logger, 'hi')
    log_json = JSONDecoder().decode(stream.getvalue())
    _, error = JsonValidator(JOB_LOG_SCHEMA).validate(log_json)

    assert error == {}
github SAP / cf-python-logging-support / tests / unit / test_init.py View on Github external
def test_init_called_twice(mocker):
    """ test cf_logging.init can be called only once """
    framework = mocker.Mock(Framework)
    cf_logging._SETUP_DONE = False
    cf_logging.init(framework, level=logging.DEBUG)
    cf_logging.init(framework, level=logging.DEBUG)
github SAP / cf-python-logging-support / tests / test_falcon_logging.py View on Github external
def _set_up_falcon_logging(app, *args):
    cf_logging._SETUP_DONE = False
    falcon_logging.init(app, logging.DEBUG, *args)
github SAP / cf-python-logging-support / tests / test_job_logging.py View on Github external
def test_thread_safety():
    """ test context keeps separate correlation ID per thread """
    class _SampleThread(threading.Thread):
        def __init__(self):
            super(_SampleThread, self).__init__()
            self.correlation_id = str(uuid.uuid1())
            self.read_correlation_id = ''

        def run(self):
            cf_logging.FRAMEWORK.context.set_correlation_id(self.correlation_id)
            time.sleep(0.1)
            self.read_correlation_id = cf_logging.FRAMEWORK.context.get_correlation_id()

    cf_logging.init(level=logging.DEBUG)

    thread_one = _SampleThread()
    thread_two = _SampleThread()

    thread_one.start()
    thread_two.start()

    thread_one.join()
    thread_two.join()

    assert thread_one.correlation_id == thread_one.read_correlation_id
    assert thread_two.correlation_id == thread_two.read_correlation_id
github SAP / cf-python-logging-support / tests / unit / test_init.py View on Github external
def test_init_called_twice(mocker):
    """ test cf_logging.init can be called only once """
    framework = mocker.Mock(Framework)
    cf_logging._SETUP_DONE = False
    cf_logging.init(framework, level=logging.DEBUG)
    cf_logging.init(framework, level=logging.DEBUG)
github SAP / cf-python-logging-support / tests / unit / test_init.py View on Github external
def test_init_incorrect_framework():
    """ test cf_logging.init fails for invalid framework """
    cf_logging._SETUP_DONE = False
    cf_logging.init({})
github SAP / cf-python-logging-support / tests / test_job_logging.py View on Github external
def test_set_correlation_id():
    """ Test setting correlation_id """
    correlation_id = '1234'
    cf_logging.init(level=logging.DEBUG)
    cf_logging.FRAMEWORK.context.set_correlation_id(correlation_id)

    logger, stream = config_logger('cli.test')
    logger.info('hi')

    log_json = JSONDecoder().decode(stream.getvalue())
    _, error = JsonValidator(JOB_LOG_SCHEMA).validate(log_json)

    assert error == {}
    assert log_json['correlation_id'] == correlation_id
    assert cf_logging.FRAMEWORK.context.get_correlation_id() == correlation_id
github SAP / cf-python-logging-support / tests / unit / core / test_framework.py View on Github external
def test_init(initializers):
    """ test constructor with invalid context, request_reader and response_reader """
    Framework('django', **initializers)