Skip to content

Commit 75d22b3

Browse files
committed
Remove outdated tests for overwrite/skip cache and Prometheus exporter fallback
1 parent 3070f4f commit 75d22b3

File tree

2 files changed

+3
-84
lines changed

2 files changed

+3
-84
lines changed

tests/sql_tests/test_sql_core.py

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ def f(x, y):
6262

6363
@pytest.mark.sql
6464
def test_sql_core_keywords():
65+
"""Keyword arguments produce a cache hit the same as positional arguments."""
66+
6567
@cachier(backend="sql", sql_engine=SQL_CONN_STR)
6668
def f(x, y):
6769
return random() + x + y
@@ -70,14 +72,7 @@ def f(x, y):
7072
v1 = f(1, y=2)
7173
v2 = f(1, y=2)
7274
assert v1 == v2
73-
v3 = f(1, y=2, cachier__skip_cache=True)
74-
assert v3 != v1
75-
v4 = f(1, y=2)
76-
assert v4 == v1
77-
v5 = f(1, y=2, cachier__overwrite_cache=True)
78-
assert v5 != v1
79-
v6 = f(1, y=2)
80-
assert v6 == v5
75+
f.clear_cache()
8176

8277

8378
@pytest.mark.sql
@@ -100,24 +95,6 @@ def f(x, y):
10095
assert v3 != v1
10196

10297

103-
@pytest.mark.sql
104-
def test_sql_overwrite_and_skip_cache():
105-
@cachier(backend="sql", sql_engine=SQL_CONN_STR)
106-
def f(x):
107-
return random() + x
108-
109-
f.clear_cache()
110-
v1 = f(1)
111-
v2 = f(1)
112-
assert v1 == v2
113-
v3 = f(1, cachier__skip_cache=True)
114-
assert v3 != v1
115-
v4 = f(1, cachier__overwrite_cache=True)
116-
assert v4 != v1
117-
v5 = f(1)
118-
assert v5 == v4
119-
120-
12198
@pytest.mark.sql
12299
def test_sql_concurrency():
123100
@cachier(backend="sql", sql_engine=SQL_CONN_STR)

tests/test_exporters.py

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -121,64 +121,6 @@ def test_metrics_exporter_interface():
121121
assert isinstance(exporter, MetricsExporter)
122122

123123

124-
@pytest.mark.memory
125-
def test_prometheus_exporter_with_prometheus_client_fallback():
126-
"""Test PrometheusExporter with use_prometheus_client=True falls back gracefully."""
127-
128-
# When prometheus_client is not available, it should fall back to text mode
129-
@cachier(backend="memory", enable_metrics=True)
130-
def test_func(x):
131-
return x * 2
132-
133-
test_func.clear_cache()
134-
135-
# Create exporter with use_prometheus_client=True (will use text mode as fallback)
136-
exporter = PrometheusExporter(port=9095, use_prometheus_client=True)
137-
exporter.register_function(test_func)
138-
139-
# Generate some metrics
140-
test_func(5)
141-
test_func(5)
142-
143-
# Verify function is registered
144-
assert test_func in exporter._registered_functions.values()
145-
146-
# Verify text metrics can be generated (fallback mode)
147-
metrics_text = exporter._generate_text_metrics()
148-
assert "cachier_cache_hits_total" in metrics_text
149-
150-
test_func.clear_cache()
151-
152-
153-
@pytest.mark.memory
154-
def test_prometheus_exporter_collector_metrics():
155-
"""Test that custom collector generates correct metrics."""
156-
from cachier import cachier
157-
from cachier.exporters import PrometheusExporter
158-
159-
@cachier(backend="memory", enable_metrics=True)
160-
def test_func(x):
161-
return x * 2
162-
163-
test_func.clear_cache()
164-
165-
# Use text mode to verify metrics are accessible
166-
exporter = PrometheusExporter(port=9096, use_prometheus_client=False)
167-
exporter.register_function(test_func)
168-
169-
# Generate metrics
170-
test_func(5)
171-
test_func(5) # hit
172-
test_func(10) # miss
173-
174-
# Get stats to verify
175-
stats = test_func.metrics.get_stats()
176-
assert stats.hits == 1
177-
assert stats.misses == 2
178-
179-
test_func.clear_cache()
180-
181-
182124
@pytest.mark.memory
183125
def test_prometheus_exporter_double_instantiation():
184126
"""Test that two PrometheusExporter instances both work independently."""

0 commit comments

Comments
 (0)