Esempio n. 1
0
def test_batch_command_from_tracked_request_with_tag():
    tracked_request = TrackedRequest()
    tracked_request.tag("test_key", "test_value")
    tracked_request.finish()
    make_tracked_request_instance_deterministic(tracked_request)
    command = commands.BatchCommand.from_tracked_request(tracked_request)
    assert command.message() == {
        "BatchCommand": {
            "commands": [
                {
                    "StartRequest": {
                        "request_id": REQUEST_ID,
                        "timestamp": START_TIME_STR,
                    }
                },
                {
                    "TagRequest": {
                        "request_id": REQUEST_ID,
                        "timestamp": START_TIME_STR,
                        "tag": "test_key",
                        "value": "test_value",
                    }
                },
                {
                    "FinishRequest": {
                        "request_id": REQUEST_ID,
                        "timestamp": END_TIME_STR,
                    }
                },
            ]
        }
    }
Esempio n. 2
0
def test_batch_command_from_tracked_request():
    tr = TrackedRequest()
    tr.finish()
    make_tracked_request_instance_deterministic(tr)
    command = commands.BatchCommand.from_tracked_request(tr)
    assert command.message() == {
        "BatchCommand": {
            "commands": [
                {
                    "StartRequest": {
                        "request_id": REQUEST_ID,
                        "timestamp": START_TIME_STR,
                    }
                },
                {
                    "FinishRequest": {
                        "request_id": REQUEST_ID,
                        "timestamp": END_TIME_STR,
                    }
                },
            ]
        }
    }
Esempio n. 3
0
def tr():
    request = TrackedRequest()
    try:
        yield request
    finally:
        request.finish()