Beispiel #1
0
def test_swift_session_class():
    """SwiftSession works"""
    swift_session = SwiftSession(
        swift_storage_url='foo',
        swift_auth_token='bar',)
    assert swift_session._creds
    assert swift_session.get_credential_options()['SWIFT_STORAGE_URL'] == 'foo'
    assert swift_session.get_credential_options()['SWIFT_AUTH_TOKEN'] == 'bar'
Beispiel #2
0
def test_swift_session_class():
    """SwiftSession works"""
    swift_session = SwiftSession(
        swift_storage_url='foo',
        swift_auth_token='bar',)
    assert swift_session._creds
    assert swift_session.get_credential_options()['SWIFT_STORAGE_URL'] == 'foo'
    assert swift_session.get_credential_options()['SWIFT_AUTH_TOKEN'] == 'bar'
Beispiel #3
0
def test_swift_session_by_user_key():
    def mock_init(self, session=None, 
                swift_storage_url=None, swift_auth_token=None, 
                swift_auth_v1_url=None, swift_user=None, swift_key=None):
        self._creds = {'SWIFT_STORAGE_URL':'foo',
                       'SWIFT_AUTH_TOKEN':'bar'}
    with mock.patch('rasterio.session.SwiftSession.__init__', new=mock_init):
        swift_session = SwiftSession(
            swift_auth_v1_url='foo',
            swift_user='******',
            swift_key='key')
        assert swift_session._creds
        assert swift_session.get_credential_options()['SWIFT_STORAGE_URL'] == 'foo'
        assert swift_session.get_credential_options()['SWIFT_AUTH_TOKEN'] == 'bar'
Beispiel #4
0
def test_swift_session_by_user_key():
    def mock_init(self, session=None, 
                swift_storage_url=None, swift_auth_token=None, 
                swift_auth_v1_url=None, swift_user=None, swift_key=None):
        self._creds = {'SWIFT_STORAGE_URL':'foo',
                       'SWIFT_AUTH_TOKEN':'bar'}
    with mock.patch('rasterio.session.SwiftSession.__init__', new=mock_init):
        swift_session = SwiftSession(
            swift_auth_v1_url='foo',
            swift_user='******',
            swift_key='key')
        assert swift_session._creds
        assert swift_session.get_credential_options()['SWIFT_STORAGE_URL'] == 'foo'
        assert swift_session.get_credential_options()['SWIFT_AUTH_TOKEN'] == 'bar'
Beispiel #5
0
def test_swift_session_credentials(gdalenv):
    """Create an Env with a oss session."""
    swift_session = SwiftSession(swift_storage_url='foo',
                                 swift_auth_token='bar')
    with rasterio.env.Env(session=swift_session) as s:
        s.credentialize()
        assert getenv()['SWIFT_STORAGE_URL'] == 'foo'
        assert getenv()['SWIFT_AUTH_TOKEN'] == 'bar'