# Path: user_management/api/avatar/views.py
# class AvatarAPIViewBase(generics.RetrieveUpdateAPIView):
# class ProfileAvatar(AvatarAPIViewBase):
# class UserAvatar(AvatarAPIViewBase):
#     def post(self, *args, **kwargs):
#     def get_object(self):
#     def delete(self, request, *args, **kwargs):
# 
# Path: user_management/models/tests/factories.py
# class AuthTokenFactory(factory.DjangoModelFactory):
#     key = factory.Sequence('key{}'.format)
#     user = factory.SubFactory(UserFactory)
# 
#     class Meta:
#         model = AuthToken
# 
# class UserFactory(factory.DjangoModelFactory):
#     name = factory.Sequence('Test User {}'.format)
#     email = factory.Sequence('email{}@example.com'.format)
#     is_active = True
# 
#     class Meta:
#         model = get_user_model()
# 
#     @factory.post_generation
#     def password(self, create, extracted='default password', **kwargs):
#         self.raw_password = extracted
#         self.set_password(self.raw_password)
#         if create:
#             self.save()
# 
# Path: user_management/models/tests/utils.py
# class APIRequestTestCase(Python2AssertMixin, BaseAPIRequestTestCase):
#     user_factory = UserFactory


from io import BytesIO
from django.contrib.auth import get_user_model
from django.test.client import Client
from django.urls import reverse
from mock import patch
from PIL import Image
from rest_framework import status
from rest_framework.test import APIRequestFactory, force_authenticate
from user_management.api.avatar import views
from user_management.models.tests.factories import AuthTokenFactory, UserFactory
from user_management.models.tests.utils import APIRequestTestCase




User = get_user_model()
TEST_SERVER = 'http://testserver'


def _simple_png():
    """Create a 1x1 black png in memory."""
    image_file = BytesIO()
    image = Image.new('RGBA', (1, 1))
    image.save(image_file, 'png')
    image_file._committed = True
    image_file.name = 'test.png'
    image_file.url = '{0}/{1}'.format(
        TEST_SERVER,
        image_file.name
    )
    image_file.seek(0)
    return image_file
SIMPLE_PNG = _simple_png()


class TestProfileAvatar(APIRequestTestCase):

# Path: user_management/api/avatar/views.py
# class AvatarAPIViewBase(generics.RetrieveUpdateAPIView):
# class ProfileAvatar(AvatarAPIViewBase):
# class UserAvatar(AvatarAPIViewBase):
#     def post(self, *args, **kwargs):
#     def get_object(self):
#     def delete(self, request, *args, **kwargs):
# 
# Path: user_management/models/tests/factories.py
# class AuthTokenFactory(factory.DjangoModelFactory):
#     key = factory.Sequence('key{}'.format)
#     user = factory.SubFactory(UserFactory)
# 
#     class Meta:
#         model = AuthToken
# 
# class UserFactory(factory.DjangoModelFactory):
#     name = factory.Sequence('Test User {}'.format)
#     email = factory.Sequence('email{}@example.com'.format)
#     is_active = True
# 
#     class Meta:
#         model = get_user_model()
# 
#     @factory.post_generation
#     def password(self, create, extracted='default password', **kwargs):
#         self.raw_password = extracted
#         self.set_password(self.raw_password)
#         if create:
#             self.save()
# 
# Path: user_management/models/tests/utils.py
# class APIRequestTestCase(Python2AssertMixin, BaseAPIRequestTestCase):
#     user_factory = UserFactory


# Path: user_management/api/avatar/tests/test_views.py
from io import BytesIO
from django.contrib.auth import get_user_model
from django.test.client import Client
from django.urls import reverse
from mock import patch
from PIL import Image
from rest_framework import status
from rest_framework.test import APIRequestFactory, force_authenticate
from user_management.api.avatar import views
from user_management.models.tests.factories import AuthTokenFactory, UserFactory
from user_management.models.tests.utils import APIRequestTestCase





User = get_user_model()
TEST_SERVER = 'http://testserver'


def _simple_png():
    """Create a 1x1 black png in memory."""
    image_file = BytesIO()
    image = Image.new('RGBA', (1, 1))
    image.save(image_file, 'png')
    image_file._committed = True
    image_file.name = 'test.png'
    image_file.url = '{0}/{1}'.format(
        TEST_SERVER,
        image_file.name
    )
    image_file.seek(0)
    return image_file
SIMPLE_PNG = _simple_png()


class TestProfileAvatar(APIRequestTestCase):

    view_class = views.ProfileAvatar