<commit_before>try:
    from http import HTTPStatus
except ImportError:
    # noinspection PyUnresolvedReferences
    from httpstatus import HTTPStatus

import pytest
import requests

from cloudstorage.drivers.google import GoogleStorageDriver
from cloudstorage.exceptions import (CloudStorageError, IsNotEmptyError,
                                     NotFoundError)
from cloudstorage.helpers import file_checksum
from tests.helpers import random_container_name, uri_validator
from tests.settings import *

pytestmark = pytest.mark.skipif(not bool(GOOGLE_CREDENTIALS),
                                reason='settings missing key and secret')


@pytest.fixture(scope='module')
def storage():
    driver = GoogleStorageDriver(key=GOOGLE_CREDENTIALS)

    yield driver

    for container in driver:  # cleanup
        if container.name.startswith(CONTAINER_PREFIX):
            for blob in container:
                blob.delete()

            container.delete()


# noinspection PyShadowingNames
def test_driver_create_container(storage):
    container_name = random_container_name()
    container = storage.create_container(container_name)
    assert container_name in storage
    assert container.name == container_name


# noinspection PyShadowingNames
def test_driver_create_container_invalid_name(storage):<commit_msg>Add delay to google driver tests due to rate limiting on backend.<commit_after>try:
    from http import HTTPStatus
except ImportError:
    # noinspection PyUnresolvedReferences
    from httpstatus import HTTPStatus

from threading import Timer

import pytest
import random
import requests

from cloudstorage.drivers.google import GoogleStorageDriver
from cloudstorage.exceptions import CloudStorageError
from cloudstorage.exceptions import IsNotEmptyError
from cloudstorage.exceptions import NotFoundError
from cloudstorage.helpers import file_checksum
from tests.helpers import random_container_name, uri_validator
from tests.settings import *

pytestmark = pytest.mark.skipif(not bool(GOOGLE_CREDENTIALS),
                                reason='settings missing key and secret')


@pytest.fixture(scope='function', autouse=True)
def delay(request):
    # Prevent google.api.core.exceptions.TooManyRequests
    seconds = random.random()
    t = Timer(seconds, request)
    t.start()


@pytest.fixture(scope='module')
def storage():
    driver = GoogleStorageDriver(key=GOOGLE_CREDENTIALS)

    yield driver

    for container in driver:  # cleanup
        if container.name.startswith(CONTAINER_PREFIX):
            for blob in container:
                blob.delete()

            container.delete()


# noinspection PyShadowingNames
def test_driver_create_container(storage):
    container_name = random_container_name()
    container = storage.create_container(container_name)
    assert container_name in storage
    assert container.name == container_name


# noinspection PyShadowingNames
def test_driver_create_container_invalid_name(storage):
{'fraction_non_alphanumeric': 0.05945582801477998, 'fraction_numerical': 0.0, 'mean_word_length': 4.038917089678511, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1979205', 'n_tokens_mistral': 792, 'n_tokens_neox': 775, 'n_words': 206}