示例#1
0
def test_ended_txn_name(api_version, tastypie_full_debug):
    # if the transaction has ended, do not change the transaction name
    end_of_transaction()

    with TastyPieFullDebugMode(tastypie_full_debug) as debug_status:
        test_application.get('/api/%s/simple/NotFound/' % api_version,
                             status=debug_status)
def test_trace_after_end_of_transaction(caplog):
    end_of_transaction()
    with FunctionTrace("foobar"):
        pass

    error_messages = [
        record for record in caplog.records if record.levelno >= logging.ERROR
    ]
    assert not error_messages
示例#3
0
def test_celery_tasks_end_transaction():
    """
    Only functions that run before the call to end_of_transaction() are
    included in the transaction.

    """
    add_result = add(1, 2)
    assert add_result == 3

    end_of_transaction()

    tsum_result = tsum([1, 2, 3])
    assert tsum_result == 6
示例#4
0
def test_blocking_connection_basic_consume_stopped_txn(producer, as_partial):
    def on_message(channel, method_frame, header_frame, body):
        assert hasattr(method_frame, '_nr_start_time')
        assert body == BODY
        channel.stop_consuming()

    end_of_transaction()

    if as_partial:
        on_message = functools.partial(on_message)

    with pika.BlockingConnection(
            pika.ConnectionParameters(DB_SETTINGS['host'])) as connection:
        channel = connection.channel()
        basic_consume(channel, QUEUE, on_message)
        try:
            channel.start_consuming()
        except:
            channel.stop_consuming()
            raise