"""
Contains tests for the timer metric.
"""

from statsite.metrics import Timer

class TestTimerMetric(object):
    def test_fold_sum(self):
        """
        Tests that folding generates a sum of the timers.
        """
        now = 10
        metrics = [Timer("k", 10),
                   Timer("k", 15),
                   Timer("j", 7),
                   Timer("j", 8)]
        result = Timer.fold(metrics, now)

        assert ("k", 25, now) == self._get_metric("timers.k.sum", result)
        assert ("j", 15, now) == self._get_metric("timers.j.sum", result)

    def _get_metric(self, key, metrics):
        """
        This will extract a specific metric out of an array of metrics.
        """
        for metric in metrics:
            if metric[0] == key:
                return metric

        return None

@@ -432,17 +432,28 @@
 ssert (%22
-k
+timers.k.sum
 %22, 25, n
@@ -517,17 +517,28 @@
 ssert (%22
-j
+timers.j.sum
 %22, 15, n

Fix typo with expected metric