<s> from simplekv . _compat import BytesIO <EOL> from simplekv . memory import DictStore <EOL> from simplekv . decorator import PrefixDecorator <EOL> import pytest <EOL> from basic_store import BasicStore <EOL> class TestPrefixDecorator ( BasicStore ) : <EOL> @ pytest . fixture ( params = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] ) <EOL> def prefix ( self , request ) : <EOL> return request . param <EOL> @ pytest . fixture ( params = [ '<STR_LIT>' , '<STR_LIT>' , ] ) <EOL> def prefix2 ( self , request ) : <EOL> return request . param <EOL> @ pytest . fixture ( params = [ True , False ] ) <EOL> def store ( self , request , prefix ) : <EOL> base_store = DictStore ( ) <EOL> if request . param : <EOL> base_store . put ( '<STR_LIT>' , b'<STR_LIT>' ) <EOL> base_store . put ( '<STR_LIT>' , b'<STR_LIT>' ) <EOL> base_store . put ( '<STR_LIT>' , b'<STR_LIT>' ) <EOL> base_store . put ( '<STR_LIT:test>' , b'<STR_LIT>' ) <EOL> return PrefixDecorator ( prefix , base_store ) <EOL> def test_put_returns_correct_key ( self , store , prefix , key , value ) : <EOL> assert key == store . put ( key , value ) <EOL> def test_put_sets_prefix ( self , store , prefix , key , value ) : <EOL> full_key = prefix + key <EOL> key == store . put ( key , value ) <EOL> assert store . _dstore . get ( full_key ) == value <EOL> def test_put_file_returns_correct_key ( self , store , prefix , key , value ) : <EOL> assert key == store . put_file ( key , BytesIO ( value ) ) <EOL> def test_put_file_sets_prefix ( self , store , prefix , key , value ) : <EOL> full_key = prefix + key <EOL> key == store . put_file ( key , BytesIO ( value ) ) <EOL> assert store . _dstore . get ( full_key ) == value <EOL> def test_multiple_prefixes_one_store ( self , store , prefix , prefix2 , key , <EOL> value ) : <EOL> base_store = store . _dstore <EOL> store2 = PrefixDecorator ( prefix2 , base_store ) <EOL> pv = value + prefix . encode ( '<STR_LIT:ascii>' ) <EOL> pv2 = value + prefix2 . encode ( '<STR_LIT:ascii>' ) <EOL> store . put ( key , pv ) <EOL> store2 . put ( key , pv2 ) <EOL> assert key in store <EOL> assert key in store2 <EOL> assert prefix + key in base_store <EOL> assert prefix2 + key in base_store <EOL> assert len ( store . keys ( ) ) == <NUM_LIT:1> <EOL> assert len ( store2 . keys ( ) ) == <NUM_LIT:1> <EOL> assert store . get ( key ) == pv <EOL> assert store2 . get ( key ) == pv2 </s>
