@@ -68,8 +68,6 @@ def test_get_record(monkeypatch):
6868
6969 stats = Statistics ()
7070 stats .total_hits = 10
71- stats .on_rate_limit ()
72- stats .on_rate_limit ()
7371 stats .operations .register_call ("test.test" , "nosql_op" )
7472 stats .on_detected_attack (blocked = True , operation = "test.test" )
7573 stats .attacks_detected = 5
@@ -79,7 +77,6 @@ def test_get_record(monkeypatch):
7977 assert record ["startedAt" ] == stats .started_at
8078 assert record ["endedAt" ] == mock_time
8179 assert record ["requests" ]["total" ] == 10
82- assert record ["requests" ]["rate_limited" ] == 2
8380 assert record ["requests" ]["aborted" ] == 0
8481 assert record ["requests" ]["attacksDetected" ]["total" ] == 5
8582 assert record ["requests" ]["attacksDetected" ]["blocked" ] == 3
@@ -100,7 +97,6 @@ def test_import_from_record():
10097 record = {
10198 "requests" : {
10299 "total" : 10 ,
103- "rate_limited" : 5 ,
104100 "attacksDetected" : {
105101 "total" : 5 ,
106102 "blocked" : 3 ,
@@ -121,7 +117,6 @@ def test_import_from_record():
121117 }
122118 stats .import_from_record (record )
123119 assert stats .total_hits == 10
124- assert stats .rate_limited_hits == 5
125120 assert stats .attacks_detected == 5
126121 assert stats .attacks_blocked == 3
127122 assert stats .operations == {
@@ -157,7 +152,6 @@ def test_multiple_imports(stats):
157152 record1 = {
158153 "requests" : {
159154 "total" : 10 ,
160- "rate_limited" : 20 ,
161155 "attacksDetected" : {
162156 "total" : 5 ,
163157 "blocked" : 3 ,
@@ -174,7 +168,6 @@ def test_multiple_imports(stats):
174168 record2 = {
175169 "requests" : {
176170 "total" : 20 ,
177- "rate_limited" : 5 ,
178171 "attacksDetected" : {
179172 "total" : 10 ,
180173 "blocked" : 7 ,
@@ -191,7 +184,6 @@ def test_multiple_imports(stats):
191184 stats .import_from_record (record1 )
192185 stats .import_from_record (record2 )
193186 assert stats .total_hits == 30
194- assert stats .rate_limited_hits == 25
195187 assert stats .attacks_detected == 15
196188 assert stats .attacks_blocked == 10
197189 assert stats .operations == {
@@ -212,7 +204,6 @@ def test_import_empty_record(stats):
212204 record = {"requests" : {}}
213205 stats .import_from_record (record )
214206 assert stats .total_hits == 0
215- assert stats .rate_limited_hits == 0
216207 assert stats .attacks_detected == 0
217208 assert stats .attacks_blocked == 0
218209 assert stats .operations == {}
@@ -222,7 +213,6 @@ def test_import_partial_record(stats):
222213 record = {"requests" : {"total" : 10 }}
223214 stats .import_from_record (record )
224215 assert stats .total_hits == 10
225- assert stats .rate_limited_hits == 0
226216 assert stats .attacks_detected == 0
227217 assert stats .attacks_blocked == 0
228218 assert stats .operations == {}
@@ -252,40 +242,3 @@ def test_multiple_increments_and_detects(stats):
252242 "kind" : "sql_op" ,
253243 "total" : 1 ,
254244 }
255-
256- stats .on_rate_limit ()
257- assert stats .rate_limited_hits == 1
258-
259- stats .on_rate_limit ()
260- assert stats .rate_limited_hits == 2
261-
262-
263- def test_multiple_rate_limits (stats ):
264- """Test multiple rate limit calls"""
265- for _ in range (5 ):
266- stats .on_rate_limit ()
267- assert stats .rate_limited_hits == 5
268-
269-
270- def test_rate_limit_in_get_record ():
271- """Test that rate_limited_hits is included in get_record output"""
272- stats = Statistics ()
273- stats .total_hits = 10
274- stats .on_rate_limit ()
275- stats .on_rate_limit ()
276- stats .on_rate_limit ()
277-
278- record = stats .get_record ()
279- assert record ["requests" ]["rate_limited" ] == 3
280- assert record ["requests" ]["total" ] == 10
281-
282-
283- def test_rate_limit_clear ():
284- """Test that clear() resets rate_limited_hits"""
285- stats = Statistics ()
286- stats .on_rate_limit ()
287- stats .on_rate_limit ()
288- assert stats .rate_limited_hits == 2
289-
290- stats .clear ()
291- assert stats .rate_limited_hits == 0
0 commit comments