def check_static_metrics(expected_metrics, error_message=""):
    """Create a callable to verify that the static provider response contains
    the expected values.

    To be used with the :meth:`run` function. The callable will raise an
    :class:`AssertionError` if the static metrics in the response are different
    from the given ones.

    Args:
        expected_metrics (dict[str, float]): Dictionary with the metrics names as
            keys and metric values as values.
        error_message (str): the message that will be displayed if the
            check fails.

    Returns:
        callable: a condition that will check its given response against
            the parameters of the current function.

    """
    if not error_message:
        error_message = (
            f"The static provider did not provide the expected "
            f"metrics. Expected metrics: {expected_metrics}"
        )

    def validate(response):
        try:
            observed_metrics = response.json["spec"]["static"]["metrics"]
            msg = error_message + f" Provided metrics: {observed_metrics}"
            for m, val in expected_metrics.items():
                assert val == observed_metrics.get(m), msg
        except Exception as e:
            raise AssertionError(error_message + f"Error: {e}")

    return validate