wiremock.resources.requests.resource.Requests.get_matching_requests

Here are the examples of the python api wiremock.resources.requests.resource.Requests.get_matching_requests taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

3 Source : test_integration_metric.py
with Apache License 2.0
from dynatrace-oss

async def test_metric_authorization_header():
    await async_dynatrace_gcp_extension()

    request = NearMissMatchPatternRequest(url_path_pattern="/api/v2/metrics/ingest",
                                          method="POST")

    matched_request: RequestResponseFindResponse = Requests.get_matching_requests(request)

    assert_that(matched_request.requests).is_not_empty()

    result: RequestResponseRequest = matched_request.requests[0]

    assert_that(result.headers['Authorization']).is_equal_to(f"Api-Token {AUTHORIZATION_KEY}")


@pytest.mark.asyncio

0 Source : test_integration_metric.py
with Apache License 2.0
from dynatrace-oss

async def ingest_lines_output(expected_ingest_output_file):
    await async_dynatrace_gcp_extension()
    reqeusts_gcp_timeseries_pattern = NearMissMatchPatternRequest(url_path_pattern="/v3/projects/dynatrace-gcp-extension/timeSeries?([\d\w\W]*)",
                                          method="GET")
    reqeusts_gcp_timeseries: RequestResponseFindResponse = Requests.get_matching_requests(reqeusts_gcp_timeseries_pattern)
    gce_instance_filter="resource.labels.instance_name%3Dstarts_with(%22test%22)"
    requests_with_filter = [reqeust_gcp_timeseries for reqeust_gcp_timeseries in reqeusts_gcp_timeseries.requests
                            if gce_instance_filter in reqeust_gcp_timeseries.url]
    assert_that(requests_with_filter).is_length(3)

    sent_requests = Requests.get_all_received_requests().get_json_data().get('requests')
    urls = {sent_request["request"]["url"] for sent_request in sent_requests}
    apigee_url_prefix = "/v3/projects/dynatrace-gcp-extension/timeSeries?filter=metric.type+%3D+%22apigee.googleapis.com/environment/anomaly_count"
    request_for_apigee_metric_was_sent = any(url.startswith(apigee_url_prefix) for url in urls)
    assert not request_for_apigee_metric_was_sent

    request_metrics_ingest_pattern = NearMissMatchPatternRequest(url_path_pattern="/api/v2/metrics/ingest", method="POST")
    request_metrics_ingest: RequestResponseFindResponse = Requests.get_matching_requests(request_metrics_ingest_pattern)
    assert_that(request_metrics_ingest.requests).is_not_empty()
    result: RequestResponseRequest = request_metrics_ingest.requests[0]

    body = result.body

    with open(expected_ingest_output_file) as ingest:
        expected_ingest_lines = ingest.read().split("\n")
        actual_ingest_lines = body.split("\n")

        assert_that(actual_ingest_lines).is_length(len(expected_ingest_lines))
        assert_that(actual_ingest_lines).contains_only(*expected_ingest_lines)