def test_get_lifecycle_policy(): """ Check whether GET lifecycle_policy API call returns 404 since no lifecycle_policy is set """ client = get_S3client() error = raise_assertError(ClientError, client.get_bucket_lifecycle_configuration, Bucket=config('BUCKET_NAME')) assert get_response_status(error.response) == 404
def test_get_bucket_policy(): """ Check whether GET bucket_policy API call returns 404 since no bucket_policy is set """ bucket = helpers.get_bucket() error = helpers.raise_assertError(S3ResponseError, bucket.get_policy) error_response = helpers.get_err_response_status(error) assert error_response[0] == 404 assert error_response[1] == 'NoSuchBucketPolicy'
def test_get_website_configuration(): """ Check whether GET website_configuration API call returns 404 since no website_configuration is set """ client = get_S3client() error = raise_assertError(ClientError, client.get_bucket_website, Bucket=config('BUCKET_NAME')) assert get_response_status(error.response) == 404
def test_get_cors(): """ Check whether GET CORS API call returns 404 since no CORS Rule is set """ bucket = helpers.get_bucket() error = helpers.raise_assertError(S3ResponseError, bucket.get_cors) # assert error.error_code == 'NoSuchCORSConfiguration' error_response = helpers.get_err_response_status(error) assert error_response[0] == 404 assert error_response[1] == 'NoSuchCORSConfiguration'
def test_get_website_configuration(): """ Check whether GET website_configuration API call returns 404 since no website_configuration is set """ bucket = helpers.get_bucket() error = helpers.raise_assertError(S3ResponseError, bucket.get_website_configuration) error_response = helpers.get_err_response_status(error) assert error_response[0] == 404 assert error_response[1] == 'NoSuchWebsiteConfiguration'
def test_get_cors(): """ Check whether GET CORS API call returns 404 since no CORS Rule is set """ client = get_S3client() # GET CORS before setting CORS Rules should raise error error = raise_assertError(ClientError, client.get_bucket_cors, Bucket=config('BUCKET_NAME')) assert get_response_status(error.response) == 404
def test_get_lifecycle_policy(): """ Check whether GET lifecycle_policy API call returns 404 since no lifecycle_policy is set """ bucket = helpers.get_bucket() error = helpers.raise_assertError(S3ResponseError, bucket.get_lifecycle_config) # assert error.error_code == 'NoSuchCORSConfiguration' error_response = helpers.get_err_response_status(error) assert error_response[0] == 404 assert error_response[1] == 'NoSuchLifecycleConfiguration'
def test_download_file_missing(): """ Tries to download file gsoc-test.txt which isn't yet uploaded,hence gets 404 """ client = get_S3client() error = raise_assertError(ClientError, client.download_file, Bucket=config('BUCKET_NAME'), Key='gsoc-test.txt', Filename='gsoc-test.txt') assert get_response_status(error.response) == 404
def test_get_file_missing_from_key(): """ Tries to download file gsoc-test.txt which isn't yet uploaded,hence gets 404 """ bucket = helpers.get_bucket() k = Key(bucket=bucket) k.key = 'gsoc-test.txt' error = helpers.raise_assertError(S3ResponseError, k.get_contents_as_string) error_response = helpers.get_err_response_status(error) assert error_response[0] == 404 assert error_response[1] == 'NoSuchKey'
def test_delete_bucket_policy(): """ Deletes bucket_policy and then checks whether GET bucket_policy API call returns 404 """ client = get_S3client() client.delete_bucket_policy(Bucket=config('BUCKET_NAME')) error = raise_assertError(ClientError, client.get_bucket_policy, Bucket=config('BUCKET_NAME')) assert get_response_status(error.response) == 404
def test_delete_cors(): """ Deletes CORS Rules and then checks whether GET CORS API call returns 404 """ client = get_S3client() client.delete_bucket_cors(Bucket=config('BUCKET_NAME')) error = raise_assertError(ClientError, client.get_bucket_cors, Bucket=config('BUCKET_NAME')) assert get_response_status(error.response) == 404
def test_delete_website_configuration(): """ Deletes website_configuration and then checks whether GET website_configuration API call returns 404 """ client = get_S3client() client.delete_bucket_website(Bucket=config('BUCKET_NAME')) error = raise_assertError(ClientError, client.get_bucket_website, Bucket=config('BUCKET_NAME')) assert get_response_status(error.response) == 404
def test_delete_file_uploaded(): """ Deletes uploaded file gsoc-test.txt and checks whether response StatusCode is 204 """ bucket = helpers.get_bucket() k = Key(bucket=bucket) k.key = 'gsoc-test.txt' k.delete() error = helpers.raise_assertError(S3ResponseError, k.get_contents_as_string) error_response = helpers.get_err_response_status(error) assert error_response[0] == 404 assert error_response[1] == 'NoSuchKey'