<s> import pytest <EOL> import sys <EOL> from . test_base_class import TestBaseClass <EOL> from aerospike import exception as e <EOL> aerospike = pytest . importorskip ( "<STR_LIT>" ) <EOL> try : <EOL> import aerospike <EOL> except : <EOL> print ( "<STR_LIT>" ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> class TestListIndex ( object ) : <EOL> def setup_class ( cls ) : <EOL> """<STR_LIT>""" <EOL> hostlist , user , password = TestBaseClass . get_hosts ( ) <EOL> config = { '<STR_LIT>' : hostlist } <EOL> if user is None and password is None : <EOL> TestListIndex . client = aerospike . client ( config ) . connect ( ) <EOL> else : <EOL> TestListIndex . client = aerospike . client ( config ) . connect ( user , <EOL> password ) <EOL> def teardown_class ( cls ) : <EOL> TestListIndex . client . close ( ) <EOL> def setup_method ( self , method ) : <EOL> """<STR_LIT>""" <EOL> for i in range ( <NUM_LIT:5> ) : <EOL> key = ( '<STR_LIT:test>' , u'<STR_LIT>' , i ) <EOL> rec = { <EOL> '<STR_LIT:name>' : '<STR_LIT>' % ( str ( i ) ) , <EOL> '<STR_LIT>' : '<STR_LIT>' % ( str ( i ) ) , <EOL> '<STR_LIT>' : [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] , <EOL> '<STR_LIT>' : [ "<STR_LIT:a>" , "<STR_LIT:b>" , "<STR_LIT:c>" , "<STR_LIT:d>" ] , <EOL> '<STR_LIT>' : i , <EOL> '<STR_LIT>' : i <EOL> } <EOL> TestListIndex . client . put ( key , rec ) <EOL> def teardown_method ( self , method ) : <EOL> """<STR_LIT>""" <EOL> for i in range ( <NUM_LIT:5> ) : <EOL> key = ( '<STR_LIT:test>' , u'<STR_LIT>' , i ) <EOL> TestListIndex . client . remove ( key ) <EOL> def test_listindex_with_no_paramters ( self ) : <EOL> """<STR_LIT>""" <EOL> with pytest . raises ( TypeError ) as typeError : <EOL> TestListIndex . client . index_list_create ( ) <EOL> assert "<STR_LIT>" in str ( <EOL> typeError . value ) <EOL> def test_listindex_with_correct_parameters ( self ) : <EOL> """<STR_LIT>""" <EOL> policy = { } <EOL> retobj = TestListIndex . client . index_list_create ( <EOL> '<STR_LIT:test>' , '<STR_LIT>' , '<STR_LIT>' , aerospike . INDEX_STRING , <EOL> '<STR_LIT>' , policy ) <EOL> assert retobj == <NUM_LIT:0> <EOL> TestListIndex . client . index_remove ( '<STR_LIT:test>' , '<STR_LIT>' , <EOL> policy ) <EOL> def test_listindex_with_correct_parameters_numeric ( self ) : <EOL> """<STR_LIT>""" <EOL> policy = { } <EOL> retobj = TestListIndex . client . index_list_create ( <EOL> '<STR_LIT:test>' , '<STR_LIT>' , '<STR_LIT>' , aerospike . INDEX_NUMERIC , <EOL> '<STR_LIT>' , policy ) <EOL> assert retobj == <NUM_LIT:0> <EOL> TestListIndex . client . index_remove ( '<STR_LIT:test>' , '<STR_LIT>' , <EOL> policy ) <EOL> def test_listindex_with_correct_parameters_set_length_extra ( self ) : <EOL> set_name = '<STR_LIT:a>' <EOL> for _ in range ( <NUM_LIT:100> ) : <EOL> set_name = set_name + '<STR_LIT:a>' <EOL> policy = { } <EOL> try : <EOL> TestListIndex . client . index_list_create ( <EOL> '<STR_LIT:test>' , set_name , '<STR_LIT>' , aerospike . INDEX_STRING , <EOL> "<STR_LIT>" , policy ) <EOL> assert False <EOL> except e . InvalidRequest as exception : <EOL> assert exception . code == <NUM_LIT:4> <EOL> except Exception as exception : <EOL> assert type ( exception ) == e . InvalidRequest <EOL> def test_listindex_with_incorrect_namespace ( self ) : <EOL> """<STR_LIT>""" <EOL> policy = { } <EOL> try : <EOL> TestListIndex . client . index_list_create ( <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , aerospike . INDEX_NUMERIC , <EOL> '<STR_LIT>' , policy ) <EOL> except e . InvalidRequest as exception : <EOL> assert exception . code == <NUM_LIT:4> <EOL> def test_listindex_with_incorrect_set ( self ) : <EOL> """<STR_LIT>""" <EOL> policy = { } <EOL> retobj = TestListIndex . client . index_list_create ( <EOL> '<STR_LIT:test>' , '<STR_LIT>' , '<STR_LIT>' , aerospike . INDEX_NUMERIC , <EOL> '<STR_LIT>' , policy ) <EOL> assert retobj == <NUM_LIT:0> <EOL> TestListIndex . client . index_remove ( '<STR_LIT:test>' , '<STR_LIT>' , <EOL> policy ) <EOL> def test_listindex_with_incorrect_bin ( self ) : <EOL> """<STR_LIT>""" <EOL> policy = { } <EOL> retobj = TestListIndex . client . index_list_create ( <EOL> '<STR_LIT:test>' , '<STR_LIT>' , '<STR_LIT>' , aerospike . INDEX_STRING , <EOL> '<STR_LIT>' , policy ) <EOL> assert retobj == <NUM_LIT:0> <EOL> TestListIndex . client . index_remove ( '<STR_LIT:test>' , '<STR_LIT>' , <EOL> policy ) <EOL> def test_listindex_with_namespace_is_none ( self ) : <EOL> """<STR_LIT>""" <EOL> policy = { } <EOL> try : <EOL> TestListIndex . client . index_list_create ( <EOL> None , '<STR_LIT>' , '<STR_LIT>' , aerospike . INDEX_STRING , <EOL> '<STR_LIT>' , policy ) <EOL> except e . ParamError as exception : <EOL> assert exception . code == - <NUM_LIT:2> <EOL> assert exception . msg == '<STR_LIT>' <EOL> def test_listindex_with_set_is_int ( self ) : <EOL> """<STR_LIT>""" <EOL> policy = { } <EOL> try : <EOL> TestListIndex . client . index_list_create ( <EOL> '<STR_LIT:test>' , <NUM_LIT:1> , '<STR_LIT>' , aerospike . INDEX_STRING , <EOL> '<STR_LIT>' , policy ) <EOL> assert False <EOL> except e . ParamError as exception : <EOL> assert exception . code == - <NUM_LIT:2> <EOL> assert exception . msg == '<STR_LIT>' <EOL> except Exception as exception : <EOL> assert type ( exception ) == e . ParamError <EOL> def test_listindex_with_set_is_none ( self ) : <EOL> """<STR_LIT>""" <EOL> policy = { } <EOL> try : <EOL> TestListIndex . client . index_list_create ( <EOL> '<STR_LIT:test>' , None , '<STR_LIT>' , aerospike . INDEX_STRING , <EOL> '<STR_LIT>' , policy ) <EOL> except e . ParamError as exception : <EOL> assert exception . code == - <NUM_LIT:2> <EOL> assert exception . msg == '<STR_LIT>' <EOL> def test_listindex_with_bin_is_none ( self ) : <EOL> """<STR_LIT>""" <EOL> policy = { } <EOL> try : <EOL> TestListIndex . client . index_list_create ( <EOL> '<STR_LIT:test>' , '<STR_LIT>' , None , aerospike . INDEX_NUMERIC , <EOL> '<STR_LIT>' , policy ) <EOL> except e . ParamError as exception : <EOL> assert exception . code == - <NUM_LIT:2> <EOL> assert exception . msg == '<STR_LIT>' <EOL> def test_listindex_with_index_is_none ( self ) : <EOL> """<STR_LIT>""" <EOL> policy = { } <EOL> try : <EOL> TestListIndex . client . index_list_create ( <EOL> '<STR_LIT:test>' , '<STR_LIT>' , '<STR_LIT>' , aerospike . INDEX_STRING , <EOL> None , policy ) <EOL> except e . ParamError as exception : <EOL> assert exception . code == - <NUM_LIT:2> <EOL> assert exception . msg == '<STR_LIT>' <EOL> def test_create_same_listindex_multiple_times ( self ) : <EOL> """<STR_LIT>""" <EOL> policy = { } <EOL> retobj = TestListIndex . client . index_list_create ( <EOL> '<STR_LIT:test>' , '<STR_LIT>' , '<STR_LIT>' , aerospike . INDEX_NUMERIC , <EOL> '<STR_LIT>' , policy ) <EOL> if retobj == <NUM_LIT:0> : <EOL> retobj = TestListIndex . client . index_list_create ( <EOL> '<STR_LIT:test>' , '<STR_LIT>' , '<STR_LIT>' , aerospike . INDEX_NUMERIC , <EOL> '<STR_LIT>' , policy ) <EOL> TestListIndex . client . index_remove ( <EOL> '<STR_LIT:test>' , '<STR_LIT>' , policy ) <EOL> assert retobj == <NUM_LIT:0> <EOL> else : <EOL> assert True is False <EOL> def test_create_same_listindex_multiple_times_different_bin ( self ) : <EOL> """<STR_LIT>""" <EOL> policy = { } <EOL> retobj = TestListIndex . client . index_list_create ( <EOL> '<STR_LIT:test>' , '<STR_LIT>' , '<STR_LIT>' , aerospike . INDEX_STRING , <EOL> '<STR_LIT>' , policy ) <EOL> if retobj == <NUM_LIT:0> : <EOL> retobj = TestListIndex . client . index_list_create ( <EOL> '<STR_LIT:test>' , '<STR_LIT>' , '<STR_LIT>' , aerospike . INDEX_NUMERIC , <EOL> '<STR_LIT>' , policy ) <EOL> assert retobj == <NUM_LIT:0> <EOL> TestListIndex . client . index_remove ( '<STR_LIT:test>' , '<STR_LIT>' , <EOL> policy ) <EOL> else : <EOL> assert True is False <EOL> def test_create_different_listindex_multiple_times_same_bin ( self ) : <EOL> """<STR_LIT>""" <EOL> policy = { } <EOL> retobj = TestListIndex . client . index_list_create ( <EOL> '<STR_LIT:test>' , '<STR_LIT>' , '<STR_LIT>' , aerospike . INDEX_STRING , <EOL> '<STR_LIT>' , policy ) <EOL> if retobj == <NUM_LIT:0> : <EOL> retobj = TestListIndex . client . index_list_create ( <EOL> '<STR_LIT:test>' , '<STR_LIT>' , '<STR_LIT>' , aerospike . INDEX_STRING , <EOL> '<STR_LIT>' , policy ) <EOL> assert retobj == <NUM_LIT:0> <EOL> TestListIndex . client . index_remove ( '<STR_LIT:test>' , '<STR_LIT>' , <EOL> policy ) <EOL> TestListIndex . client . index_remove ( <EOL> '<STR_LIT:test>' , '<STR_LIT>' , policy ) <EOL> else : <EOL> assert True is False <EOL> def test_createlistindex_with_policy ( self ) : <EOL> """<STR_LIT>""" <EOL> policy = { '<STR_LIT>' : <NUM_LIT:1000> } <EOL> retobj = TestListIndex . client . index_list_create ( <EOL> '<STR_LIT:test>' , '<STR_LIT>' , '<STR_LIT>' , aerospike . INDEX_NUMERIC , <EOL> '<STR_LIT>' , policy ) <EOL> assert retobj == <NUM_LIT:0> <EOL> TestListIndex . client . index_remove ( '<STR_LIT:test>' , '<STR_LIT>' , <EOL> policy ) <EOL> def test_createlistindex_with_policystring ( self ) : <EOL> """<STR_LIT>""" <EOL> policy = { '<STR_LIT>' : <NUM_LIT:1000> } <EOL> retobj = TestListIndex . client . index_list_create ( <EOL> '<STR_LIT:test>' , '<STR_LIT>' , '<STR_LIT>' , aerospike . INDEX_STRING , <EOL> '<STR_LIT>' , policy ) <EOL> assert retobj == <NUM_LIT:0> <EOL> TestListIndex . client . index_remove ( '<STR_LIT:test>' , '<STR_LIT>' , <EOL> policy ) <EOL> """<STR_LIT>""" <EOL> def test_create_liststringindex_unicode_positive ( self ) : <EOL> """<STR_LIT>""" <EOL> policy = { } <EOL> retobj = TestListIndex . client . index_list_create ( <EOL> '<STR_LIT:test>' , u'<STR_LIT>' , u'<STR_LIT>' , aerospike . INDEX_STRING , <EOL> u'<STR_LIT>' , policy ) <EOL> assert retobj == <NUM_LIT:0> <EOL> TestListIndex . client . index_remove ( '<STR_LIT:test>' , u'<STR_LIT>' , policy ) <EOL> def test_create_list_integer_index_unicode ( self ) : <EOL> """<STR_LIT>""" <EOL> policy = { } <EOL> retobj = TestListIndex . client . index_list_create ( <EOL> '<STR_LIT:test>' , u'<STR_LIT>' , u'<STR_LIT>' , aerospike . INDEX_NUMERIC , <EOL> u'<STR_LIT>' , policy ) <EOL> assert retobj == <NUM_LIT:0> <EOL> TestListIndex . client . index_remove ( '<STR_LIT:test>' , u'<STR_LIT>' , policy ) <EOL> def test_listindex_with_correct_parameters_no_connection ( self ) : <EOL> """<STR_LIT>""" <EOL> policy = { } <EOL> config = { '<STR_LIT>' : [ ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ] } <EOL> client1 = aerospike . client ( config ) <EOL> try : <EOL> client1 . index_list_create ( <EOL> '<STR_LIT:test>' , '<STR_LIT>' , '<STR_LIT>' , aerospike . INDEX_STRING , <EOL> '<STR_LIT>' , policy ) <EOL> except e . ClusterError as exception : <EOL> assert exception . code == <NUM_LIT:11> <EOL> assert exception . msg == '<STR_LIT>' </s>
