def test_metric(self):

        slug = 'test-metric'
        n = 1

        # get the keys used for the metric, so we can check for the appropriate
        # calls
        keys = self.r._build_keys(slug)
        second, minute, hour, day, week, month, year = keys
        self.r.metric(slug, num=n)

        # Verify that setting a metric adds the appropriate slugs to the keys
        # set and then incrememts each key
        self.redis.assert_has_calls([
            call.sadd(self.r._metric_slugs_key, slug),
            call.pipeline(),
            call.pipeline().incr(second, n),
            call.pipeline().incr(minute, n),
            call.pipeline().incr(hour, n),
            call.pipeline().incr(day, n),
            call.pipeline().incr(week, n),
            call.pipeline().incr(month, n),
            call.pipeline().incr(year, n),
        ])

        # Expiration should not have gotten called
        self.assertFalse(self.redis.expire.called)
Test setting metrics using ``R.metric``.
dataset/ETHPy150Open bradmontgomery/django-redis-metrics/redis_metrics/tests/test_models.py/TestR.test_metric