(client)
| 582 | |
| 583 | @pytest.mark.redismod |
| 584 | def test_numby_commands_dollar(client): |
| 585 | # Test NUMINCRBY |
| 586 | client.json().set("doc1", "$", {"a": "b", "b": [{"a": 2}, {"a": 5.0}, {"a": "c"}]}) |
| 587 | # Test multi |
| 588 | assert client.json().numincrby("doc1", "$..a", 2) == [None, 4, 7.0, None] |
| 589 | |
| 590 | assert client.json().numincrby("doc1", "$..a", 2.5) == [None, 6.5, 9.5, None] |
| 591 | # Test single |
| 592 | assert client.json().numincrby("doc1", "$.b[1].a", 2) == [11.5] |
| 593 | |
| 594 | assert client.json().numincrby("doc1", "$.b[2].a", 2) == [None] |
| 595 | assert client.json().numincrby("doc1", "$.b[1].a", 3.5) == [15.0] |
| 596 | |
| 597 | # Test NUMMULTBY |
| 598 | client.json().set("doc1", "$", {"a": "b", "b": [{"a": 2}, {"a": 5.0}, {"a": "c"}]}) |
| 599 | |
| 600 | # test list |
| 601 | with pytest.deprecated_call(): |
| 602 | assert client.json().nummultby("doc1", "$..a", 2) == [None, 4, 10, None] |
| 603 | assert client.json().nummultby("doc1", "$..a", 2.5) == [None, 10.0, 25.0, None] |
| 604 | |
| 605 | # Test single |
| 606 | with pytest.deprecated_call(): |
| 607 | assert client.json().nummultby("doc1", "$.b[1].a", 2) == [50.0] |
| 608 | assert client.json().nummultby("doc1", "$.b[2].a", 2) == [None] |
| 609 | assert client.json().nummultby("doc1", "$.b[1].a", 3) == [150.0] |
| 610 | |
| 611 | # test missing keys |
| 612 | with pytest.raises(exceptions.ResponseError): |
| 613 | client.json().numincrby("non_existing_doc", "$..a", 2) |
| 614 | client.json().nummultby("non_existing_doc", "$..a", 2) |
| 615 | |
| 616 | client.json().set("doc1", "$", {"a": "b", "b": [{"a": 2}, {"a": 5.0}, {"a": "c"}]}) |
| 617 | assert_resp_response(client, client.json().numincrby("doc1", ".b[0].a", 3), 5, [5]) |
| 618 | |
| 619 | # Test legacy NUMMULTBY |
| 620 | client.json().set("doc1", "$", {"a": "b", "b": [{"a": 2}, {"a": 5.0}, {"a": "c"}]}) |
| 621 | |
| 622 | with pytest.deprecated_call(): |
| 623 | assert_resp_response( |
| 624 | client, client.json().nummultby("doc1", ".b[0].a", 3), 6, [6] |
| 625 | ) |
| 626 | |
| 627 | |
| 628 | @pytest.mark.redismod |
nothing calls this directly
no test coverage detected