Skip to content

Commit

Permalink
fix expression bool/bitwise tests for server 5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
dwelch-spike committed May 11, 2021
1 parent f1ba33a commit 8c331b6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
28 changes: 22 additions & 6 deletions test/new_tests/test_expressions_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,24 +226,40 @@ def test_bool_bin_true(self):
pytest.mark.xfail(reason="Servers older than 5.6 do not support 6.0.0 expressions")
pytest.xfail()

hostlist, user, password = TestBaseClass().get_hosts()
tls_info = TestBaseClass().get_tls_info()
config = TestBaseClass.get_connection_config()
config["send_bool_as"] = aerospike.AS_BOOL
test_client = aerospike.client(config).connect(user, password)

expr = BoolBin("t")
ops = [
expressions.expression_read(expr.compile())
operations.write("t", True),
expressions.expression_read("", expr.compile())
]
_, _, res = self.as_connection.operate(('test', u'demo', _NUM_RECORDS - 1), ops)
assert res['']
_, _, res = test_client.operate(('test', u'demo', _NUM_RECORDS - 1), ops)
test_client.close()
assert res[""]

def test_bool_bin_false(self):
if self.server_version < [5, 6]:
pytest.mark.xfail(reason="Servers older than 5.6 do not support 6.0.0 expressions")
pytest.xfail()

hostlist, user, password = TestBaseClass().get_hosts()
tls_info = TestBaseClass().get_tls_info()
config = TestBaseClass.get_connection_config()
config["send_bool_as"] = aerospike.AS_BOOL
test_client = aerospike.client(config).connect(user, password)

expr = Not(BoolBin("t"))
ops = [
expressions.expression_read(expr.compile())
operations.write("t", True),
expressions.expression_read("", expr.compile())
]
_, _, res = self.as_connection.operate(('test', u'demo', _NUM_RECORDS - 1), ops)
assert not res['']
_, _, res = test_client.operate(('test', u'demo', _NUM_RECORDS - 1), ops)
test_client.close()
assert not res[""]

def test_exclusive_pos(self):
if self.server_version < [5, 6]:
Expand Down
13 changes: 7 additions & 6 deletions test/new_tests/test_expressions_bitwise_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ def test_int_left_shift_pos(self, bin, val, check):
self.verify_expression(expr, self.rec)

@pytest.mark.parametrize("bin, val, check, expected", [
# (IntBin("10bin"), [2], 0xAAF0, e.FilteredOut),
# FilteredOut instead of InvalidRequest because shift is not type checked (expression).
(IntBin("1bin"), ["bad_arg"], 0x0000, e.FilteredOut)
(IntBin("10bin"), [2], 0xAAF0, e.FilteredOut),
# InvalidRequest because shift is not type checked (expression).
(IntBin("1bin"), ["bad_arg"], 0x0000, e.InvalidRequest)
])
def test_int_left_shift_neg(self, bin, val, expected, check):
"""
Expand Down Expand Up @@ -201,8 +201,8 @@ def test_int_right_shift_pos(self, bin, val, check):

@pytest.mark.parametrize("bin, val, check, expected", [
(IntBin("10bin"), [2], 0xAAF0, e.FilteredOut),
# NOTE FilteredOut instead of InvalidRequest because shift is not type checked (expression).
(IntBin("1bin"), ["bad_arg"], 0xFFFF, e.FilteredOut)
# InvalidRequest because shift is not type checked (expression).
(IntBin("1bin"), ["bad_arg"], 0xFFFF, e.InvalidRequest)
])
def test_int_right_shift_neg(self, bin, val, expected, check):
"""
Expand Down Expand Up @@ -230,7 +230,8 @@ def test_int_right_arithmetic_shift_pos(self, bin, val, check):

@pytest.mark.parametrize("bin, val, check, expected", [
(IntBin("10bin"), [2], 0xAAF0, e.FilteredOut),
(IntBin("1bin"), ["bad_arg"], 0xFFFF, e.FilteredOut)
# InvalidRequest because shift is not type checked (expression).
(IntBin("1bin"), ["bad_arg"], 0xFFFF, e.InvalidRequest)
])
def test_int_right_arithmetic_shift_neg(self, bin, val, expected, check):
"""
Expand Down

0 comments on commit 8c331b6

Please sign in to comment.