22from django .test import TestCase
33from redis import RedisError
44
5- from django_prometheus .testutils import PrometheusTestCaseMixin , get_metric
5+ from django_prometheus .testutils import assert_metric_equal , get_metric
66
77
8- class TestCachesMetrics (PrometheusTestCaseMixin , TestCase ):
8+ class TestCachesMetrics (TestCase ):
99 """Test django_prometheus.caches metrics."""
1010
1111 def test_counters (self ):
@@ -35,9 +35,9 @@ def test_counters(self):
3535
3636 assert result == "default"
3737
38- self . assertMetricEquals (total_before + 4 , "django_cache_get_total" , backend = backend )
39- self . assertMetricEquals (hit_before + 2 , "django_cache_get_hits_total" , backend = backend )
40- self . assertMetricEquals (
38+ assert_metric_equal (total_before + 4 , "django_cache_get_total" , backend = backend )
39+ assert_metric_equal (hit_before + 2 , "django_cache_get_hits_total" , backend = backend )
40+ assert_metric_equal (
4141 miss_before + 2 ,
4242 "django_cache_get_misses_total" ,
4343 backend = backend ,
@@ -55,19 +55,19 @@ def test_redis_cache_fail(self):
5555 tested_cache = caches ["stopped_redis_ignore_exception" ]
5656 tested_cache .get ("foo1" )
5757
58- self . assertMetricEquals (hit_before , "django_cache_get_hits_total" , backend = supported_cache )
59- self . assertMetricEquals (miss_before , "django_cache_get_misses_total" , backend = supported_cache )
60- self . assertMetricEquals (total_before + 1 , "django_cache_get_total" , backend = supported_cache )
61- self . assertMetricEquals (fail_before + 1 , "django_cache_get_fail_total" , backend = supported_cache )
58+ assert_metric_equal (hit_before , "django_cache_get_hits_total" , backend = supported_cache )
59+ assert_metric_equal (miss_before , "django_cache_get_misses_total" , backend = supported_cache )
60+ assert_metric_equal (total_before + 1 , "django_cache_get_total" , backend = supported_cache )
61+ assert_metric_equal (fail_before + 1 , "django_cache_get_fail_total" , backend = supported_cache )
6262
6363 tested_cache = caches ["stopped_redis" ]
6464 with self .assertRaises (RedisError ):
6565 tested_cache .get ("foo1" )
6666
67- self . assertMetricEquals (hit_before , "django_cache_get_hits_total" , backend = supported_cache )
68- self . assertMetricEquals (miss_before , "django_cache_get_misses_total" , backend = supported_cache )
69- self . assertMetricEquals (total_before + 2 , "django_cache_get_total" , backend = supported_cache )
70- self . assertMetricEquals (fail_before + 2 , "django_cache_get_fail_total" , backend = supported_cache )
67+ assert_metric_equal (hit_before , "django_cache_get_hits_total" , backend = supported_cache )
68+ assert_metric_equal (miss_before , "django_cache_get_misses_total" , backend = supported_cache )
69+ assert_metric_equal (total_before + 2 , "django_cache_get_total" , backend = supported_cache )
70+ assert_metric_equal (fail_before + 2 , "django_cache_get_fail_total" , backend = supported_cache )
7171
7272 def test_cache_version_support (self ):
7373 supported_caches = [
0 commit comments