| 144 | @pytest.mark.redismod |
| 145 | @skip_ifmodversion_lt("1.4.0", "timeseries") |
| 146 | def test_add_on_duplicate(client): |
| 147 | # Test for duplicate policy BLOCK |
| 148 | assert 1 == client.ts().add("time-serie-add-ooo-block", 1, 5.0) |
| 149 | with pytest.raises(Exception): |
| 150 | client.ts().add("time-serie-add-ooo-block", 1, 5.0, on_duplicate="block") |
| 151 | |
| 152 | # Test for duplicate policy LAST |
| 153 | assert 1 == client.ts().add("time-serie-add-ooo-last", 1, 5.0) |
| 154 | assert 1 == client.ts().add("time-serie-add-ooo-last", 1, 10.0, on_duplicate="last") |
| 155 | assert 10.0 == client.ts().get("time-serie-add-ooo-last")[1] |
| 156 | |
| 157 | # Test for duplicate policy FIRST |
| 158 | assert 1 == client.ts().add("time-serie-add-ooo-first", 1, 5.0) |
| 159 | assert 1 == client.ts().add( |
| 160 | "time-serie-add-ooo-first", 1, 10.0, on_duplicate="first" |
| 161 | ) |
| 162 | assert 5.0 == client.ts().get("time-serie-add-ooo-first")[1] |
| 163 | |
| 164 | # Test for duplicate policy MAX |
| 165 | assert 1 == client.ts().add("time-serie-add-ooo-max", 1, 5.0) |
| 166 | assert 1 == client.ts().add("time-serie-add-ooo-max", 1, 10.0, on_duplicate="max") |
| 167 | assert 10.0 == client.ts().get("time-serie-add-ooo-max")[1] |
| 168 | |
| 169 | # Test for duplicate policy MIN |
| 170 | assert 1 == client.ts().add("time-serie-add-ooo-min", 1, 5.0) |
| 171 | assert 1 == client.ts().add("time-serie-add-ooo-min", 1, 10.0, on_duplicate="min") |
| 172 | assert 5.0 == client.ts().get("time-serie-add-ooo-min")[1] |
| 173 | |
| 174 | |
| 175 | @pytest.mark.redismod |