Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 41 additions & 46 deletions test/new_tests/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,89 +62,87 @@ def add_ctx_op(ctx_type, value):

class TestQuery(TestBaseClass):
# TODO: This fixture should be split up to speed up this test class
def setup_class(cls):
client = TestBaseClass.get_new_connection()

def setup_class(cls, as_connection):
try:
client.index_integer_create("test", "demo", "test_age", "age_index")
as_connection.index_integer_create("test", "demo", "test_age", "age_index")
except e.IndexFoundError:
pass

try:
client.index_string_create("test", "demo", "addr", "addr_index")
as_connection.index_string_create("test", "demo", "addr", "addr_index")
except e.IndexFoundError:
pass

try:
client.index_integer_create("test", "demo", "age1", "age_index1")
as_connection.index_integer_create("test", "demo", "age1", "age_index1")
except e.IndexFoundError:
pass

try:
client.index_list_create("test", "demo", "numeric_list", aerospike.INDEX_NUMERIC, "numeric_list_index")
as_connection.index_list_create("test", "demo", "numeric_list", aerospike.INDEX_NUMERIC, "numeric_list_index")
except e.IndexFoundError:
pass

try:
client.index_list_create("test", "demo", "string_list", aerospike.INDEX_STRING, "string_list_index")
as_connection.index_list_create("test", "demo", "string_list", aerospike.INDEX_STRING, "string_list_index")
except e.IndexFoundError:
pass

try:
client.index_map_keys_create("test", "demo", "numeric_map", aerospike.INDEX_NUMERIC, "numeric_map_index")
as_connection.index_map_keys_create("test", "demo", "numeric_map", aerospike.INDEX_NUMERIC, "numeric_map_index")
except e.IndexFoundError:
pass

try:
client.index_map_keys_create("test", "demo", "string_map", aerospike.INDEX_STRING, "string_map_index")
as_connection.index_map_keys_create("test", "demo", "string_map", aerospike.INDEX_STRING, "string_map_index")
except e.IndexFoundError:
pass

try:
client.index_map_values_create(
as_connection.index_map_values_create(
"test", "demo", "numeric_map", aerospike.INDEX_NUMERIC, "numeric_map_values_index"
)
except e.IndexFoundError:
pass

try:
client.index_map_values_create(
as_connection.index_map_values_create(
"test", "demo", "string_map", aerospike.INDEX_STRING, "string_map_values_index"
)
except e.IndexFoundError:
pass

try:
client.index_integer_create("test", None, "test_age_none", "age_index_none")
as_connection.index_integer_create("test", None, "test_age_none", "age_index_none")
except e.IndexFoundError:
pass

try:
client.index_integer_create("test", "demo", bytearray("sal\0kj", "utf-8"), "sal_index")
as_connection.index_integer_create("test", "demo", bytearray("sal\0kj", "utf-8"), "sal_index")
except e.IndexFoundError:
pass

if (TestBaseClass.major_ver, TestBaseClass.minor_ver) >= (7, 0):
# These indexes are only used for server 7.0+ tests
try:
client.index_list_create("test", "demo", "blob_list", aerospike.INDEX_BLOB, "blob_list_index")
as_connection.index_list_create("test", "demo", "blob_list", aerospike.INDEX_BLOB, "blob_list_index")
except e.IndexFoundError:
pass

try:
client.index_map_keys_create("test", "demo", "blob_map", aerospike.INDEX_BLOB, "blob_map_keys_index")
as_connection.index_map_keys_create("test", "demo", "blob_map", aerospike.INDEX_BLOB, "blob_map_keys_index")
except e.IndexFoundError:
pass

try:
client.index_map_values_create(
as_connection.index_map_values_create(
"test", "demo", "blob_map", aerospike.INDEX_BLOB, "blob_map_values_index"
)
except e.IndexFoundError:
pass

try:
client.index_cdt_create(
as_connection.index_cdt_create(
"test",
"demo",
"numeric_list",
Expand All @@ -157,7 +155,7 @@ def setup_class(cls):
pass

try:
client.index_cdt_create(
as_connection.index_cdt_create(
"test",
"demo",
"numeric_map",
Expand All @@ -169,74 +167,71 @@ def setup_class(cls):
except e.IndexFoundError:
pass

client.close()

def teardown_class(cls):
client = TestBaseClass.get_new_connection()
yield

policy = {}
try:
client.index_remove("test", "age_index", policy)
as_connection.index_remove("test", "age_index", policy)
except e.IndexNotFound:
pass

try:
client.index_remove("test", "age_index1", policy)
as_connection.index_remove("test", "age_index1", policy)
except e.IndexNotFound:
pass

try:
client.index_remove("test", "addr_index", policy)
as_connection.index_remove("test", "addr_index", policy)
except e.IndexNotFound:
pass

try:
client.index_remove("test", "numeric_list_index", policy)
as_connection.index_remove("test", "numeric_list_index", policy)
except e.IndexNotFound:
pass

try:
client.index_remove("test", "string_list_index", policy)
as_connection.index_remove("test", "string_list_index", policy)
except e.IndexNotFound:
pass

try:
client.index_remove("test", "numeric_map_index", policy)
as_connection.index_remove("test", "numeric_map_index", policy)
except e.IndexNotFound:
pass

try:
client.index_remove("test", "string_map_index", policy)
as_connection.index_remove("test", "string_map_index", policy)
except e.IndexNotFound:
pass

try:
client.index_remove("test", "numeric_map_values_index", policy)
as_connection.index_remove("test", "numeric_map_values_index", policy)
except e.IndexNotFound:
pass

try:
client.index_remove("test", "string_map_values_index", policy)
as_connection.index_remove("test", "string_map_values_index", policy)
except e.IndexNotFound:
pass

try:
client.index_remove("test", "age_index_none", policy)
as_connection.index_remove("test", "age_index_none", policy)
except e.IndexNotFound:
pass

try:
client.index_remove("test", "sal_index")
as_connection.index_remove("test", "sal_index")
except e.IndexNotFound:
pass

try:
client.index_remove("test", "numeric_list_cdt_index", policy)
as_connection.index_remove("test", "numeric_list_cdt_index", policy)
except e.IndexNotFound:
pass

try:
client.index_remove("test", "numeric_map_cdt_index", policy)
as_connection.index_remove("test", "numeric_map_cdt_index", policy)
except e.IndexNotFound:
pass

Expand All @@ -247,14 +242,14 @@ def teardown_class(cls):
]
for name in blob_index_names_to_remove:
try:
client.index_remove("test", name, policy)
as_connection.index_remove("test", name, policy)
except e.IndexNotFound:
pass

client.close()
as_connection.close()

@pytest.fixture(autouse=True)
def setup_method(self, request, as_connection):
def setup_method(self, request):
"""
Setup method.
"""
Expand All @@ -280,32 +275,32 @@ def setup_method(self, request, as_connection):
"no": i,
"blob": i.to_bytes(length=1, byteorder='big')
}
as_connection.put(key, rec)
self.as_connection.put(key, rec)
for i in range(5, 10):
key = ("test", "demo", i)
rec = {"name": "name%s" % (str(i)), "addr": "name%s" % (str(i)), "test_age": i, "no": i}
as_connection.put(key, rec)
self.as_connection.put(key, rec)

key = ("test", "demo", 122)
llist = [{"op": aerospike.OPERATOR_WRITE, "bin": bytearray("sal\0kj", "utf-8"), "val": 80000}]
as_connection.operate(key, llist)
self.as_connection.operate(key, llist)

key = ("test", None, 145)
rec = {"test_age_none": 1}
as_connection.put(key, rec)
self.as_connection.put(key, rec)

def teardown():
"""
Teardown method.
"""
for i in range(10):
key = ("test", "demo", i)
as_connection.remove(key)
self.as_connection.remove(key)

key = ("test", "demo", 122)
as_connection.remove(key)
self.as_connection.remove(key)
key = ("test", None, 145)
as_connection.remove(key)
self.as_connection.remove(key)

request.addfinalizer(teardown)

Expand Down
Loading