From 4f078c2511126e2104ebc289e3ddb26c3f3a5c34 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Thu, 9 Jul 2026 14:24:38 -0700 Subject: [PATCH] Add tests to make sure warning is printed for invalid values passed to enum types --- test/new_tests/test_invalid_options.py | 43 ++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 test/new_tests/test_invalid_options.py diff --git a/test/new_tests/test_invalid_options.py b/test/new_tests/test_invalid_options.py new file mode 100644 index 0000000000..c31f87ba13 --- /dev/null +++ b/test/new_tests/test_invalid_options.py @@ -0,0 +1,43 @@ +from conftest import KEYS +import pytest + +from aerospike_helpers.operations import bitwise_operations, map_operations, list_operations, hll_operations +import aerospike + +@pytest.mark.usefixtures("as_connection") +class TestInvalidOptions: + def setup(self): + self.key = KEYS[0] + self.as_connection.put( + self.key, + bins={ + "bitwise": b'12345', + "map": { + "a": 1 + }, + "list": [] + } + ) + yield + self.as_connection.remove(self.key) + + @pytest.mark.parametrize( + "op", + [ + # Use fixture with correct bins + bitwise_operations.bit_lshift(bin_name="bitwise", bit_offset=0, bit_size=2, shift=1, policy={"bit_write_flags": -1}), + # TODO: aerospike.BIT_WRITE_PARTIAL <= x < aerospike.BIT_WRITE_PARTIAL * 2 may be valid + bitwise_operations.bit_resize(bin_name="bitwise", byte_size=1, resize_flags=aerospike.BIT_RESIZE_SHRINK_ONLY * 2), + # TODO: same issue as above + map_operations.map_set_policy(bin_name="map", policy={"map_write_flags": aerospike.MAP_WRITE_PARTIAL * 2}), + list_operations.list_append(bin_name="list", value=1, policy={"list_order": aerospike.LIST_ORDERED + 1}), + list_operations.list_append(bin_name="list", value=1, policy={"write_flags": aerospike.LIST_WRITE_PARTIAL * 2}), + hll_operations.hll_add(bin_name="hll", policy={"flags": aerospike.HLL_WRITE_ALLOW_FOLD * 2}), + ] + ) + def test_invalid_enum_values_emits_warning(self, op): + ops = [ + op + ] + with pytest.warns(DeprecationWarning): + self.as_connection.operate(self.key, ops)