Esempio n. 1
0
def test_check_s3_urls_other_client_error(botomock, settings):
    def mock_api_call(self, operation_name, api_params):
        assert operation_name == "HeadBucket"
        if api_params["Bucket"] == "private":
            response = {"Error": {"Code": "500", "Message": "Other"}}
            raise ClientError(response, operation_name)
        return {}

    with botomock(mock_api_call):
        with pytest.raises(ClientError):
            dockerflow_extra.check_s3_urls(None)
Esempio n. 2
0
def test_check_s3_urls_other_client_error(botomock, settings):
    def mock_api_call(self, operation_name, api_params):
        assert operation_name == 'HeadBucket'
        if api_params['Bucket'] == 'private':
            response = {'Error': {'Code': '500', 'Message': 'Other'}}
            raise ClientError(response, operation_name)
        return {}

    with botomock(mock_api_call):
        with pytest.raises(ClientError):
            dockerflow_extra.check_s3_urls(None)
Esempio n. 3
0
def test_check_s3_urls_happy_path(botomock, settings):
    def mock_api_call(self, operation_name, api_params):
        assert operation_name == "HeadBucket"
        # These come from settings.Test
        fixture_bucket_names = ("private", "mybucket", "peterbe-com")
        assert api_params["Bucket"] in fixture_bucket_names
        return {}

    with botomock(mock_api_call):
        assert not dockerflow_extra.check_s3_urls(None)
Esempio n. 4
0
def test_check_s3_urls_endpointconnectionerror(botomock, settings):
    def mock_api_call(self, operation_name, api_params):
        assert operation_name == 'HeadBucket'
        if api_params['Bucket'] == 'private':
            raise EndpointConnectionError(endpoint_url='http://s3.example.com')
        return {}

    with botomock(mock_api_call):
        errors = dockerflow_extra.check_s3_urls(None)
        assert errors
        error, = errors
        assert 'private' in error.msg
        assert 'EndpointConnectionError' in error.msg
Esempio n. 5
0
def test_check_s3_urls_endpointconnectionerror(botomock, settings):
    def mock_api_call(self, operation_name, api_params):
        assert operation_name == "HeadBucket"
        if api_params["Bucket"] == "private":
            raise EndpointConnectionError(endpoint_url="http://s3.example.com")
        return {}

    with botomock(mock_api_call):
        errors = dockerflow_extra.check_s3_urls(None)
        assert errors
        error, = errors
        assert "private" in error.msg
        assert "EndpointConnectionError" in error.msg
Esempio n. 6
0
def test_check_s3_urls_client_error(botomock, settings):
    def mock_api_call(self, operation_name, api_params):
        assert operation_name == 'HeadBucket'
        if api_params['Bucket'] == 'private':
            response = {'Error': {'Code': '404', 'Message': 'Not found'}}
            raise ClientError(response, operation_name)
        return {}

    with botomock(mock_api_call):
        errors = dockerflow_extra.check_s3_urls(None)
        assert errors
        error, = errors
        assert 'private' in error.msg
        assert 'ClientError' in error.msg
Esempio n. 7
0
def test_check_s3_urls_client_error(botomock, settings):
    def mock_api_call(self, operation_name, api_params):
        assert operation_name == "HeadBucket"
        if api_params["Bucket"] == "private":
            response = {"Error": {"Code": "404", "Message": "Not found"}}
            raise ClientError(response, operation_name)
        return {}

    with botomock(mock_api_call):
        errors = dockerflow_extra.check_s3_urls(None)
        assert errors
        error, = errors
        assert "private" in error.msg
        assert "ClientError" in error.msg