<s> from tests . base import SingleMemberTestCase <EOL> from tests . util import random_string <EOL> class TransactionalMultiMapTest ( SingleMemberTestCase ) : <EOL> def setUp ( self ) : <EOL> self . multi_map = self . client . get_multi_map ( random_string ( ) ) . blocking ( ) <EOL> def test_put ( self ) : <EOL> with self . client . new_transaction ( ) as tx : <EOL> tx_multi_map = tx . get_multi_map ( self . multi_map . name ) <EOL> self . assertTrue ( tx_multi_map . put ( "<STR_LIT:key>" , "<STR_LIT>" ) ) <EOL> self . assertTrue ( tx_multi_map . put ( "<STR_LIT:key>" , "<STR_LIT>" ) ) <EOL> self . assertItemsEqual ( self . multi_map . get ( "<STR_LIT:key>" ) , [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> def test_put_when_present ( self ) : <EOL> self . multi_map . put ( "<STR_LIT:key>" , "<STR_LIT>" ) <EOL> with self . client . new_transaction ( ) as tx : <EOL> tx_multi_map = tx . get_multi_map ( self . multi_map . name ) <EOL> self . assertFalse ( tx_multi_map . put ( "<STR_LIT:key>" , "<STR_LIT>" ) ) <EOL> self . assertItemsEqual ( self . multi_map . get ( "<STR_LIT:key>" ) , [ "<STR_LIT>" ] ) <EOL> def test_get ( self ) : <EOL> self . multi_map . put ( "<STR_LIT:key>" , "<STR_LIT>" ) <EOL> self . multi_map . put ( "<STR_LIT:key>" , "<STR_LIT>" ) <EOL> with self . client . new_transaction ( ) as tx : <EOL> tx_multi_map = tx . get_multi_map ( self . multi_map . name ) <EOL> self . assertItemsEqual ( tx_multi_map . get ( "<STR_LIT:key>" ) , [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> def test_get_when_missing ( self ) : <EOL> with self . client . new_transaction ( ) as tx : <EOL> tx_multi_map = tx . get_multi_map ( self . multi_map . name ) <EOL> self . assertEqual ( tx_multi_map . get ( "<STR_LIT:key>" ) , [ ] ) <EOL> def test_size ( self ) : <EOL> self . multi_map . put ( "<STR_LIT:key>" , "<STR_LIT>" ) <EOL> self . multi_map . put ( "<STR_LIT:key>" , "<STR_LIT>" ) <EOL> self . multi_map . put ( "<STR_LIT:key>" , "<STR_LIT>" ) <EOL> with self . client . new_transaction ( ) as tx : <EOL> tx_multi_map = tx . get_multi_map ( self . multi_map . name ) <EOL> self . assertTrue ( tx_multi_map . size ( ) , <NUM_LIT:3> ) <EOL> def test_remove_all ( self ) : <EOL> self . multi_map . put ( "<STR_LIT:key>" , "<STR_LIT>" ) <EOL> self . multi_map . put ( "<STR_LIT:key>" , "<STR_LIT>" ) <EOL> with self . client . new_transaction ( ) as tx : <EOL> tx_multi_map = tx . get_multi_map ( self . multi_map . name ) <EOL> self . assertItemsEqual ( [ "<STR_LIT>" , "<STR_LIT>" ] , tx_multi_map . remove_all ( "<STR_LIT:key>" ) ) <EOL> self . assertFalse ( self . multi_map . contains_key ( "<STR_LIT:key>" ) ) <EOL> def test_remove_all_when_missing ( self ) : <EOL> with self . client . new_transaction ( ) as tx : <EOL> tx_multi_map = tx . get_multi_map ( self . multi_map . name ) <EOL> self . assertEqual ( [ ] , tx_multi_map . remove_all ( "<STR_LIT:key>" ) ) <EOL> def test_remove_when_same ( self ) : <EOL> self . multi_map . put ( "<STR_LIT:key>" , "<STR_LIT>" ) <EOL> self . multi_map . put ( "<STR_LIT:key>" , "<STR_LIT>" ) <EOL> with self . client . new_transaction ( ) as tx : <EOL> tx_multi_map = tx . get_multi_map ( self . multi_map . name ) <EOL> self . assertTrue ( tx_multi_map . remove ( "<STR_LIT:key>" , "<STR_LIT>" ) ) <EOL> self . assertItemsEqual ( [ "<STR_LIT>" ] , self . multi_map . get ( "<STR_LIT:key>" ) ) <EOL> def test_remove_when_different ( self ) : <EOL> self . multi_map . put ( "<STR_LIT:key>" , "<STR_LIT>" ) <EOL> self . multi_map . put ( "<STR_LIT:key>" , "<STR_LIT>" ) <EOL> with self . client . new_transaction ( ) as tx : <EOL> tx_multi_map = tx . get_multi_map ( self . multi_map . name ) <EOL> self . assertFalse ( tx_multi_map . remove ( "<STR_LIT:key>" , "<STR_LIT>" ) ) <EOL> self . assertItemsEqual ( [ "<STR_LIT>" , "<STR_LIT>" ] , self . multi_map . get ( "<STR_LIT:key>" ) ) <EOL> def test_value_count ( self ) : <EOL> self . multi_map . put ( "<STR_LIT:key>" , "<STR_LIT>" ) <EOL> self . multi_map . put ( "<STR_LIT:key>" , "<STR_LIT>" ) <EOL> self . multi_map . put ( "<STR_LIT:key>" , "<STR_LIT>" ) <EOL> with self . client . new_transaction ( ) as tx : <EOL> tx_multi_map = tx . get_multi_map ( self . multi_map . name ) <EOL> self . assertEqual ( tx_multi_map . value_count ( "<STR_LIT:key>" ) , <NUM_LIT:3> ) <EOL> def test_str ( self ) : <EOL> with self . client . new_transaction ( ) as tx : <EOL> tx_multi_map = tx . get_multi_map ( self . multi_map . name ) <EOL> self . assertTrue ( str ( tx_multi_map ) . startswith ( "<STR_LIT>" ) ) </s>
