<s> import pytest <EOL> import sys <EOL> import random <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 TestListExtend ( 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> TestListExtend . client = aerospike . client ( config ) . connect ( ) <EOL> else : <EOL> TestListExtend . client = aerospike . client ( <EOL> config ) . connect ( user , password ) <EOL> def teardown_class ( cls ) : <EOL> TestListExtend . client . close ( ) <EOL> def setup_method ( self , method ) : <EOL> for i in range ( <NUM_LIT:5> ) : <EOL> key = ( '<STR_LIT:test>' , '<STR_LIT>' , i ) <EOL> rec = { '<STR_LIT:name>' : '<STR_LIT>' % <EOL> ( str ( i ) ) , '<STR_LIT>' : [ i , i + <NUM_LIT:1> ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] } <EOL> TestListExtend . 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>' , '<STR_LIT>' , i ) <EOL> TestListExtend . client . remove ( key ) <EOL> def test_list_extend_with_list_of_integers ( self ) : <EOL> """<STR_LIT>""" <EOL> key = ( '<STR_LIT:test>' , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> TestListExtend . client . list_extend ( key , "<STR_LIT>" , [ <NUM_LIT:12> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> ( key , _ , bins ) = TestListExtend . client . get ( key ) <EOL> assert bins == { <EOL> '<STR_LIT>' : [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:12> , <NUM_LIT> , <NUM_LIT> ] , '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] } <EOL> def test_list_extend_with_policy ( self ) : <EOL> """<STR_LIT>""" <EOL> key = ( '<STR_LIT:test>' , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> policy = { <EOL> '<STR_LIT>' : <NUM_LIT:1000> , <EOL> '<STR_LIT>' : aerospike . POLICY_RETRY_ONCE , <EOL> '<STR_LIT>' : aerospike . POLICY_COMMIT_LEVEL_MASTER <EOL> } <EOL> TestListExtend . client . list_extend ( <EOL> key , "<STR_LIT>" , [ <NUM_LIT:12> , <NUM_LIT> , <NUM_LIT> ] , { } , policy ) <EOL> ( key , _ , bins ) = TestListExtend . client . get ( key ) <EOL> assert bins == { <EOL> '<STR_LIT>' : [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:12> , <NUM_LIT> , <NUM_LIT> ] , '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] } <EOL> def test_list_extend_with_floats ( self ) : <EOL> """<STR_LIT>""" <EOL> key = ( '<STR_LIT:test>' , '<STR_LIT>' , <NUM_LIT:2> ) <EOL> TestListExtend . client . list_extend ( key , "<STR_LIT>" , [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> ( key , _ , bins ) = TestListExtend . client . get ( key ) <EOL> assert bins == { <EOL> '<STR_LIT>' : [ <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT> , <NUM_LIT> ] , '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT:name>' : '<STR_LIT>' } <EOL> def test_list_extend_with_all_entries ( self ) : <EOL> """<STR_LIT>""" <EOL> key = ( '<STR_LIT:test>' , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> TestListExtend . client . list_extend ( <EOL> key , "<STR_LIT>" , [ False , [ <NUM_LIT> , <NUM_LIT> ] , <NUM_LIT> , <NUM_LIT> , '<STR_LIT>' ] ) <EOL> ( key , _ , bins ) = TestListExtend . client . get ( key ) <EOL> assert bins == { '<STR_LIT>' : [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:0> , [ <NUM_LIT> , <NUM_LIT> ] , <NUM_LIT> , <NUM_LIT> , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , '<STR_LIT:name>' : '<STR_LIT>' } <EOL> def test_list_extend_with_nonexistent_key ( self ) : <EOL> """<STR_LIT>""" <EOL> charSet = '<STR_LIT>' <EOL> minLength = <NUM_LIT:5> <EOL> maxLength = <NUM_LIT:30> <EOL> length = random . randint ( minLength , maxLength ) <EOL> key = ( '<STR_LIT:test>' , '<STR_LIT>' , '<STR_LIT>' . join ( map ( lambda unused : <EOL> random . choice ( charSet ) , <EOL> range ( length ) ) ) + "<STR_LIT>" ) <EOL> status = TestListExtend . client . list_extend ( key , "<STR_LIT:abc>" , [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> assert status == <NUM_LIT:0> <EOL> ( key , _ , bins ) = TestListExtend . client . get ( key ) <EOL> assert status == <NUM_LIT:0> <EOL> assert bins == { '<STR_LIT:abc>' : [ <NUM_LIT> , <NUM_LIT> ] } <EOL> TestListExtend . client . remove ( key ) <EOL> def test_list_extend_with_nonexistent_bin ( self ) : <EOL> """<STR_LIT>""" <EOL> key = ( '<STR_LIT:test>' , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> charSet = '<STR_LIT>' <EOL> minLength = <NUM_LIT:5> <EOL> maxLength = <NUM_LIT:10> <EOL> length = random . randint ( minLength , maxLength ) <EOL> bin = '<STR_LIT>' . join ( map ( lambda unused : <EOL> random . choice ( charSet ) , range ( length ) ) ) + "<STR_LIT>" <EOL> status = TestListExtend . client . list_extend ( key , bin , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> assert status == <NUM_LIT:0> <EOL> ( key , _ , bins ) = TestListExtend . client . get ( key ) <EOL> assert status == <NUM_LIT:0> <EOL> assert bins == { '<STR_LIT>' : [ <NUM_LIT:1> , <NUM_LIT:2> ] , '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , bin : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] } <EOL> def test_list_extend_with_no_parameters ( self ) : <EOL> """<STR_LIT>""" <EOL> with pytest . raises ( TypeError ) as typeError : <EOL> TestListExtend . client . list_extend ( ) <EOL> assert "<STR_LIT>" in str ( <EOL> typeError . value ) <EOL> def test_list_extend_with_incorrect_policy ( self ) : <EOL> """<STR_LIT>""" <EOL> key = ( '<STR_LIT:test>' , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> policy = { <EOL> '<STR_LIT>' : <NUM_LIT:0.5> <EOL> } <EOL> try : <EOL> TestListExtend . client . list_extend ( <EOL> key , "<STR_LIT>" , [ "<STR_LIT:str>" ] , { } , policy ) <EOL> except e . ParamError as exception : <EOL> assert exception . code == - <NUM_LIT:2> <EOL> assert exception . msg == "<STR_LIT>" <EOL> def test_list_extend_with_extra_parameter ( self ) : <EOL> """<STR_LIT>""" <EOL> key = ( '<STR_LIT:test>' , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> policy = { '<STR_LIT>' : <NUM_LIT:1000> } <EOL> with pytest . raises ( TypeError ) as typeError : <EOL> TestListExtend . client . list_extend ( <EOL> key , "<STR_LIT>" , [ <NUM_LIT> ] , { } , policy , "<STR_LIT>" ) <EOL> assert "<STR_LIT>" in str ( <EOL> typeError . value ) <EOL> def test_list_extend_policy_is_string ( self ) : <EOL> """<STR_LIT>""" <EOL> key = ( '<STR_LIT:test>' , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> try : <EOL> TestListExtend . client . list_extend ( key , "<STR_LIT>" , [ <NUM_LIT> ] , { } , "<STR_LIT>" ) <EOL> except e . ParamError as exception : <EOL> assert exception . code == - <NUM_LIT:2> <EOL> assert exception . msg == "<STR_LIT>" <EOL> def test_list_extend_key_is_none ( self ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> TestListExtend . client . list_extend ( None , "<STR_LIT>" , [ <NUM_LIT> ] ) <EOL> except e . ParamError as exception : <EOL> assert exception . code == - <NUM_LIT:2> <EOL> assert exception . msg == "<STR_LIT>" <EOL> def test_list_extend_bin_is_none ( self ) : <EOL> """<STR_LIT>""" <EOL> key = ( '<STR_LIT:test>' , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> try : <EOL> TestListExtend . client . list_extend ( key , None , [ "<STR_LIT:str>" ] ) <EOL> except e . ParamError as exception : <EOL> assert exception . code == - <NUM_LIT:2> <EOL> assert exception . msg == "<STR_LIT>" <EOL> def test_list_extend_with_string_instead_of_list ( self ) : <EOL> """<STR_LIT>""" <EOL> key = ( '<STR_LIT:test>' , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> try : <EOL> TestListExtend . client . list_extend ( key , "<STR_LIT>" , "<STR_LIT:str>" ) <EOL> except e . ParamError as exception : <EOL> assert exception . code == - <NUM_LIT:2> <EOL> assert exception . msg == "<STR_LIT>" <EOL> def test_list_extend_meta_type_integer ( self ) : <EOL> """<STR_LIT>""" <EOL> key = ( '<STR_LIT:test>' , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> try : <EOL> TestListExtend . client . list_extend ( key , "<STR_LIT>" , [ <NUM_LIT> ] , <NUM_LIT> ) <EOL> except e . ParamError as exception : <EOL> assert exception . code == - <NUM_LIT:2> <EOL> assert exception . msg == "<STR_LIT>" </s>
