| 197 | |
| 198 | @pytest.mark.redismod |
| 199 | async def test_incrby_decrby(decoded_r: redis.Redis): |
| 200 | for _ in range(100): |
| 201 | assert await decoded_r.ts().incrby(KEY1, 1) |
| 202 | sleep(0.001) |
| 203 | assert 100 == (await decoded_r.ts().get(KEY1))[1] |
| 204 | for _ in range(100): |
| 205 | assert await decoded_r.ts().decrby(KEY1, 1) |
| 206 | sleep(0.001) |
| 207 | assert 0 == (await decoded_r.ts().get(KEY1))[1] |
| 208 | |
| 209 | assert await decoded_r.ts().incrby(KEY2, 1.5, timestamp=5) |
| 210 | assert_resp_response(decoded_r, await decoded_r.ts().get(KEY2), (5, 1.5), [5, 1.5]) |
| 211 | assert await decoded_r.ts().incrby(KEY2, 2.25, timestamp=7) |
| 212 | assert_resp_response( |
| 213 | decoded_r, await decoded_r.ts().get(KEY2), (7, 3.75), [7, 3.75] |
| 214 | ) |
| 215 | assert await decoded_r.ts().decrby(KEY2, 1.5, timestamp=15) |
| 216 | assert_resp_response( |
| 217 | decoded_r, await decoded_r.ts().get(KEY2), (15, 2.25), [15, 2.25] |
| 218 | ) |
| 219 | |
| 220 | # Test for a chunk size of 128 Bytes on TS.INCRBY |
| 221 | assert await decoded_r.ts().incrby("time-serie-1", 10, chunk_size=128) |
| 222 | info = await decoded_r.ts().info("time-serie-1") |
| 223 | assert_resp_response(decoded_r, 128, info.get("chunk_size"), info.get("chunkSize")) |
| 224 | |
| 225 | # Test for a chunk size of 128 Bytes on TS.DECRBY |
| 226 | assert await decoded_r.ts().decrby("time-serie-2", 10, chunk_size=128) |
| 227 | info = await decoded_r.ts().info("time-serie-2") |
| 228 | assert_resp_response(decoded_r, 128, info.get("chunk_size"), info.get("chunkSize")) |
| 229 | |
| 230 | |
| 231 | @pytest.mark.redismod |