MCPcopy
hub / github.com/redis/redis-py / test_create_and_delete_rule

Function test_create_and_delete_rule

tests/test_timeseries.py:220–240  ·  view source on GitHub ↗
(client)

Source from the content-addressed store, hash-verified

218
219@pytest.mark.redismod
220def test_create_and_delete_rule(client):
221 # test rule creation
222 time = 100
223 client.ts().create(1)
224 client.ts().create(2)
225 client.ts().createrule(1, 2, "avg", 100)
226 for i in range(50):
227 client.ts().add(1, time + i * 2, 1)
228 client.ts().add(1, time + i * 2 + 1, 2)
229 client.ts().add(1, time * 2, 1.5)
230 assert round(client.ts().get(2)[1], 5) == 1.5
231 info = client.ts().info(1)
232 if is_resp2_connection(client):
233 assert info.rules[0][1] == 100
234 else:
235 assert info["rules"]["2"][0] == 100
236
237 # test rule deletion
238 client.ts().deleterule(1, 2)
239 info = client.ts().info(1)
240 assert not info["rules"]
241
242
243@pytest.mark.redismod

Callers

nothing calls this directly

Calls 8

is_resp2_connectionFunction · 0.85
createruleMethod · 0.80
deleteruleMethod · 0.80
createMethod · 0.45
tsMethod · 0.45
addMethod · 0.45
getMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected