<s> import pytest <EOL> import boto <EOL> import boto . provider <EOL> from boto import utils <EOL> from wal_e . blobstore . s3 import s3_credentials <EOL> META_DATA_CREDENTIALS = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : None , <EOL> "<STR_LIT>" : None , <EOL> "<STR_LIT>" : None , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } <EOL> def boto_flat_metadata ( ) : <EOL> return tuple ( int ( x ) for x in boto . __version__ . split ( '<STR_LIT:.>' ) ) >= ( <NUM_LIT:2> , <NUM_LIT:9> , <NUM_LIT:0> ) <EOL> @ pytest . fixture ( ) <EOL> def metadata ( monkeypatch ) : <EOL> m = dict ( ** META_DATA_CREDENTIALS ) <EOL> m [ '<STR_LIT>' ] = '<STR_LIT:foo>' <EOL> m [ '<STR_LIT>' ] = '<STR_LIT:bar>' <EOL> m [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> monkeypatch . setattr ( boto . provider . Provider , <EOL> '<STR_LIT>' , <EOL> lambda self : False ) <EOL> if boto_flat_metadata ( ) : <EOL> m = { '<STR_LIT>' : m } <EOL> else : <EOL> m = { '<STR_LIT>' : { '<STR_LIT>' : { '<STR_LIT>' : m } } } <EOL> monkeypatch . setattr ( utils , '<STR_LIT>' , <EOL> lambda * args , ** kwargs : m ) <EOL> def test_profile_provider ( metadata ) : <EOL> ipp = s3_credentials . InstanceProfileCredentials ( ) <EOL> assert ipp . get_access_key ( ) == '<STR_LIT:foo>' <EOL> assert ipp . get_secret_key ( ) == '<STR_LIT:bar>' <EOL> assert ipp . get_security_token ( ) == '<STR_LIT>' </s>
