(self, metric_name, tag, count=None, at_least=1)
Assert a metric is tagged with tag
Assert a metric is tagged with tag
Assert a metric is tagged with tag
def assert_metric_has_tag(self, metric_name, tag, count=None, at_least=1):
        """
        Assert a metric is tagged with tag
        """
        self._asserted.add(metric_name)

        candidates = []
        candidates_with_tag = []
        for metric in self.metrics(metric_name):
            candidates.append(metric)
            if tag in metric.tags:
                candidates_with_tag.append(metric)

        if candidates_with_tag:  # The metric was found with the tag but not enough times
            msg = "The metric '{}' with tag '{}' was only found {}/{} times".format(metric_name, tag, count, at_least)
        elif candidates:
            msg = (
                "The metric '{}' was found but not with the tag '{}'.\n"
                + "Similar submitted:\n"
                + "\n".join(["     {}".format(m) for m in candidates])
            )
        else:
            msg = "Metric '{}' not found".format(metric_name)

        if count is not None:
            assert len(candidates_with_tag) == count, msg
        else:
            assert len(candidates_with_tag) >= at_least, msg
def assert_metric_has_tag ( self , metric_name , tag , count = None , at_least = 1 ) : self . _asserted . add ( metric_name ) candidates = [ ] candidates_with_tag = [ ] for metric in self . metrics ( metric_name ) : candidates . append ( metric ) if tag in metric . tags : candidates_with_tag . append ( metric ) if candidates_with_tag : # The metric was found with the tag but not enough times msg = "The metric '{}' with tag '{}' was only found {}/{} times" . format ( metric_name , tag , count , at_least ) elif candidates : msg = ( "The metric '{}' was found but not with the tag '{}'.\n" + "Similar submitted:\n" + "\n" . join ( [ "     {}" . format ( m ) for m in candidates ] ) ) else : msg = "Metric '{}' not found" . format ( metric_name ) if count is not None : assert len ( candidates_with_tag ) == count , msg else : assert len ( candidates_with_tag ) >= at_least , msg