import errno
import os.path

from requests.exceptions import HTTPError
import cloudinary.uploader
from django.test import SimpleTestCase, override_settings
from django.core.files.base import ContentFile
from django.conf import settings

from cloudinary_storage.storage import (MediaCloudinaryStorage, ManifestCloudinaryStorage, StaticCloudinaryStorage,
                                        StaticHashedCloudinaryStorage, RESOURCE_TYPES)
from cloudinary_storage import app_settings
from tests.tests.test_helpers import get_random_name, import_mock

mock = import_mock()

TAG = get_random_name()


class CloudinaryMediaStorageTests(SimpleTestCase):
    @classmethod
    def setUpClass(cls):
        super(CloudinaryMediaStorageTests, cls).setUpClass()
        cls.file_content = b'Content of file'
        cls.storage = MediaCloudinaryStorage(tag=TAG, resource_type='raw')
        cls.file_name, cls.file = cls.upload_file()