diff --git a/test/test_geospatial.py b/test/test_geospatial.py index ec262c244..ffe67ce67 100644 --- a/test/test_geospatial.py +++ b/test/test_geospatial.py @@ -69,10 +69,12 @@ def test_geospatial_put_get_positive(self): key, meta, bins = TestGeospatial.client.get(key) - assert bins == {'loc': {'coordinates': [42.34, 58.62], 'type': 'Point'}, + expected = {'loc': {'coordinates': [42.34, 58.62], 'type': 'Point'}, "int_bin": 2, "string_bin": "str", "dict_bin": {"a": 1, "b": 2, "geo": {'coordinates': [56.34, 69.62], 'type': 'Point'}}} + for b in bins: + assert b in expected TestGeospatial.client.remove(key) @@ -95,8 +97,10 @@ def callback((key, metadata, record)): query.foreach(callback) assert len(records) == 3 - assert records == [{'loc': {'coordinates': [-122.0, 37.5], 'type': 'Point'}}, {'loc': {'coordinates': [-121.8, 37.7], 'type': + expected = [{'loc': {'coordinates': [-122.0, 37.5], 'type': 'Point'}}, {'loc': {'coordinates': [-121.8, 37.7], 'type': 'Point'}}, {'loc': {'coordinates': [-121.6, 37.9], 'type': 'Point'}}] + for r in records: + assert r in expected def test_geospatial_positive_query_outside_shape(self): """ @@ -153,7 +157,9 @@ def callback((key, metadata, record)): TestGeospatial.client.remove(key) assert len(records) == 2 - assert records == [{'loc': {'coordinates': [-121.8, 37.7], 'type': 'Point'}}, {'loc': {'coordinates': [-121.6, 37.9], 'type': 'Point'}}] + expected = [{'loc': {'coordinates': [-121.8, 37.7], 'type': 'Point'}}, {'loc': {'coordinates': [-121.6, 37.9], 'type': 'Point'}}] + for r in records: + assert r in expected def test_geospatial_positive_query_for_circle(self): """ @@ -261,8 +267,10 @@ def callback((key, metadata, record)): query.foreach(callback) assert len(records) == 3 - assert records == [{'loc': {'coordinates': [-122.0, 37.5], 'type': 'Point'}}, {'loc': {'coordinates': [-121.8, 37.7], 'type': + expected = [{'loc': {'coordinates': [-122.0, 37.5], 'type': 'Point'}}, {'loc': {'coordinates': [-121.8, 37.7], 'type': 'Point'}}, {'loc': {'coordinates': [-121.6, 37.9], 'type': 'Point'}}] + for r in records: + assert r in expected def test_geospatial_loads_positive(self): """ @@ -306,8 +314,10 @@ def callback((key, metadata, record)): query.foreach(callback) assert len(records) == 3 - assert records == [{'loc': {'coordinates': [-122.0, 37.5], 'type': 'Point'}}, {'loc': {'coordinates': [-121.8, 37.7], 'type': + expected = [{'loc': {'coordinates': [-122.0, 37.5], 'type': 'Point'}}, {'loc': {'coordinates': [-121.8, 37.7], 'type': 'Point'}}, {'loc': {'coordinates': [-121.6, 37.9], 'type': 'Point'}}] + for r in records: + assert r in expected def test_geospatial_dumps_positive(self): """ @@ -341,10 +351,12 @@ def test_geospatial_put_get_positive_with_geodata(self): key, meta, bins = TestGeospatial.client.get(key) - assert bins == {'loc': {'coordinates': [42.34, 58.62], 'type': 'Point'}, + expected = {'loc': {'coordinates': [42.34, 58.62], 'type': 'Point'}, "int_bin": 2, "string_bin": "str", "dict_bin": {"a": 1, "b": 2, "geo": {'coordinates': [56.34, 69.62], 'type': 'Point'}}} + for b in bins: + assert b in expected TestGeospatial.client.remove(key) @@ -364,10 +376,12 @@ def test_geospatial_put_get_positive_with_geojson(self): key, meta, bins = TestGeospatial.client.get(key) - assert bins == {'loc': {'coordinates': [42.34, 58.62], 'type': 'Point'}, + expected = {'loc': {'coordinates': [42.34, 58.62], 'type': 'Point'}, "int_bin": 2, "string_bin": "str", "dict_bin": {"a": 1, "b": 2, "geo": {'coordinates': [56.34, 69.62], 'type': 'Point'}}} + for b in bins: + assert b in expected TestGeospatial.client.remove(key) @@ -390,8 +404,10 @@ def callback((key, metadata, record)): query.foreach(callback) assert len(records) == 3 - assert records == [{'loc': {'coordinates': [-122.0, 37.5], 'type': 'Point'}}, {'loc': {'coordinates': [-121.8, 37.7], 'type': + expected = [{'loc': {'coordinates': [-122.0, 37.5], 'type': 'Point'}}, {'loc': {'coordinates': [-121.8, 37.7], 'type': 'Point'}}, {'loc': {'coordinates': [-121.6, 37.9], 'type': 'Point'}}] + for r in records: + assert r in expected def test_geospatial_positive_query_with_geojson(self): """ @@ -410,8 +426,10 @@ def callback((key, metadata, record)): query.foreach(callback) assert len(records) == 3 - assert records == [{'loc': {'coordinates': [-122.0, 37.5], 'type': 'Point'}}, {'loc': {'coordinates': [-121.8, 37.7], 'type': + expected = [{'loc': {'coordinates': [-122.0, 37.5], 'type': 'Point'}}, {'loc': {'coordinates': [-121.8, 37.7], 'type': 'Point'}}, {'loc': {'coordinates': [-121.6, 37.9], 'type': 'Point'}}] + for r in records: + assert r in expected def test_geospatial_2dindex_positive(self): """ @@ -447,9 +465,7 @@ def test_geospatial_2dindex_set_length_extra(self): status = TestGeospatial.client.index_remove('test', 'loc_index') assert status == 0 - try: - status = TestGeospatial.client.index_geo2dsphere_create("test", set_name, "loc", "loc_index") - - except InvalidRequest as exception: - assert exception.code == 4 - assert exception.msg == "Invalid Set Name" + try: + status = TestGeospatial.client.index_geo2dsphere_create("test", set_name, "loc", "loc_index") + except InvalidRequest as exception: + assert exception.code == 4 diff --git a/test/test_index.py b/test/test_index.py index 31bc0a790..0612c6780 100644 --- a/test/test_index.py +++ b/test/test_index.py @@ -81,7 +81,6 @@ def test_createindex_with_correct_parameters_set_length_extra(self): 'age', 'age_index', policy) assert exception.value[0] == 4 - assert exception.value[1] == 'Invalid Set Name' def test_createindex_with_incorrect_namespace(self): """ @@ -94,7 +93,6 @@ def test_createindex_with_incorrect_namespace(self): except InvalidRequest as exception: assert exception.code == 4 - assert exception.msg == 'Namespace Not Found' def test_createindex_with_incorrect_set(self): """ @@ -259,7 +257,6 @@ def test_create_string_index_with_correct_parameters_set_length_extra(self): 'name', 'name_index', policy) assert exception.value[0] == 4 - assert exception.value[1] == 'Invalid Set Name' def test_create_string_index_with_correct_parameters_ns_length_extra(self): #Invoke createindex() with correct arguments ns length extra @@ -272,7 +269,6 @@ def test_create_string_index_with_correct_parameters_ns_length_extra(self): 'name', 'name_index', policy) assert exception.value[0] == 4 - assert exception.value[1] == 'Namespace Not Found' def test_create_string_index_with_incorrect_namespace(self): """ @@ -285,7 +281,6 @@ def test_create_string_index_with_incorrect_namespace(self): except InvalidRequest as exception: assert exception.code == 4 - assert exception.msg == 'Namespace Not Found' def test_create_string_index_with_incorrect_set(self): """ diff --git a/test/test_list_index.py b/test/test_list_index.py index 478e97f24..02347905f 100644 --- a/test/test_list_index.py +++ b/test/test_list_index.py @@ -101,7 +101,6 @@ def test_listindex_with_correct_parameters_set_length_extra(self): 'string_list', aerospike.INDEX_STRING, "test_string_list_index", policy) assert exception.value[0] == 4 - assert exception.value[1] == 'Invalid Set Name' def test_listindex_with_incorrect_namespace(self): """ @@ -115,7 +114,6 @@ def test_listindex_with_incorrect_namespace(self): except InvalidRequest as exception: assert exception.code == 4 - assert exception.msg == 'Namespace Not Found' def test_listindex_with_incorrect_set(self): """ diff --git a/test/test_mapkeys_index.py b/test/test_mapkeys_index.py index 4d9d07c13..e4972f5fc 100644 --- a/test/test_mapkeys_index.py +++ b/test/test_mapkeys_index.py @@ -103,7 +103,6 @@ def test_mapkeys_with_correct_parameters_set_length_extra(self): 'string_map', aerospike.INDEX_STRING, "test_string_map_index", policy) assert exception.value[0] == 4 - assert exception.value[1] == 'Invalid Set Name' def test_mapkeysindex_with_incorrect_namespace(self): """ @@ -116,7 +115,6 @@ def test_mapkeysindex_with_incorrect_namespace(self): except InvalidRequest as exception: assert exception.code == 4 - assert exception.msg == 'Namespace Not Found' def test_mapkeysindex_with_incorrect_set(self): """ diff --git a/test/test_mapvalues_index.py b/test/test_mapvalues_index.py index 1d074ae08..81e02d96c 100644 --- a/test/test_mapvalues_index.py +++ b/test/test_mapvalues_index.py @@ -104,7 +104,6 @@ def test_mapvalues_index_with_correct_parameters_set_length_extra(self): 'string_map', aerospike.INDEX_STRING, "test_string_map_index", policy) assert exception.value[0] == 4 - assert exception.value[1] == 'Invalid Set Name' def test_mapvaluesindex_with_incorrect_namespace(self): """ @@ -117,7 +116,6 @@ def test_mapvaluesindex_with_incorrect_namespace(self): except InvalidRequest as exception: assert exception.code == 4 - assert exception.msg == 'Namespace Not Found' def test_mapvaluesindex_with_incorrect_set(self): """ diff --git a/test/test_operate.py b/test/test_operate.py index d4ed6e82e..612f7961b 100644 --- a/test/test_operate.py +++ b/test/test_operate.py @@ -24,11 +24,11 @@ def setup_class(cls): else: TestOperate.client = aerospike.client(config).connect(user, password) - config_strict_types = {'hosts': hostlist, 'strict_types': False} + config_no_typechecks = {'hosts': hostlist, 'strict_types': False} if user == None and password == None: - TestOperate.client_strict_types = aerospike.client(config_strict_types).connect() + TestOperate.client_no_typechecks = aerospike.client(config_no_typechecks).connect() else: - TestOperate.client_strict_types = aerospike.client(config_strict_types).connect(user, password) + TestOperate.client_no_typechecks = aerospike.client(config_no_typechecks).connect(user, password) TestOperate.skip_old_server = True versioninfo = TestOperate.client.info('version') @@ -41,7 +41,7 @@ def setup_class(cls): def teardown_class(cls): TestOperate.client.close() - TestOperate.client_strict_types.close() + TestOperate.client_no_typechecks.close() def setup_method(self, method): TestOperate.keys = [] @@ -342,7 +342,6 @@ def test_operate_with_policy_gen_EQ_not_equal(self): except RecordGenerationError as exception: assert exception.code == 3L - assert exception.msg == "AEROSPIKE_ERR_RECORD_GENERATION" (key , meta, bins) = TestOperate.client.get(key) assert bins == { "age": 1, 'name': 'name1'} @@ -376,7 +375,6 @@ def test_operate_with_policy_gen_GT_lesser(self): except RecordGenerationError as exception: assert exception.code == 3L - assert exception.msg == "AEROSPIKE_ERR_RECORD_GENERATION" (key , meta, bins) = TestOperate.client.get(key) assert bins == { 'age' : 1, 'name': 'name1'} @@ -459,7 +457,6 @@ def test_opearte_on_same_bin_negative(self): except InvalidRequest as exception: assert exception.code == 4L - assert exception.msg == "AEROSPIKE_ERR_REQUEST_INVALID" def test_operate_with_nonexistent_key_positive(self): """ @@ -893,11 +890,11 @@ def test_operate_prepend_with_int_new_record(self): } ] - (key, meta, bins) = TestOperate.client_strict_types.operate(key, list) + (key, meta, bins) = TestOperate.client_no_typechecks.operate(key, list) assert {'age': 4} == bins - TestOperate.client_strict_types.remove(key) + TestOperate.client_no_typechecks.remove(key) def test_operate_prepend_with_int_existing_record(self): """ @@ -918,12 +915,12 @@ def test_operate_prepend_with_int_existing_record(self): ] try: - (key, meta, bins) = TestOperate.client_strict_types.operate(key, list) + (key, meta, bins) = TestOperate.client_no_typechecks.operate(key, list) except BinIncompatibleType as exception: assert exception.code == 12L - TestOperate.client_strict_types.remove(key) + TestOperate.client_no_typechecks.remove(key) def test_operate_prepend_with_list_existing_record(self): """ @@ -931,7 +928,7 @@ def test_operate_prepend_with_list_existing_record(self): """ key = ('test', 'demo', 'existing_key') - (key, old_meta) = TestOperate.client_strict_types.exists(key) + (key, old_meta) = TestOperate.client_no_typechecks.exists(key) list = [ { @@ -945,12 +942,16 @@ def test_operate_prepend_with_list_existing_record(self): } ] - (key, meta, bins) = TestOperate.client_strict_types.operate(key, list) + exception_raised = False + try: + (key, meta, bins) = TestOperate.client_no_typechecks.operate(key, list) + except BinIncompatibleType as exception: + assert exception.code == 12L + exception_raised = True + assert exception_raised is True - assert bins == {'list': ['c']} - assert meta['gen'] == old_meta['gen'] + 1 - TestOperate.client_strict_types.remove(key) + TestOperate.client_no_typechecks.remove(key) def test_operate_append_with_dict_new_record(self): """ @@ -970,11 +971,11 @@ def test_operate_append_with_dict_new_record(self): } ] - (key, meta, bins) = TestOperate.client_strict_types.operate(key, list) + (key, meta, bins) = TestOperate.client_no_typechecks.operate(key, list) assert {'dict': {"a": 1, "b": 2}} == bins - TestOperate.client_strict_types.remove(key) + TestOperate.client_no_typechecks.remove(key) def test_operate_append_with_dict_existing_record(self): """ @@ -982,7 +983,7 @@ def test_operate_append_with_dict_existing_record(self): """ key = ('test', 'demo', 'existing_key') - (key, old_meta) = TestOperate.client_strict_types.exists(key) + (key, old_meta) = TestOperate.client_no_typechecks.exists(key) list = [ { @@ -994,14 +995,17 @@ def test_operate_append_with_dict_existing_record(self): "op": aerospike.OPERATOR_READ, "bin": "dict" } - ] - - (key, meta, bins) = TestOperate.client_strict_types.operate(key, list) + ] - assert {'dict': {"a": 1}} == bins - assert meta['gen'] == old_meta['gen'] + 1 + exception_raised = False + try: + (key, meta, bins) = TestOperate.client_no_typechecks.operate(key, list) + except BinIncompatibleType as exception: + assert exception.code == 12L + exception_raised = True + assert exception_raised is True - TestOperate.client_strict_types.remove(key) + TestOperate.client_no_typechecks.remove(key) def test_operate_append_with_float_existing_record(self): """ @@ -1022,12 +1026,12 @@ def test_operate_append_with_float_existing_record(self): ] try: - (key, meta, bins) = TestOperate.client_strict_types.operate(key, list) + (key, meta, bins) = TestOperate.client_no_typechecks.operate(key, list) except BinIncompatibleType as exception: assert exception.code == 12L - TestOperate.client_strict_types.remove(key) + TestOperate.client_no_typechecks.remove(key) def test_operate_incr_with_string_new_record(self): """ @@ -1047,11 +1051,11 @@ def test_operate_incr_with_string_new_record(self): } ] - (key, meta, bins) = TestOperate.client_strict_types.operate(key, list) + (key, meta, bins) = TestOperate.client_no_typechecks.operate(key, list) assert {'name': 'aerospike'} == bins - TestOperate.client_strict_types.remove(key) + TestOperate.client_no_typechecks.remove(key) def test_operate_incr_with_string_existing_record(self): """ @@ -1072,12 +1076,12 @@ def test_operate_incr_with_string_existing_record(self): ] try: - (key, meta, bins) = TestOperate.client_strict_types.operate(key, list) + (key, meta, bins) = TestOperate.client_no_typechecks.operate(key, list) except BinIncompatibleType as exception: assert exception.code == 12L - TestOperate.client_strict_types.remove(key) + TestOperate.client_no_typechecks.remove(key) def test_operate_incr_with_bytearray_existing_record(self): """ @@ -1098,12 +1102,12 @@ def test_operate_incr_with_bytearray_existing_record(self): ] try: - (key, meta, bins) = TestOperate.client_strict_types.operate(key, list) + (key, meta, bins) = TestOperate.client_no_typechecks.operate(key, list) except BinIncompatibleType as exception: assert exception.code == 12L - TestOperate.client_strict_types.remove(key) + TestOperate.client_no_typechecks.remove(key) def test_operate_incr_with_geospatial_new_record(self): """ @@ -1124,11 +1128,11 @@ def test_operate_incr_with_geospatial_new_record(self): } ] - (key, meta, bins) = TestOperate.client_strict_types.operate(key, list) + (key, meta, bins) = TestOperate.client_no_typechecks.operate(key, list) assert bins == {'geospatial': {'coordinates': [42.34, 58.62], 'type': 'Point'}} - TestOperate.client_strict_types.remove(key) + TestOperate.client_no_typechecks.remove(key) def test_operate_with_bin_length_extra(self): """ @@ -1175,9 +1179,9 @@ def test_operate_with_bin_length_extra_nostricttypes(self): "val": 3} ] - TestOperate.client_strict_types.operate(key, list) + TestOperate.client_no_typechecks.operate(key, list) - (key, meta, bins) = TestOperate.client_strict_types.get(key) + (key, meta, bins) = TestOperate.client_no_typechecks.get(key) assert bins == {"name": "ramname1", "age": 1} @@ -1219,7 +1223,7 @@ def test_operate_with_command_invalid_nostricttypes(self): "bin": "name"} ] - key, meta, bins = TestOperate.client_strict_types.operate(key, list) + key, meta, bins = TestOperate.client_no_typechecks.operate(key, list) assert bins == {'name': 'ramname1'}