<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> try : <EOL> from collections import Counter <EOL> except ImportError : <EOL> from counter26 import Counter <EOL> class TestExistsMany ( TestBaseClass ) : <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> TestExistsMany . client = aerospike . client ( config ) . connect ( ) <EOL> else : <EOL> TestExistsMany . client = aerospike . client ( config ) . connect ( user , <EOL> password ) <EOL> def teardown_class ( cls ) : <EOL> TestExistsMany . client . close ( ) <EOL> def setup_method ( self , method ) : <EOL> self . keys = [ ] <EOL> for i in range ( <NUM_LIT:5> ) : <EOL> key = ( '<STR_LIT:test>' , '<STR_LIT>' , i ) <EOL> rec = { '<STR_LIT:name>' : '<STR_LIT>' % ( str ( i ) ) , '<STR_LIT>' : i } <EOL> TestExistsMany . client . put ( key , rec ) <EOL> self . keys . append ( key ) <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> TestExistsMany . client . remove ( key ) <EOL> def test_exists_many_without_any_parameter ( self ) : <EOL> with pytest . raises ( TypeError ) as typeError : <EOL> TestExistsMany . client . exists_many ( ) <EOL> assert "<STR_LIT>" in str ( <EOL> typeError . value ) <EOL> def test_exists_many_without_policy ( self ) : <EOL> records = TestExistsMany . client . exists_many ( self . keys ) <EOL> assert type ( records ) == list <EOL> assert len ( records ) == <NUM_LIT:5> <EOL> def test_exists_many_with_proper_parameters ( self ) : <EOL> records = TestExistsMany . client . exists_many ( <EOL> self . keys , { '<STR_LIT>' : <NUM_LIT> } ) <EOL> assert type ( records ) == list <EOL> assert len ( records ) == <NUM_LIT:5> <EOL> assert Counter ( [ x [ <NUM_LIT:0> ] [ <NUM_LIT:2> ] for x in records ] ) == Counter ( <EOL> [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] ) <EOL> def test_exists_many_with_none_policy ( self ) : <EOL> records = TestExistsMany . client . exists_many ( self . keys , None ) <EOL> assert type ( records ) == list <EOL> assert len ( records ) == <NUM_LIT:5> <EOL> assert Counter ( [ x [ <NUM_LIT:0> ] [ <NUM_LIT:2> ] for x in records ] ) == Counter ( <EOL> [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] ) <EOL> def test_exists_many_with_none_keys ( self ) : <EOL> try : <EOL> TestExistsMany . client . exists_many ( None , { } ) <EOL> except e . ParamError as exception : <EOL> assert exception . code == - <NUM_LIT:2> <EOL> assert exception . msg == "<STR_LIT>" <EOL> def test_exists_many_with_non_existent_keys ( self ) : <EOL> self . keys . append ( ( '<STR_LIT:test>' , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> records = TestExistsMany . client . exists_many ( self . keys ) <EOL> assert type ( records ) == list <EOL> assert len ( records ) == <NUM_LIT:6> <EOL> assert Counter ( [ x [ <NUM_LIT:0> ] [ <NUM_LIT:2> ] for x in records ] ) == Counter ( <EOL> [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , '<STR_LIT>' ] ) <EOL> for x in records : <EOL> if x [ <NUM_LIT:0> ] [ <NUM_LIT:2> ] == '<STR_LIT>' : <EOL> assert x [ <NUM_LIT:1> ] == None <EOL> def test_exists_many_with_all_non_existent_keys ( self ) : <EOL> keys = [ ( '<STR_LIT:test>' , '<STR_LIT>' , '<STR_LIT:key>' ) ] <EOL> records = TestExistsMany . client . exists_many ( keys ) <EOL> assert len ( records ) == <NUM_LIT:1> <EOL> for x in records : <EOL> if x [ <NUM_LIT:0> ] [ <NUM_LIT:2> ] == '<STR_LIT:key>' : <EOL> assert x [ <NUM_LIT:1> ] == None <EOL> def test_exists_many_with_invalid_key ( self ) : <EOL> try : <EOL> TestExistsMany . client . exists_many ( "<STR_LIT:key>" ) <EOL> except e . ParamError as exception : <EOL> assert exception . code == - <NUM_LIT:2> <EOL> assert exception . msg == "<STR_LIT>" <EOL> def test_exists_many_with_invalid_timeout ( self ) : <EOL> policies = { '<STR_LIT>' : <NUM_LIT> } <EOL> try : <EOL> TestExistsMany . client . exists_many ( self . keys , policies ) <EOL> except e . ParamError as exception : <EOL> assert exception . code == - <NUM_LIT:2> <EOL> assert exception . msg == "<STR_LIT>" <EOL> def test_exists_many_with_initkey_as_digest ( self ) : <EOL> keys = [ ] <EOL> key = ( "<STR_LIT:test>" , "<STR_LIT>" , None , bytearray ( <EOL> "<STR_LIT>" , "<STR_LIT:utf-8>" ) ) <EOL> rec = { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT:1> } <EOL> TestExistsMany . client . put ( key , rec ) <EOL> keys . append ( key ) <EOL> key = ( "<STR_LIT:test>" , "<STR_LIT>" , None , bytearray ( <EOL> "<STR_LIT>" , "<STR_LIT:utf-8>" ) ) <EOL> rec = { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT:2> } <EOL> TestExistsMany . client . put ( key , rec ) <EOL> keys . append ( key ) <EOL> records = TestExistsMany . client . exists_many ( keys ) <EOL> for key in keys : <EOL> TestExistsMany . client . remove ( key ) <EOL> assert type ( records ) == list <EOL> assert len ( records ) == <NUM_LIT:2> <EOL> i = <NUM_LIT:0> <EOL> for x in records : <EOL> if i : <EOL> assert x [ <NUM_LIT:0> ] [ <NUM_LIT:3> ] == bytearray ( b"<STR_LIT>" ) <EOL> else : <EOL> assert x [ <NUM_LIT:0> ] [ <NUM_LIT:3> ] == bytearray ( b"<STR_LIT>" ) <EOL> i += <NUM_LIT:1> <EOL> def test_exists_many_with_non_existent_keys_in_middle ( self ) : <EOL> self . keys . append ( ( '<STR_LIT:test>' , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> for i in range ( <NUM_LIT:15> , <NUM_LIT:20> ) : <EOL> key = ( '<STR_LIT:test>' , '<STR_LIT>' , i ) <EOL> rec = { '<STR_LIT:name>' : '<STR_LIT>' % ( str ( i ) ) , '<STR_LIT>' : i } <EOL> TestExistsMany . client . put ( key , rec ) <EOL> self . keys . append ( key ) <EOL> records = TestExistsMany . client . exists_many ( self . keys ) <EOL> for i in range ( <NUM_LIT:15> , <NUM_LIT:20> ) : <EOL> key = ( '<STR_LIT:test>' , '<STR_LIT>' , i ) <EOL> TestExistsMany . client . remove ( key ) <EOL> assert type ( records ) == list <EOL> assert len ( records ) == <NUM_LIT:11> <EOL> assert Counter ( [ x [ <NUM_LIT:0> ] [ <NUM_LIT:2> ] for x in records ] ) == Counter ( <EOL> [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , '<STR_LIT>' , <NUM_LIT:15> , <NUM_LIT:16> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> for x in records : <EOL> if x [ <NUM_LIT:0> ] [ <NUM_LIT:2> ] == '<STR_LIT>' : <EOL> assert x [ <NUM_LIT:1> ] == None <EOL> def test_exists_many_with_proper_parameters_without_connection ( self ) : <EOL> config = { '<STR_LIT>' : [ ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ] } <EOL> client1 = aerospike . client ( config ) <EOL> try : <EOL> client1 . exists_many ( self . keys , { '<STR_LIT>' : <NUM_LIT:20> } ) <EOL> except e . ClusterError as exception : <EOL> assert exception . code == <NUM_LIT:11> <EOL> assert exception . msg == '<STR_LIT>' </s>
