# Path: app_author/models.py
# def validate_image(fieldfile_obj):
#     """
#     Limit image size upload
#     """
#     filesize = fieldfile_obj.file.size
#     megabyte_limit = 0.5
#     if filesize > megabyte_limit*1024*1024:
#         raise ValidationError("Max file size is %sMB" % str(megabyte_limit))


from unittest.mock import MagicMock
from django.core.exceptions import ValidationError
from django.test import SimpleTestCase
from app_author.models import validate_image




class AuthorModelTestCase(SimpleTestCase):

    def test_validate_image_author(self):
        obj = MagicMock()
        obj.file.size = 900000
        with self.assertRaisesMessage(ValidationError, 'Max file size is 0.5MB'):

# Path: app_author/models.py
# def validate_image(fieldfile_obj):
#     """
#     Limit image size upload
#     """
#     filesize = fieldfile_obj.file.size
#     megabyte_limit = 0.5
#     if filesize > megabyte_limit*1024*1024:
#         raise ValidationError("Max file size is %sMB" % str(megabyte_limit))


# Path: app_author/tests/test_models.py
from unittest.mock import MagicMock
from django.core.exceptions import ValidationError
from django.test import SimpleTestCase
from app_author.models import validate_image





class AuthorModelTestCase(SimpleTestCase):

    def test_validate_image_author(self):
        obj = MagicMock()
        obj.file.size = 900000
        with self.assertRaisesMessage(ValidationError, 'Max file size is 0.5MB'):

            validate_image(obj)