# Path: brasilcomvc/accounts/models.py
# class User(AbstractBaseUser, PermissionsMixin):
# 
#     # Personal Info
#     email = models.EmailField(unique=True)
#     full_name = models.CharField('Nome Completo', max_length=255)
#     username = models.SlugField(max_length=30, null=True, blank=True)
#     picture = ProcessedImageField(
#         null=True, blank=True,
#         format='JPEG',
#         options={'quality': 80},
#         processors=[ResizeToFill(256, 256)],
#         upload_to=user_picture_upload_to)
#     picture_medium = ImageSpecField(
#         format='JPEG',
#         options={'quality': 80},
#         processors=[ResizeToFill(128, 128)],
#         source='picture')
#     picture_small = ImageSpecField(
#         format='JPEG',
#         options={'quality': 80},
#         processors=[ResizeToFill(50, 50)],
#         source='picture')
# 
#     # Professional Info
#     job_title = models.CharField(max_length=80, null=True, blank=True)
#     bio = models.TextField(null=True, blank=True)
# 
#     # Status
#     date_joined = models.DateTimeField(auto_now_add=True)
#     date_updated = models.DateTimeField(auto_now=True)
#     is_active = models.BooleanField(editable=False, default=True)
#     is_staff = models.BooleanField(editable=False, default=False)
# 
#     # Notifications
#     email_newsletter = models.BooleanField(default=True)
# 
#     # Verbose names
#     email.verbose_name = 'e-mail'
#     full_name.verbose_name = 'nome completo'
#     username.verbose_name = 'nome de usuário'
#     picture.verbose_name = 'foto do usuário'
#     job_title.verbose_name = 'profissão'
#     bio.verbose_name = 'biografia'
# 
#     USERNAME_FIELD = 'email'
#     REQUIRED_FIELDS = ('full_name',)
# 
#     objects = UserManager()
# 
#     class Meta:
#         verbose_name = 'usuário'
# 
#     def get_short_name(self):
#         return self.full_name.split()[0] if self.full_name else ''
# 
#     def get_full_name(self):
#         return self.full_name
# 
#     def send_welcome_email(self):
#         send_template_email(
#             subject='Bem vindo!',
#             to=self.email,
#             template_name='emails/welcome.html',
#             context={'user': self})
# 
# Path: brasilcomvc/accounts/pipelines.py
# def set_user_info_from_auth_provider(backend, user, details, *args, **kwargs):
#     """Social auth pipeline to set user info returned from auth provider
#     """
#     if not user:
#         return
# 
#     user.email = details['email']
#     user.full_name = details['fullname']
# 
#     backend.strategy.storage.user.changed(user)


from django.test import TestCase
from ..models import User
from ..pipelines import set_user_info_from_auth_provider
import mock



class SetUserInfoFromAuthProviderTestCase(TestCase):

    def test_should_return_none_if_user_not_found(self):
        self.assertIsNone(set_user_info_from_auth_provider(None, None, None))

    def test_should_register_full_name_and_email_on_user_instance(self):
        backend = mock.Mock()
        details = {
            'email': 'cool@mailinator.com',
            'fullname': 'My Name Yo',
        }
        user = User()
        self.assertEqual(user.email, '')
        self.assertEqual(user.full_name, '')


# Path: brasilcomvc/accounts/models.py
# class User(AbstractBaseUser, PermissionsMixin):
# 
#     # Personal Info
#     email = models.EmailField(unique=True)
#     full_name = models.CharField('Nome Completo', max_length=255)
#     username = models.SlugField(max_length=30, null=True, blank=True)
#     picture = ProcessedImageField(
#         null=True, blank=True,
#         format='JPEG',
#         options={'quality': 80},
#         processors=[ResizeToFill(256, 256)],
#         upload_to=user_picture_upload_to)
#     picture_medium = ImageSpecField(
#         format='JPEG',
#         options={'quality': 80},
#         processors=[ResizeToFill(128, 128)],
#         source='picture')
#     picture_small = ImageSpecField(
#         format='JPEG',
#         options={'quality': 80},
#         processors=[ResizeToFill(50, 50)],
#         source='picture')
# 
#     # Professional Info
#     job_title = models.CharField(max_length=80, null=True, blank=True)
#     bio = models.TextField(null=True, blank=True)
# 
#     # Status
#     date_joined = models.DateTimeField(auto_now_add=True)
#     date_updated = models.DateTimeField(auto_now=True)
#     is_active = models.BooleanField(editable=False, default=True)
#     is_staff = models.BooleanField(editable=False, default=False)
# 
#     # Notifications
#     email_newsletter = models.BooleanField(default=True)
# 
#     # Verbose names
#     email.verbose_name = 'e-mail'
#     full_name.verbose_name = 'nome completo'
#     username.verbose_name = 'nome de usuário'
#     picture.verbose_name = 'foto do usuário'
#     job_title.verbose_name = 'profissão'
#     bio.verbose_name = 'biografia'
# 
#     USERNAME_FIELD = 'email'
#     REQUIRED_FIELDS = ('full_name',)
# 
#     objects = UserManager()
# 
#     class Meta:
#         verbose_name = 'usuário'
# 
#     def get_short_name(self):
#         return self.full_name.split()[0] if self.full_name else ''
# 
#     def get_full_name(self):
#         return self.full_name
# 
#     def send_welcome_email(self):
#         send_template_email(
#             subject='Bem vindo!',
#             to=self.email,
#             template_name='emails/welcome.html',
#             context={'user': self})
# 
# Path: brasilcomvc/accounts/pipelines.py
# def set_user_info_from_auth_provider(backend, user, details, *args, **kwargs):
#     """Social auth pipeline to set user info returned from auth provider
#     """
#     if not user:
#         return
# 
#     user.email = details['email']
#     user.full_name = details['fullname']
# 
#     backend.strategy.storage.user.changed(user)


# Path: brasilcomvc/accounts/tests/test_pipelines.py
from django.test import TestCase
from ..models import User
from ..pipelines import set_user_info_from_auth_provider
import mock




class SetUserInfoFromAuthProviderTestCase(TestCase):

    def test_should_return_none_if_user_not_found(self):
        self.assertIsNone(set_user_info_from_auth_provider(None, None, None))

    def test_should_register_full_name_and_email_on_user_instance(self):
        backend = mock.Mock()
        details = {
            'email': 'cool@mailinator.com',
            'fullname': 'My Name Yo',
        }
        user = User()
        self.assertEqual(user.email, '')
        self.assertEqual(user.full_name, '')


        set_user_info_from_auth_provider(backend, user, details)