# Path: incuna_test_utils/factories/images.py
# SHORT_FILE_PATH = 'files/image.png'
# IMAGE_PATH = os.path.join(directory, SHORT_FILE_PATH)
# def simple_png():
#     def __init__(self, *args, **kwargs):
#     def __init__(self, method=None, *args, **kwargs):
#             def png_file(a):
# def uploadable_file():
# class LocalFileField(factory.django.FileField):
# class SimplePngFileField(factory.LazyAttribute):


from io import BufferedReader, BytesIO
from django.core.files import File
from incuna_test_utils.factories import images
import factory




# In Python 2 Django's File wraps the builtin `file`, but that doesn't exist in Python 3.
try:
    FILE_TYPE = file
except NameError:
    FILE_TYPE = BufferedReader


def test_local_file_field():
    class FileFactory(factory.StubFactory):
        image = images.LocalFileField()

    built_file = FileFactory.build().image
    assert isinstance(built_file, File)
    assert isinstance(built_file.file, FILE_TYPE)


def test_simple_png_file_field():
    class FileFactory(factory.StubFactory):
        image = images.SimplePngFileField()

    built_file = FileFactory.build().image
    assert isinstance(built_file, File)
    assert isinstance(built_file.file, BytesIO)


def test_uploadable_file():

# Path: incuna_test_utils/factories/images.py
# SHORT_FILE_PATH = 'files/image.png'
# IMAGE_PATH = os.path.join(directory, SHORT_FILE_PATH)
# def simple_png():
#     def __init__(self, *args, **kwargs):
#     def __init__(self, method=None, *args, **kwargs):
#             def png_file(a):
# def uploadable_file():
# class LocalFileField(factory.django.FileField):
# class SimplePngFileField(factory.LazyAttribute):


# Path: tests/factory_tests/test_images.py
from io import BufferedReader, BytesIO
from django.core.files import File
from incuna_test_utils.factories import images
import factory





# In Python 2 Django's File wraps the builtin `file`, but that doesn't exist in Python 3.
try:
    FILE_TYPE = file
except NameError:
    FILE_TYPE = BufferedReader


def test_local_file_field():
    class FileFactory(factory.StubFactory):
        image = images.LocalFileField()

    built_file = FileFactory.build().image
    assert isinstance(built_file, File)
    assert isinstance(built_file.file, FILE_TYPE)


def test_simple_png_file_field():
    class FileFactory(factory.StubFactory):
        image = images.SimplePngFileField()

    built_file = FileFactory.build().image
    assert isinstance(built_file, File)
    assert isinstance(built_file.file, BytesIO)


def test_uploadable_file():

    built_file = images.uploadable_file()